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

Function parseArrowExpression

packages/babel-parser/src/parser/expression.ts:2521–2572  ·  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

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