(program, sourceFile, span, collector, cancellationToken)
| 131013 | return resultTokens; |
| 131014 | } |
| 131015 | function collectTokens(program, sourceFile, span, collector, cancellationToken) { |
| 131016 | var typeChecker = program.getTypeChecker(); |
| 131017 | var inJSXElement = false; |
| 131018 | function visit(node) { |
| 131019 | switch (node.kind) { |
| 131020 | case 261 /* SyntaxKind.ModuleDeclaration */: |
| 131021 | case 257 /* SyntaxKind.ClassDeclaration */: |
| 131022 | case 258 /* SyntaxKind.InterfaceDeclaration */: |
| 131023 | case 256 /* SyntaxKind.FunctionDeclaration */: |
| 131024 | case 226 /* SyntaxKind.ClassExpression */: |
| 131025 | case 213 /* SyntaxKind.FunctionExpression */: |
| 131026 | case 214 /* SyntaxKind.ArrowFunction */: |
| 131027 | cancellationToken.throwIfCancellationRequested(); |
| 131028 | } |
| 131029 | if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { |
| 131030 | return; |
| 131031 | } |
| 131032 | var prevInJSXElement = inJSXElement; |
| 131033 | if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) { |
| 131034 | inJSXElement = true; |
| 131035 | } |
| 131036 | if (ts.isJsxExpression(node)) { |
| 131037 | inJSXElement = false; |
| 131038 | } |
| 131039 | if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) { |
| 131040 | var symbol = typeChecker.getSymbolAtLocation(node); |
| 131041 | if (symbol) { |
| 131042 | if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { |
| 131043 | symbol = typeChecker.getAliasedSymbol(symbol); |
| 131044 | } |
| 131045 | var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node)); |
| 131046 | if (typeIdx !== undefined) { |
| 131047 | var modifierSet = 0; |
| 131048 | if (node.parent) { |
| 131049 | var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx); |
| 131050 | if (parentIsDeclaration && node.parent.name === node) { |
| 131051 | modifierSet = 1 << 0 /* TokenModifier.declaration */; |
| 131052 | } |
| 131053 | } |
| 131054 | // property declaration in constructor |
| 131055 | if (typeIdx === 6 /* TokenType.parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { |
| 131056 | typeIdx = 9 /* TokenType.property */; |
| 131057 | } |
| 131058 | typeIdx = reclassifyByType(typeChecker, node, typeIdx); |
| 131059 | var decl = symbol.valueDeclaration; |
| 131060 | if (decl) { |
| 131061 | var modifiers = ts.getCombinedModifierFlags(decl); |
| 131062 | var nodeFlags = ts.getCombinedNodeFlags(decl); |
| 131063 | if (modifiers & 32 /* ModifierFlags.Static */) { |
| 131064 | modifierSet |= 1 << 1 /* TokenModifier.static */; |
| 131065 | } |
| 131066 | if (modifiers & 256 /* ModifierFlags.Async */) { |
| 131067 | modifierSet |= 1 << 2 /* TokenModifier.async */; |
| 131068 | } |
| 131069 | if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) { |
| 131070 | if ((modifiers & 64 /* ModifierFlags.Readonly */) || (nodeFlags & 2 /* NodeFlags.Const */) || (symbol.getFlags() & 8 /* SymbolFlags.EnumMember */)) { |
| 131071 | modifierSet |= 1 << 3 /* TokenModifier.readonly */; |
| 131072 | } |
no test coverage detected