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

Function parseArrowExpression

packages/babel-parser/src/parser/expression.ts:2520–2571  ·  view source on GitHub ↗
(
    this: Parser,
    node: Undone<N.ArrowFunctionExpression>,
    params:
      | (
          | N.Expression
          | N.SpreadElement
          | N.VoidPattern
          | N.AssignmentPattern
          | N.ArgumentPlaceholder
          | N.TSTypeCastExpression
        )[]
      | (
          | N.Expression
          | N.RestElement
          | N.VoidPattern
          | N.AssignmentPattern
          | N.ArgumentPlaceholder
          | N.TSTypeCastExpression
        )[]
      | null
      | undefined,
    isAsync: boolean,
    trailingCommaLoc?: Position | null,
  )

Source from the content-addressed store, hash-verified

2518 // If the parameters are provided, they will be converted to an
2519 // assignable list.
2520 parseArrowExpression(
2521 this: Parser,
2522 node: Undone<N.ArrowFunctionExpression>,
2523 params:
2524 | (
2525 | N.Expression
2526 | N.SpreadElement
2527 | N.VoidPattern
2528 | N.AssignmentPattern
2529 | N.ArgumentPlaceholder
2530 | N.TSTypeCastExpression
2531 )[]
2532 | (
2533 | N.Expression
2534 | N.RestElement
2535 | N.VoidPattern
2536 | N.AssignmentPattern
2537 | N.ArgumentPlaceholder
2538 | N.TSTypeCastExpression
2539 )[]
2540 | null
2541 | undefined,
2542 isAsync: boolean,
2543 trailingCommaLoc?: Position | null,
2544 ): N.ArrowFunctionExpression {
2545 this.scope.enter(ScopeFlag.FUNCTION | ScopeFlag.ARROW);
2546 let flags = functionFlags(isAsync, false);
2547 // ConciseBody[In] :
2548 // [lookahead ≠ {] ExpressionBody[?In, ~Await]
2549 // { FunctionBody[~Yield, ~Await] }
2550 const hasBlockBody = this.match(tt.braceL);
2551 if (!hasBlockBody) {
2552 flags |=
2553 this.prodParam.currentFlags() &
2554 (ParamKind.PARAM_IN | ParamKind.PARAM_NOT_FSHARP_PIPELINE_DIRECT_BODY);
2555 }
2556 this.prodParam.enter(flags);
2557 this.initFunction(node, isAsync);
2558
2559 if (params) {
2560 this.setArrowFunctionParameters(node, params, trailingCommaLoc);
2561 }
2562 this.parseFunctionBody(node, true);
2563 if (hasBlockBody) {
2564 this.state.regExpAllowedAt = this.state.lastTokEndLoc!.index;
2565 }
2566
2567 this.prodParam.exit();
2568 this.scope.exit();
2569
2570 return this.finishNode(node, "ArrowFunctionExpression");
2571 }
2572
2573 setArrowFunctionParameters(
2574 node: Undone<N.ArrowFunctionExpression>,

Callers

nothing calls this directly

Calls 9

functionFlagsFunction · 0.90
matchMethod · 0.80
currentFlagsMethod · 0.80
initFunctionMethod · 0.80
finishNodeMethod · 0.80
enterMethod · 0.45
parseFunctionBodyMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected