MCPcopy
hub / github.com/jquery/esprima / parseClassDeclaration

Method parseClassDeclaration

src/parser.ts:3286–3303  ·  view source on GitHub ↗
(identifierIsOptional?: boolean)

Source from the content-addressed store, hash-verified

3284 }
3285
3286 parseClassDeclaration(identifierIsOptional?: boolean): Node.ClassDeclaration {
3287 const node = this.createNode();
3288
3289 const previousStrict = this.context.strict;
3290 this.context.strict = true;
3291 this.expectKeyword('class');
3292
3293 const id = (identifierIsOptional && (this.lookahead.type !== Token.Identifier)) ? null : this.parseVariableIdentifier();
3294 let superClass: Node.Identifier | null = null;
3295 if (this.matchKeyword('extends')) {
3296 this.nextToken();
3297 superClass = this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall);
3298 }
3299 const classBody = this.parseClassBody();
3300 this.context.strict = previousStrict;
3301
3302 return this.finalize(node, new Node.ClassDeclaration(id, superClass, classBody));
3303 }
3304
3305 parseClassExpression(): Node.ClassExpression {
3306 const node = this.createNode();

Callers 3

Calls 8

createNodeMethod · 0.95
expectKeywordMethod · 0.95
matchKeywordMethod · 0.95
nextTokenMethod · 0.95
isolateCoverGrammarMethod · 0.95
parseClassBodyMethod · 0.95
finalizeMethod · 0.95

Tested by

no test coverage detected