`kind` should be a token kind.
(kind Kind, file *SourceFile, pos, end int, flags TokenFlags)
| 2803 | |
| 2804 | // `kind` should be a token kind. |
| 2805 | func createToken(kind Kind, file *SourceFile, pos, end int, flags TokenFlags) *Node { |
| 2806 | if file.tokenFactory == nil { |
| 2807 | file.tokenFactory = NewNodeFactory(NodeFactoryHooks{}) |
| 2808 | } |
| 2809 | text := file.text[pos:end] |
| 2810 | switch kind { |
| 2811 | case KindNumericLiteral: |
| 2812 | return file.tokenFactory.NewNumericLiteral(text, flags) |
| 2813 | case KindBigIntLiteral: |
| 2814 | return file.tokenFactory.NewBigIntLiteral(text, flags) |
| 2815 | case KindStringLiteral: |
| 2816 | return file.tokenFactory.NewStringLiteral(text, flags) |
| 2817 | case KindJsxText, KindJsxTextAllWhiteSpaces: |
| 2818 | return file.tokenFactory.NewJsxText(text, kind == KindJsxTextAllWhiteSpaces) |
| 2819 | case KindRegularExpressionLiteral: |
| 2820 | return file.tokenFactory.NewRegularExpressionLiteral(text, flags) |
| 2821 | case KindNoSubstitutionTemplateLiteral: |
| 2822 | return file.tokenFactory.NewNoSubstitutionTemplateLiteral(text, flags) |
| 2823 | case KindTemplateHead: |
| 2824 | return file.tokenFactory.NewTemplateHead(text, "" /*rawText*/, flags) |
| 2825 | case KindTemplateMiddle: |
| 2826 | return file.tokenFactory.NewTemplateMiddle(text, "" /*rawText*/, flags) |
| 2827 | case KindTemplateTail: |
| 2828 | return file.tokenFactory.NewTemplateTail(text, "" /*rawText*/, flags) |
| 2829 | case KindIdentifier: |
| 2830 | return file.tokenFactory.NewIdentifier(text) |
| 2831 | case KindPrivateIdentifier: |
| 2832 | return file.tokenFactory.NewPrivateIdentifier(text) |
| 2833 | default: // Punctuation and keywords |
| 2834 | return file.tokenFactory.NewToken(kind) |
| 2835 | } |
| 2836 | } |
| 2837 | |
| 2838 | func (node *SourceFile) GetDeclarationMap() map[string][]*Node { |
| 2839 | node.declarationMapMu.Lock() |
no test coverage detected