MCPcopy Create free account
hub / github.com/babel/babel / parseClassMemberWithIsStatic

Function parseClassMemberWithIsStatic

packages/babel-parser/src/parser/statement.ts:1782–1969  ·  view source on GitHub ↗
(
    this: Parser,
    classBody: Undone<N.ClassBody>,
    member: Undone<N.ClassMember>,
    state: N.ParseClassMemberState,
    isStatic: boolean,
  )

Source from the content-addressed store, hash-verified

1780 }
1781
1782 parseClassMemberWithIsStatic(
1783 this: Parser,
1784 classBody: Undone<N.ClassBody>,
1785 member: Undone<N.ClassMember>,
1786 state: N.ParseClassMemberState,
1787 isStatic: boolean,
1788 ) {
1789 const publicMethod = member as Undone<N.ClassMethod>;
1790 const privateMethod = member as Undone<N.ClassPrivateMethod>;
1791 const publicProp = member as Undone<N.ClassProperty>;
1792 const privateProp = member as Undone<N.ClassPrivateProperty>;
1793 const accessorProp = member as Undone<N.ClassAccessorProperty>;
1794
1795 const method: typeof publicMethod | typeof privateMethod = publicMethod;
1796 const publicMember: typeof publicMethod | typeof publicProp = publicMethod;
1797
1798 member.static = isStatic;
1799 this.parsePropertyNamePrefixOperator(member);
1800
1801 if (this.eat(tt.star)) {
1802 // a generator
1803 method.kind = "method";
1804 const isPrivateName = this.match(tt.privateName);
1805 this.parseClassElementName(method);
1806 this.parsePostMemberNameModifiers(method);
1807
1808 if (isPrivateName) {
1809 // Private generator method
1810 this.pushClassPrivateMethod(classBody, privateMethod, true, false);
1811 return;
1812 }
1813
1814 if (this.isNonstaticConstructor(publicMethod)) {
1815 this.raise(Errors.ConstructorIsGenerator, publicMethod.key);
1816 }
1817
1818 this.pushClassMethod(
1819 classBody,
1820 publicMethod,
1821 true,
1822 false,
1823 /* isConstructor */ false,
1824 false,
1825 );
1826
1827 return;
1828 }
1829
1830 const isContextual =
1831 !this.state.containsEsc && tokenIsIdentifier(this.state.type);
1832 const key = this.parseClassElementName(member);
1833 const maybeContextualKw = isContextual ? (key as N.Identifier).name : null;
1834 const isPrivate = this.isPrivateName(key);
1835 const maybeQuestionTokenStartLoc = this.state.startLoc;
1836
1837 this.parsePostMemberNameModifiers(publicMember);
1838
1839 if (this.isClassMethod()) {

Callers

nothing calls this directly

Calls 13

tokenIsIdentifierFunction · 0.90
matchMethod · 0.80
hasPluginMethod · 0.80
isPrivateNameMethod · 0.65
isClassMethodMethod · 0.65
isClassPropertyMethod · 0.65

Tested by

no test coverage detected