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[] { findDocumentHighlight(document: TextDocument, position: Position): DocumentHighlight[] {
updateCurrentTextDocument(document); updateCurrentTextDocument(document);
let occurrences = jsLanguageService.getOccurrencesAtPosition(FILE_NAME, currentTextDocument.offsetAt(position)); const highlights = jsLanguageService.getDocumentHighlights(FILE_NAME, currentTextDocument.offsetAt(position), [FILE_NAME]);
if (occurrences) { const out: DocumentHighlight[] = [];
return occurrences.map(entry => { for (const entry of highlights || []) {
return { for (const highlight of entry.highlightSpans) {
range: convertRange(currentTextDocument, entry.textSpan), out.push({
kind: <DocumentHighlightKind>(entry.isWriteAccess ? DocumentHighlightKind.Write : DocumentHighlightKind.Text) range: convertRange(currentTextDocument, highlight.textSpan),
}; kind: highlight.kind === 'writtenReference' ? DocumentHighlightKind.Write : DocumentHighlightKind.Text
}); });
}
} }
return []; return out;
}, },
findDocumentSymbols(document: TextDocument): SymbolInformation[] { findDocumentSymbols(document: TextDocument): SymbolInformation[] {
updateCurrentTextDocument(document); updateCurrentTextDocument(document);

View file

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