@volar/language-service 2.0.0-alpha.2 → 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.
@@ -16,4 +16,4 @@ export declare const errorMarkups: Record<string, {
16
16
  error: vscode.Diagnostic;
17
17
  markup: vscode.MarkupContent;
18
18
  }[]>;
19
- export declare function register(context: ServiceContext): (uri: string, mode: 'all' | 'semantic' | 'syntactic', token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
19
+ export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
@@ -88,7 +88,7 @@ function register(context) {
88
88
  syntax_rules: new Map(),
89
89
  format_rules: new Map(),
90
90
  };
91
- return async (uri, mode, token = cancellation_1.NoneCancellationToken, response) => {
91
+ return async (uri, token = cancellation_1.NoneCancellationToken, response) => {
92
92
  const sourceFile = context.language.files.getSourceFile(context.env.uriToFileName(uri));
93
93
  if (!sourceFile)
94
94
  return [];
@@ -125,13 +125,9 @@ function register(context) {
125
125
  }
126
126
  }
127
127
  }
128
- if (mode === 'all' || mode === 'syntactic') {
129
- await worker('provideDiagnostics', cacheMaps.syntactic, lastResponse.syntactic);
130
- }
131
- if (mode === 'all' || mode === 'semantic') {
132
- await doResponse();
133
- await worker('provideSemanticDiagnostics', cacheMaps.semantic, lastResponse.semantic);
134
- }
128
+ await worker('provideDiagnostics', cacheMaps.syntactic, lastResponse.syntactic);
129
+ await doResponse();
130
+ await worker('provideSemanticDiagnostics', cacheMaps.semantic, lastResponse.semantic);
135
131
  return await collectErrors();
136
132
  async function doResponse() {
137
133
  if (errorsUpdated && !updateCacheRangeFailed) {
@@ -42,7 +42,7 @@ function register(context) {
42
42
  && file.mappings[0].lengths[0] === file.snapshot.getLength();
43
43
  if (onTypeParams && !isCodeBlock)
44
44
  continue;
45
- const docMap = createDocMap(file, context.env.fileNameToUri(sourceFile.fileName), sourceFile.languageId, tempSourceSnapshot);
45
+ const docMap = createDocMap(file, sourceFile.fileName, sourceFile.languageId, tempSourceSnapshot);
46
46
  if (!docMap)
47
47
  continue;
48
48
  let embeddedCodeResult;
@@ -194,16 +194,16 @@ function register(context) {
194
194
  }
195
195
  }
196
196
  };
197
- function createDocMap(file, sourceFileUri, sourceLanguageId, _sourceSnapshot) {
198
- const maps = (0, language_core_1.updateVirtualFileMaps)(file, (sourceFileName) => {
199
- if (!sourceFileName) {
200
- return [sourceFileUri, _sourceSnapshot];
197
+ function createDocMap(file, sourceFileName, sourceLanguageId, _sourceSnapshot) {
198
+ const maps = (0, language_core_1.updateVirtualFileMaps)(file, (sourceFileName2) => {
199
+ if (!sourceFileName2) {
200
+ return [sourceFileName, _sourceSnapshot];
201
201
  }
202
202
  });
203
- if (maps.has(sourceFileUri) && maps.get(sourceFileUri)[0] === _sourceSnapshot) {
204
- const map = maps.get(sourceFileUri);
203
+ if (maps.has(sourceFileName) && maps.get(sourceFileName)[0] === _sourceSnapshot) {
204
+ const map = maps.get(sourceFileName);
205
205
  const version = fakeVersion++;
206
- return new documents_1.SourceMapWithDocuments(vscode_languageserver_textdocument_1.TextDocument.create(sourceFileUri, sourceLanguageId ?? (0, language_core_1.resolveCommonLanguageId)(sourceFileUri), version, _sourceSnapshot.getText(0, _sourceSnapshot.getLength())), vscode_languageserver_textdocument_1.TextDocument.create(context.env.fileNameToUri(file.fileName), file.languageId, version, file.snapshot.getText(0, file.snapshot.getLength())), map[1]);
206
+ return new documents_1.SourceMapWithDocuments(vscode_languageserver_textdocument_1.TextDocument.create(context.env.fileNameToUri(sourceFileName), sourceLanguageId ?? (0, language_core_1.resolveCommonLanguageId)(sourceFileName), version, _sourceSnapshot.getText(0, _sourceSnapshot.getLength())), vscode_languageserver_textdocument_1.TextDocument.create(context.env.fileNameToUri(file.fileName), file.languageId, version, file.snapshot.getText(0, file.snapshot.getLength())), map[1]);
207
207
  }
208
208
  }
209
209
  }
@@ -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;
@@ -17,8 +17,8 @@ export declare function createLanguageService(language: Language, servicePlugins
17
17
  findDocumentSymbols: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
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
- doValidation: (uri: string, mode: "all" | "semantic" | "syntactic", 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>;
20
+ doValidation: (uri: string, token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
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.2",
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.2",
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": "88e80b9f00541ab9478b9c7b7af213813fc8cb20"
20
+ "gitHead": "4d07249613d0cc5de4197e90c741a64adf92b84b"
21
21
  }