MCPcopy Create free account
hub / github.com/nodejs/node / getSemanticDocumentHighlights

Function getSemanticDocumentHighlights

test/fixtures/snapshot/typescript.js:135556–135576  ·  view source on GitHub ↗
(position, node, program, cancellationToken, sourceFilesToSearch)

Source from the content-addressed store, hash-verified

135554 };
135555 }
135556 function getSemanticDocumentHighlights(position, node, program, cancellationToken, sourceFilesToSearch) {
135557 var sourceFilesSet = new ts.Set(sourceFilesToSearch.map(function (f) { return f.fileName; }));
135558 var referenceEntries = ts.FindAllReferences.getReferenceEntriesForNode(position, node, program, sourceFilesToSearch, cancellationToken, /*options*/ undefined, sourceFilesSet);
135559 if (!referenceEntries)
135560 return undefined;
135561 var map = ts.arrayToMultiMap(referenceEntries.map(ts.FindAllReferences.toHighlightSpan), function (e) { return e.fileName; }, function (e) { return e.span; });
135562 var getCanonicalFileName = ts.createGetCanonicalFileName(program.useCaseSensitiveFileNames());
135563 return ts.mapDefined(ts.arrayFrom(map.entries()), function (_a) {
135564 var fileName = _a[0], highlightSpans = _a[1];
135565 if (!sourceFilesSet.has(fileName)) {
135566 if (!program.redirectTargetsMap.has(ts.toPath(fileName, program.getCurrentDirectory(), getCanonicalFileName))) {
135567 return undefined;
135568 }
135569 var redirectTarget_1 = program.getSourceFile(fileName);
135570 var redirect = ts.find(sourceFilesToSearch, function (f) { return !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; });
135571 fileName = redirect.fileName;
135572 ts.Debug.assert(sourceFilesSet.has(fileName));
135573 }
135574 return { fileName: fileName, highlightSpans: highlightSpans };
135575 });
135576 }
135577 function getSyntacticDocumentHighlights(node, sourceFile) {
135578 var highlightSpans = getHighlightSpans(node, sourceFile);
135579 return highlightSpans && [{ fileName: sourceFile.fileName, highlightSpans: highlightSpans }];

Callers 1

getDocumentHighlightsFunction · 0.85

Calls 5

assertMethod · 0.80
mapMethod · 0.65
hasMethod · 0.65
findMethod · 0.65
entriesMethod · 0.45

Tested by

no test coverage detected