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

Function parseArrowExpression

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

Source from the content-addressed store, hash-verified

2409 // If the parameters are provided, they will be converted to an
2410 // assignable list.
2411 parseArrowExpression(
2412 this: Parser,
2413 node: Undone<N.ArrowFunctionExpression>,
2414 params:
2415 | (
2416 | N.Expression
2417 | N.SpreadElement
2418 | N.VoidPattern
2419 | N.AssignmentPattern
2420 | N.ArgumentPlaceholder
2421 | N.TypeCastExpression
2422 | N.TSTypeCastExpression
2423 )[]
2424 | (
2425 | N.Expression
2426 | N.RestElement
2427 | N.VoidPattern
2428 | N.AssignmentPattern
2429 | N.ArgumentPlaceholder
2430 | N.TypeCastExpression
2431 | N.TSTypeCastExpression
2432 )[]
2433 | null
2434 | undefined,
2435 isAsync: boolean,
2436 trailingCommaLoc?: Position | null,
2437 ): N.ArrowFunctionExpression {
2438 this.scope.enter(ScopeFlag.FUNCTION | ScopeFlag.ARROW);
2439 let flags = functionFlags(isAsync, false);
2440 // ConciseBody[In] :
2441 // [lookahead ≠ {] ExpressionBody[?In, ~Await]
2442 // { FunctionBody[~Yield, ~Await] }
2443 if (!this.match(tt.braceL)) {
2444 flags |=
2445 this.prodParam.currentFlags() &
2446 (ParamKind.PARAM_IN | ParamKind.PARAM_NOT_FSHARP_PIPELINE_DIRECT_BODY);
2447 }
2448 this.prodParam.enter(flags);
2449 this.initFunction(node, isAsync);
2450
2451 if (params) {
2452 this.setArrowFunctionParameters(node, params, trailingCommaLoc);
2453 }
2454 this.parseFunctionBody(node, true);
2455
2456 this.prodParam.exit();
2457 this.scope.exit();
2458
2459 return this.finishNode(node, "ArrowFunctionExpression");
2460 }
2461
2462 setArrowFunctionParameters(
2463 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