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

Function parseClassMemberWithIsStatic

packages/babel-parser/src/parser/statement.ts:1779–1966  ·  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

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