(typeChecker, cancellationToken, sourceFile, classifiableNames, span)
| 130392 | } |
| 130393 | /* @internal */ |
| 130394 | function getEncodedSemanticClassifications(typeChecker, cancellationToken, sourceFile, classifiableNames, span) { |
| 130395 | var spans = []; |
| 130396 | sourceFile.forEachChild(function cb(node) { |
| 130397 | // Only walk into nodes that intersect the requested span. |
| 130398 | if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { |
| 130399 | return; |
| 130400 | } |
| 130401 | checkForClassificationCancellation(cancellationToken, node.kind); |
| 130402 | // Only bother calling into the typechecker if this is an identifier that |
| 130403 | // could possibly resolve to a type name. This makes classification run |
| 130404 | // in a third of the time it would normally take. |
| 130405 | if (ts.isIdentifier(node) && !ts.nodeIsMissing(node) && classifiableNames.has(node.escapedText)) { |
| 130406 | var symbol = typeChecker.getSymbolAtLocation(node); |
| 130407 | var type = symbol && classifySymbol(symbol, ts.getMeaningFromLocation(node), typeChecker); |
| 130408 | if (type) { |
| 130409 | pushClassification(node.getStart(sourceFile), node.getEnd(), type); |
| 130410 | } |
| 130411 | } |
| 130412 | node.forEachChild(cb); |
| 130413 | }); |
| 130414 | return { spans: spans, endOfLineState: 0 /* EndOfLineState.None */ }; |
| 130415 | function pushClassification(start, end, type) { |
| 130416 | var length = end - start; |
| 130417 | ts.Debug.assert(length > 0, "Classification had non-positive length of ".concat(length)); |
| 130418 | spans.push(start); |
| 130419 | spans.push(length); |
| 130420 | spans.push(type); |
| 130421 | } |
| 130422 | } |
| 130423 | ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; |
| 130424 | function classifySymbol(symbol, meaningAtPosition, checker) { |
| 130425 | var flags = symbol.getFlags(); |
no test coverage detected