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

Function parseMethod

packages/babel-parser/src/parser/expression.ts:2472–2497  ·  view source on GitHub ↗
(
    this: Parser,
    node: Undone<T>,
    isGenerator: boolean,
    isAsync: boolean,
    isConstructor: boolean,
    allowDirectSuper: boolean,
    type: T["type"],
    inClassScope: boolean = false,
  )

Source from the content-addressed store, hash-verified

2470 // Parse object or class method.
2471
2472 parseMethod<T extends N.ObjectMethod | N.ClassMethod | N.ClassPrivateMethod>(
2473 this: Parser,
2474 node: Undone<T>,
2475 isGenerator: boolean,
2476 isAsync: boolean,
2477 isConstructor: boolean,
2478 allowDirectSuper: boolean,
2479 type: T["type"],
2480 inClassScope: boolean = false,
2481 ): T {
2482 this.initFunction(node, isAsync);
2483 node.generator = isGenerator;
2484 this.scope.enter(
2485 ScopeFlag.FUNCTION |
2486 ScopeFlag.SUPER |
2487 (inClassScope ? ScopeFlag.CLASS : 0) |
2488 (allowDirectSuper ? ScopeFlag.DIRECT_SUPER : 0),
2489 );
2490 this.prodParam.enter(functionFlags(isAsync, node.generator));
2491 this.parseFunctionParams(node, isConstructor);
2492 const finishedNode = this.parseFunctionBodyAndFinish(node, type, true);
2493 this.prodParam.exit();
2494 this.scope.exit();
2495
2496 return finishedNode;
2497 }
2498
2499 // parse an array literal
2500 // https://tc39.es/ecma262/#prod-ArrayLiteral

Callers

nothing calls this directly

Calls 6

functionFlagsFunction · 0.90
initFunctionMethod · 0.80
enterMethod · 0.45
parseFunctionParamsMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected