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

Function finishTopicReference

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

Source from the content-addressed store, hash-verified

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