Use proper documentHighlights api for html js intellisense

This commit is contained in:
Matt Bierner 2019-04-10 14:22:21 -07:00
parent 90c9650399
commit d81145d3f0
2 changed files with 10 additions and 10 deletions

View file

@ -173,16 +173,17 @@ export function getJavaScriptMode(documentRegions: LanguageModelCache<HTMLDocume
},
findDocumentHighlight(document: TextDocument, position: Position): DocumentHighlight[] {
updateCurrentTextDocument(document);
let occurrences = jsLanguageService.getOccurrencesAtPosition(FILE_NAME, currentTextDocument.offsetAt(position));
if (occurrences) {
return occurrences.map(entry => {
return {
range: convertRange(currentTextDocument, entry.textSpan),
kind: <DocumentHighlightKind>(entry.isWriteAccess ? DocumentHighlightKind.Write : DocumentHighlightKind.Text)
};
});
const highlights = jsLanguageService.getDocumentHighlights(FILE_NAME, currentTextDocument.offsetAt(position), [FILE_NAME]);
const out: DocumentHighlight[] = [];
for (const entry of highlights || []) {
for (const highlight of entry.highlightSpans) {
out.push({
range: convertRange(currentTextDocument, highlight.textSpan),
kind: highlight.kind === 'writtenReference' ? DocumentHighlightKind.Write : DocumentHighlightKind.Text
});
}
}
return [];
return out;
},
findDocumentSymbols(document: TextDocument): SymbolInformation[] {
updateCurrentTextDocument(document);

View file

@ -49,7 +49,6 @@ export interface TypeScriptRequestTypes {
'jsxClosingTag': [Proto.JsxClosingTagRequestArgs, Proto.JsxClosingTagResponse];
'navto': [Proto.NavtoRequestArgs, Proto.NavtoResponse];
'navtree': [Proto.FileRequestArgs, Proto.NavTreeResponse];
'occurrences': [Proto.FileLocationRequestArgs, Proto.OccurrencesResponse];
'organizeImports': [Proto.OrganizeImportsRequestArgs, Proto.OrganizeImportsResponse];
'projectInfo': [Proto.ProjectInfoRequestArgs, Proto.ProjectInfoResponse];
'quickinfo': [Proto.FileLocationRequestArgs, Proto.QuickInfoResponse];