@volar/language-service 2.0.0-alpha.3 → 2.0.0-alpha.5
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.
- package/lib/features/provideDocumentFormattingEdits.js +3 -3
- package/lib/features/provideReferences.d.ts +1 -1
- package/lib/features/provideReferences.js +2 -2
- package/lib/features/resolveCodeLens.js +1 -15
- package/lib/languageService.d.ts +1 -1
- package/lib/types.d.ts +1 -2
- package/package.json +3 -3
|
@@ -24,7 +24,7 @@ function register(context) {
|
|
|
24
24
|
}
|
|
25
25
|
const initialIndentLanguageId = await context.env.getConfiguration?.('volar.format.initialIndent') ?? { html: true };
|
|
26
26
|
let tempSourceSnapshot = sourceFile.snapshot;
|
|
27
|
-
const tempVirtualFile = sourceFile.virtualFile[1].createVirtualFile(sourceFile.fileName, sourceFile.languageId, sourceFile.snapshot);
|
|
27
|
+
const tempVirtualFile = sourceFile.virtualFile[1].createVirtualFile(sourceFile.fileName, sourceFile.languageId, sourceFile.snapshot, context.language.files);
|
|
28
28
|
const originalDocument = document;
|
|
29
29
|
let level = 0;
|
|
30
30
|
while (true) {
|
|
@@ -80,7 +80,7 @@ function register(context) {
|
|
|
80
80
|
const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, edits);
|
|
81
81
|
document = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version + 1, newText);
|
|
82
82
|
tempSourceSnapshot = (0, common_1.stringToSnapshot)(newText);
|
|
83
|
-
sourceFile.virtualFile[1].updateVirtualFile(tempVirtualFile, tempSourceSnapshot);
|
|
83
|
+
sourceFile.virtualFile[1].updateVirtualFile(tempVirtualFile, tempSourceSnapshot, context.language.files);
|
|
84
84
|
}
|
|
85
85
|
if (level > 1) {
|
|
86
86
|
const baseIndent = options.insertSpaces ? ' '.repeat(options.tabSize) : '\t';
|
|
@@ -138,7 +138,7 @@ function register(context) {
|
|
|
138
138
|
const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, indentEdits);
|
|
139
139
|
document = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version + 1, newText);
|
|
140
140
|
tempSourceSnapshot = (0, common_1.stringToSnapshot)(newText);
|
|
141
|
-
sourceFile.virtualFile[1].updateVirtualFile(tempVirtualFile, tempSourceSnapshot);
|
|
141
|
+
sourceFile.virtualFile[1].updateVirtualFile(tempVirtualFile, tempSourceSnapshot, context.language.files);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -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
|
-
|
|
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;
|
package/lib/languageService.d.ts
CHANGED
|
@@ -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
|
+
"version": "2.0.0-alpha.5",
|
|
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.
|
|
15
|
+
"@volar/language-core": "2.0.0-alpha.5",
|
|
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": "
|
|
20
|
+
"gitHead": "80f4f8791c304fbcf4a0a8425eae8ea0b5ab739c"
|
|
21
21
|
}
|