提交 4f227dd8 编写于 作者: M Matt Bierner

Use 'references' instead of 'occurrence' to power document highlights

`occurrence` is marked as deprecated
上级 61e117b2
...@@ -8,8 +8,6 @@ import * as Proto from '../protocol'; ...@@ -8,8 +8,6 @@ import * as Proto from '../protocol';
import { ITypeScriptServiceClient } from '../typescriptService'; import { ITypeScriptServiceClient } from '../typescriptService';
import * as typeConverters from '../utils/typeConverters'; import * as typeConverters from '../utils/typeConverters';
class TypeScriptDocumentHighlightProvider implements vscode.DocumentHighlightProvider { class TypeScriptDocumentHighlightProvider implements vscode.DocumentHighlightProvider {
public constructor( public constructor(
private readonly client: ITypeScriptServiceClient private readonly client: ITypeScriptServiceClient
...@@ -26,21 +24,21 @@ class TypeScriptDocumentHighlightProvider implements vscode.DocumentHighlightPro ...@@ -26,21 +24,21 @@ class TypeScriptDocumentHighlightProvider implements vscode.DocumentHighlightPro
} }
const args = typeConverters.Position.toFileLocationRequestArgs(file, position); const args = typeConverters.Position.toFileLocationRequestArgs(file, position);
const response = await this.client.execute('occurrences', args, token); const response = await this.client.execute('references', args, token);
if (response.type !== 'response' || !response.body) { if (response.type !== 'response' || !response.body) {
return []; return [];
} }
return response.body return response.body.refs
.filter(x => !x.isInString) .filter(ref => ref.file === file)
.map(documentHighlightFromOccurance); .map(documentHighlightFromReference);
} }
} }
function documentHighlightFromOccurance(occurrence: Proto.OccurrencesResponseItem): vscode.DocumentHighlight { function documentHighlightFromReference(reference: Proto.ReferencesResponseItem): vscode.DocumentHighlight {
return new vscode.DocumentHighlight( return new vscode.DocumentHighlight(
typeConverters.Range.fromTextSpan(occurrence), typeConverters.Range.fromTextSpan(reference),
occurrence.isWriteAccess ? vscode.DocumentHighlightKind.Write : vscode.DocumentHighlightKind.Read); reference.isWriteAccess ? vscode.DocumentHighlightKind.Write : vscode.DocumentHighlightKind.Read);
} }
export function register( export function register(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册