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

Function finishTopicReference

packages/babel-parser/src/parser/expression.ts:1494–1521  ·  view source on GitHub ↗
(
    node: Undone<N.TopicReference>,
    startLoc: Position,
    pipeProposal: string,
    tokenType: TokenType,
  )

Source from the content-addressed store, hash-verified

1492 // but if the given `tokenType` does not match the plugin’s configuration,
1493 // then this method will throw a `PipeTopicUnconfiguredToken` error.
1494 finishTopicReference(
1495 node: Undone<N.TopicReference>,
1496 startLoc: Position,
1497 pipeProposal: string,
1498 tokenType: TokenType,
1499 ): N.TopicReference {
1500 if (
1501 this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)
1502 ) {
1503 // The token matches the plugin’s configuration.
1504 // The token is therefore a topic reference.
1505
1506 if (!this.topicReferenceIsAllowedInCurrentContext()) {
1507 this.raise(Errors.PipeTopicUnbound, startLoc);
1508 }
1509
1510 // Register the topic reference so that its pipe body knows
1511 // that its topic was used at least once.
1512 this.registerTopicReference();
1513
1514 return this.finishNode(node, "TopicReference");
1515 } else {
1516 // The token does not match the plugin’s configuration.
1517 throw this.raise(Errors.PipeTopicUnconfiguredToken, startLoc, {
1518 token: tokenLabelName(tokenType),
1519 });
1520 }
1521 }
1522
1523 // This helper method tests whether the given token type
1524 // matches the pipelineOperator parser plugin’s configuration.

Callers

nothing calls this directly

Calls 2

tokenLabelNameFunction · 0.90
finishNodeMethod · 0.80

Tested by

no test coverage detected