({
types: { isIdentifier, numericLiteral },
}: PluginAPI)
| 548 | } |
| 549 | |
| 550 | function pluginBabelParserTokenType({ |
| 551 | types: { isIdentifier, numericLiteral }, |
| 552 | }: PluginAPI) { |
| 553 | const tokenTypesMapping = getTokenTypesMapping(); |
| 554 | return { |
| 555 | visitor: { |
| 556 | MemberExpression(path) { |
| 557 | const { node } = path; |
| 558 | if ( |
| 559 | isIdentifier(node.object, { name: "tt" }) && |
| 560 | isIdentifier(node.property) && |
| 561 | !node.computed |
| 562 | ) { |
| 563 | const tokenName = node.property.name; |
| 564 | const tokenType = tokenTypesMapping.get(node.property.name); |
| 565 | if (tokenType === undefined) { |
| 566 | throw path.buildCodeFrameError( |
| 567 | `${tokenName} is not defined in ${tokenTypeSourcePath}` |
| 568 | ); |
| 569 | } |
| 570 | path.replaceWith(numericLiteral(tokenType)); |
| 571 | } |
| 572 | }, |
| 573 | }, |
| 574 | } as PluginObject; |
| 575 | } |
| 576 | |
| 577 | function pluginGeneratorOptimization({ types: t }: PluginAPI) { |
| 578 | const generatorNames: string[] = []; |
nothing calls this directly
no test coverage detected