@volar/language-service 2.0.0-alpha.3 → 2.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  import type * as vscode from 'vscode-languageserver-protocol';
2
2
  import type { ServiceContext } from '../types';
3
- export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
3
+ export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, referenceContext: vscode.ReferenceContext, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
@@ -6,7 +6,7 @@ const dedupe = require("../utils/dedupe");
6
6
  const cancellation_1 = require("../utils/cancellation");
7
7
  const language_core_1 = require("@volar/language-core");
8
8
  function register(context) {
9
- return (uri, position, token = cancellation_1.NoneCancellationToken) => {
9
+ return (uri, position, referenceContext, token = cancellation_1.NoneCancellationToken) => {
10
10
  return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isReferencesEnabled), async (service, document, position) => {
11
11
  if (token.isCancellationRequested)
12
12
  return;
@@ -20,7 +20,7 @@ function register(context) {
20
20
  if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
21
21
  return;
22
22
  recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
23
- const references = await service[1].provideReferences(document, position, token) ?? [];
23
+ const references = await service[1].provideReferences(document, position, referenceContext, token) ?? [];
24
24
  for (const reference of references) {
25
25
  let foundMirrorPosition = false;
26
26
  recursiveChecker.add({ uri: reference.uri, range: { start: reference.range.start, end: reference.range.start } });
@@ -16,21 +16,7 @@ function register(context) {
16
16
  // item.range already transformed in codeLens request
17
17
  }
18
18
  if (data?.kind === 'references') {
19
- let references = await findReferences(data.sourceFileUri, item.range.start, token) ?? [];
20
- const service = context.services[data.serviceIndex];
21
- if (service[1].resolveReferencesCodeLensLocations) {
22
- const workerFileName = context.env.uriToFileName(data.workerFileUri);
23
- const virtualFile = context.language.files.getVirtualFile(workerFileName)[0];
24
- const sourceFile = context.language.files.getSourceFile(workerFileName);
25
- if (virtualFile) {
26
- const document = context.documents.get(context.env.fileNameToUri(virtualFile.fileName), virtualFile.languageId, virtualFile.snapshot);
27
- references = await service[1].resolveReferencesCodeLensLocations(document, data.workerFileRange, references, token);
28
- }
29
- else if (sourceFile && !sourceFile?.virtualFile) {
30
- const document = context.documents.get(context.env.fileNameToUri(sourceFile.fileName), sourceFile.languageId, sourceFile.snapshot);
31
- references = await service[1].resolveReferencesCodeLensLocations(document, data.workerFileRange, references, token);
32
- }
33
- }
19
+ const references = await findReferences(data.sourceFileUri, item.range.start, { includeDeclaration: false }, token) ?? [];
34
20
  item.command = context.commands.showReferences.create(data.sourceFileUri, item.range.start, references);
35
21
  }
36
22
  return item;
@@ -18,7 +18,7 @@ export declare function createLanguageService(language: Language, servicePlugins
18
18
  findDocumentColors: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
19
19
  getColorPresentations: (uri: string, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
20
20
  doValidation: (uri: string, token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
21
- findReferences: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
21
+ findReferences: (uri: string, position: vscode.Position, referenceContext: vscode.ReferenceContext, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
22
22
  findFileReferences: (uri: string, token?: vscode.CancellationToken) => import("./types").NullableResult<vscode.Location[]>;
23
23
  findDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
24
24
  findTypeDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
package/lib/types.d.ts CHANGED
@@ -97,7 +97,7 @@ export interface ServicePluginInstance<P = any> {
97
97
  message: string;
98
98
  }>;
99
99
  provideRenameEdits?(document: TextDocument, position: vscode.Position, newName: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceEdit>;
100
- provideReferences?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
100
+ provideReferences?(document: TextDocument, position: vscode.Position, context: vscode.ReferenceContext, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
101
101
  provideSelectionRanges?(document: TextDocument, positions: vscode.Position[], token: vscode.CancellationToken): NullableResult<vscode.SelectionRange[]>;
102
102
  provideInlayHints?(document: TextDocument, range: vscode.Range, token: vscode.CancellationToken): NullableResult<vscode.InlayHint[]>;
103
103
  provideCallHierarchyItems?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableResult<vscode.CallHierarchyItem[]>;
@@ -122,7 +122,6 @@ export interface ServicePluginInstance<P = any> {
122
122
  resolveCompletionItem?(item: vscode.CompletionItem, token: vscode.CancellationToken): Result<vscode.CompletionItem>;
123
123
  resolveDocumentLink?(link: vscode.DocumentLink, token: vscode.CancellationToken): Result<vscode.DocumentLink>;
124
124
  resolveInlayHint?(inlayHint: vscode.InlayHint, token: vscode.CancellationToken): Result<vscode.InlayHint>;
125
- resolveReferencesCodeLensLocations?(document: TextDocument, range: vscode.Range, references: vscode.Location[], token: vscode.CancellationToken): Result<vscode.Location[]>;
126
125
  transformCompletionItem?(item: vscode.CompletionItem): vscode.CompletionItem | undefined;
127
126
  transformCodeAction?(item: vscode.CodeAction): vscode.CodeAction | undefined;
128
127
  dispose?(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-service",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.4",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,10 +12,10 @@
12
12
  "directory": "packages/language-service"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-core": "2.0.0-alpha.3",
15
+ "@volar/language-core": "2.0.0-alpha.4",
16
16
  "vscode-languageserver-protocol": "^3.17.5",
17
17
  "vscode-languageserver-textdocument": "^1.0.11",
18
18
  "vscode-uri": "^3.0.8"
19
19
  },
20
- "gitHead": "0bb685a72cff180bb9b3420aaf3136c8e899c908"
20
+ "gitHead": "4d07249613d0cc5de4197e90c741a64adf92b84b"
21
21
  }