@volar/language-service 2.4.0-alpha.9 → 2.4.1
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/provideAutoInsertSnippet.d.ts +2 -2
- package/lib/features/provideAutoInsertSnippet.js +1 -3
- package/lib/features/provideCallHierarchyItems.d.ts +5 -2
- package/lib/features/provideCallHierarchyItems.js +83 -8
- package/lib/features/provideCodeActions.d.ts +2 -2
- package/lib/features/provideCodeActions.js +15 -12
- package/lib/features/provideCodeLenses.d.ts +2 -2
- package/lib/features/provideCodeLenses.js +14 -11
- package/lib/features/provideColorPresentations.d.ts +2 -2
- package/lib/features/provideColorPresentations.js +1 -3
- package/lib/features/provideCompletionItems.d.ts +2 -2
- package/lib/features/provideCompletionItems.js +46 -32
- package/lib/features/provideDefinition.d.ts +2 -2
- package/lib/features/provideDefinition.js +1 -2
- package/lib/features/provideDiagnostics.d.ts +7 -8
- package/lib/features/provideDiagnostics.js +88 -85
- package/lib/features/provideDocumentColors.d.ts +2 -2
- package/lib/features/provideDocumentColors.js +1 -3
- package/lib/features/provideDocumentDropEdits.d.ts +2 -2
- package/lib/features/provideDocumentDropEdits.js +1 -3
- package/lib/features/provideDocumentFormattingEdits.d.ts +2 -2
- package/lib/features/provideDocumentFormattingEdits.js +1 -2
- package/lib/features/provideDocumentHighlights.d.ts +2 -2
- package/lib/features/provideDocumentHighlights.js +1 -2
- package/lib/features/provideDocumentLinks.d.ts +2 -2
- package/lib/features/provideDocumentLinks.js +13 -10
- package/lib/features/provideDocumentSemanticTokens.d.ts +2 -2
- package/lib/features/provideDocumentSemanticTokens.js +2 -4
- package/lib/features/provideDocumentSymbols.d.ts +2 -2
- package/lib/features/provideDocumentSymbols.js +1 -3
- package/lib/features/provideFileReferences.d.ts +2 -2
- package/lib/features/provideFileReferences.js +1 -2
- package/lib/features/provideFileRenameEdits.d.ts +2 -2
- package/lib/features/provideFileRenameEdits.js +1 -4
- package/lib/features/provideFoldingRanges.d.ts +2 -2
- package/lib/features/provideFoldingRanges.js +1 -3
- package/lib/features/provideHover.d.ts +2 -2
- package/lib/features/provideHover.js +1 -3
- package/lib/features/provideInlayHints.d.ts +2 -2
- package/lib/features/provideInlayHints.js +13 -10
- package/lib/features/provideInlineValue.d.ts +4 -0
- package/lib/features/provideInlineValue.js +30 -0
- package/lib/features/provideLinkedEditingRanges.d.ts +2 -2
- package/lib/features/provideLinkedEditingRanges.js +1 -3
- package/lib/features/provideMoniker.d.ts +4 -0
- package/lib/features/provideMoniker.js +17 -0
- package/lib/features/provideReferences.d.ts +2 -2
- package/lib/features/provideReferences.js +1 -2
- package/lib/features/provideRenameEdits.d.ts +2 -2
- package/lib/features/provideRenameEdits.js +1 -2
- package/lib/features/provideRenameRange.d.ts +2 -2
- package/lib/features/provideRenameRange.js +1 -3
- package/lib/features/provideSelectionRanges.d.ts +2 -2
- package/lib/features/provideSelectionRanges.js +1 -3
- package/lib/features/provideSignatureHelp.d.ts +2 -2
- package/lib/features/provideSignatureHelp.js +1 -3
- package/lib/features/provideWorkspaceDiagnostics.js +2 -3
- package/lib/features/provideWorkspaceSymbols.js +11 -6
- package/lib/features/resolveCodeAction.js +2 -0
- package/lib/features/resolveCodeLens.js +3 -1
- package/lib/features/resolveCompletionItem.js +2 -0
- package/lib/features/resolveDocumentLink.js +2 -0
- package/lib/features/resolveInlayHint.js +2 -0
- package/lib/features/resolveWorkspaceSymbol.d.ts +1 -1
- package/lib/features/resolveWorkspaceSymbol.js +8 -6
- package/lib/languageService.d.ts +82 -70
- package/lib/languageService.js +17 -14
- package/lib/types.d.ts +14 -10
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
|
-
import type { LanguageServiceContext
|
|
4
|
-
export declare function register(context: LanguageServiceContext): (
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, selection: vscode.Position, change: {
|
|
5
5
|
rangeOffset: number;
|
|
6
6
|
rangeLength: number;
|
|
7
7
|
text: string;
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
6
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
7
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
7
|
function register(context) {
|
|
9
|
-
return (
|
|
10
|
-
const uri = _uri instanceof vscode_uri_1.URI ? _uri : vscode_uri_1.URI.from(_uri);
|
|
8
|
+
return (uri, selection, change, token = cancellation_1.NoneCancellationToken) => {
|
|
11
9
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => ({ selection, change }), function* (docs) {
|
|
12
10
|
for (const mappedPosition of (0, featureWorkers_1.getGeneratedPositions)(docs, selection, language_core_1.isAutoInsertEnabled)) {
|
|
13
11
|
for (const mapped of docs[2].toGeneratedLocation(change.rangeOffset)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
|
-
import type { LanguageServiceContext
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export interface PluginCallHierarchyData {
|
|
5
5
|
uri: string;
|
|
6
6
|
original: Pick<vscode.CallHierarchyItem, 'data'>;
|
|
@@ -8,7 +8,10 @@ export interface PluginCallHierarchyData {
|
|
|
8
8
|
embeddedDocumentUri: string | undefined;
|
|
9
9
|
}
|
|
10
10
|
export declare function register(context: LanguageServiceContext): {
|
|
11
|
-
getCallHierarchyItems(
|
|
11
|
+
getCallHierarchyItems(uri: URI, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
12
|
+
getTypeHierarchyItems(uri: URI, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.TypeHierarchyItem[] | undefined>;
|
|
12
13
|
getCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
13
14
|
getCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
15
|
+
getTypeHierarchySupertypes(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.TypeHierarchyItem[] | undefined>;
|
|
16
|
+
getTypeHierarchySubtypes(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.TypeHierarchyItem[] | undefined>;
|
|
14
17
|
};
|
|
@@ -8,8 +8,7 @@ const dedupe = require("../utils/dedupe");
|
|
|
8
8
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
9
9
|
function register(context) {
|
|
10
10
|
return {
|
|
11
|
-
getCallHierarchyItems(
|
|
12
|
-
const uri = _uri instanceof vscode_uri_1.URI ? _uri : vscode_uri_1.URI.from(_uri);
|
|
11
|
+
getCallHierarchyItems(uri, position, token = cancellation_1.NoneCancellationToken) {
|
|
13
12
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isCallHierarchyEnabled), async (plugin, document, position, map) => {
|
|
14
13
|
if (token.isCancellationRequested) {
|
|
15
14
|
return;
|
|
@@ -31,7 +30,33 @@ function register(context) {
|
|
|
31
30
|
return data;
|
|
32
31
|
}
|
|
33
32
|
return data
|
|
34
|
-
.map(item =>
|
|
33
|
+
.map(item => transformHierarchyItem(item, [])?.[0])
|
|
34
|
+
.filter(item => !!item);
|
|
35
|
+
}, arr => dedupe.withLocations(arr.flat()));
|
|
36
|
+
},
|
|
37
|
+
getTypeHierarchyItems(uri, position, token = cancellation_1.NoneCancellationToken) {
|
|
38
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isTypeHierarchyEnabled), async (plugin, document, position, map) => {
|
|
39
|
+
if (token.isCancellationRequested) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const items = await plugin[1].provideTypeHierarchyItems?.(document, position, token);
|
|
43
|
+
items?.forEach(item => {
|
|
44
|
+
item.data = {
|
|
45
|
+
uri: uri.toString(),
|
|
46
|
+
original: {
|
|
47
|
+
data: item.data,
|
|
48
|
+
},
|
|
49
|
+
pluginIndex: context.plugins.indexOf(plugin),
|
|
50
|
+
embeddedDocumentUri: map?.[1].uri,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return items;
|
|
54
|
+
}, (data, map) => {
|
|
55
|
+
if (!map) {
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
return data
|
|
59
|
+
.map(item => transformHierarchyItem(item, [])?.[0])
|
|
35
60
|
.filter(item => !!item);
|
|
36
61
|
}, arr => dedupe.withLocations(arr.flat()));
|
|
37
62
|
},
|
|
@@ -49,7 +74,7 @@ function register(context) {
|
|
|
49
74
|
if (isEmbeddedContent) {
|
|
50
75
|
const _calls = await plugin[1].provideCallHierarchyIncomingCalls(item, token);
|
|
51
76
|
for (const _call of _calls) {
|
|
52
|
-
const calls =
|
|
77
|
+
const calls = transformHierarchyItem(_call.from, _call.fromRanges);
|
|
53
78
|
if (!calls) {
|
|
54
79
|
continue;
|
|
55
80
|
}
|
|
@@ -63,7 +88,7 @@ function register(context) {
|
|
|
63
88
|
else {
|
|
64
89
|
const _calls = await plugin[1].provideCallHierarchyIncomingCalls(item, token);
|
|
65
90
|
for (const _call of _calls) {
|
|
66
|
-
const calls =
|
|
91
|
+
const calls = transformHierarchyItem(_call.from, _call.fromRanges);
|
|
67
92
|
if (!calls) {
|
|
68
93
|
continue;
|
|
69
94
|
}
|
|
@@ -90,7 +115,7 @@ function register(context) {
|
|
|
90
115
|
if (isEmbeddedContent) {
|
|
91
116
|
const _calls = await plugin[1].provideCallHierarchyOutgoingCalls(item, token);
|
|
92
117
|
for (const call of _calls) {
|
|
93
|
-
const calls =
|
|
118
|
+
const calls = transformHierarchyItem(call.to, call.fromRanges);
|
|
94
119
|
if (!calls) {
|
|
95
120
|
continue;
|
|
96
121
|
}
|
|
@@ -104,7 +129,7 @@ function register(context) {
|
|
|
104
129
|
else {
|
|
105
130
|
const _calls = await plugin[1].provideCallHierarchyOutgoingCalls(item, token);
|
|
106
131
|
for (const call of _calls) {
|
|
107
|
-
const calls =
|
|
132
|
+
const calls = transformHierarchyItem(call.to, call.fromRanges);
|
|
108
133
|
if (!calls) {
|
|
109
134
|
continue;
|
|
110
135
|
}
|
|
@@ -117,8 +142,58 @@ function register(context) {
|
|
|
117
142
|
}
|
|
118
143
|
return dedupe.withCallHierarchyOutgoingCalls(items);
|
|
119
144
|
},
|
|
145
|
+
async getTypeHierarchySupertypes(item, token) {
|
|
146
|
+
const data = item.data;
|
|
147
|
+
if (data) {
|
|
148
|
+
const plugin = context.plugins[data.pluginIndex];
|
|
149
|
+
if (!plugin[1].provideTypeHierarchySupertypes) {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
Object.assign(item, data.original);
|
|
153
|
+
if (data.embeddedDocumentUri) {
|
|
154
|
+
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
|
|
155
|
+
if (isEmbeddedContent) {
|
|
156
|
+
const items = await plugin[1].provideTypeHierarchySupertypes(item, token);
|
|
157
|
+
return items
|
|
158
|
+
.map(item => transformHierarchyItem(item, [])?.[0])
|
|
159
|
+
.filter(item => !!item);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const items = await plugin[1].provideTypeHierarchySupertypes(item, token);
|
|
164
|
+
return items
|
|
165
|
+
.map(item => transformHierarchyItem(item, [])?.[0])
|
|
166
|
+
.filter(item => !!item);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
async getTypeHierarchySubtypes(item, token) {
|
|
171
|
+
const data = item.data;
|
|
172
|
+
if (data) {
|
|
173
|
+
const plugin = context.plugins[data.pluginIndex];
|
|
174
|
+
if (!plugin[1].provideTypeHierarchySubtypes) {
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
Object.assign(item, data.original);
|
|
178
|
+
if (data.embeddedDocumentUri) {
|
|
179
|
+
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
|
|
180
|
+
if (isEmbeddedContent) {
|
|
181
|
+
const items = await plugin[1].provideTypeHierarchySubtypes(item, token);
|
|
182
|
+
return items
|
|
183
|
+
.map(item => transformHierarchyItem(item, [])?.[0])
|
|
184
|
+
.filter(item => !!item);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
const items = await plugin[1].provideTypeHierarchySubtypes(item, token);
|
|
189
|
+
return items
|
|
190
|
+
.map(item => transformHierarchyItem(item, [])?.[0])
|
|
191
|
+
.filter(item => !!item);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
120
195
|
};
|
|
121
|
-
function
|
|
196
|
+
function transformHierarchyItem(tsItem, tsRanges) {
|
|
122
197
|
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(tsItem.uri));
|
|
123
198
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
124
199
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
|
-
import type { LanguageServiceContext
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export interface ServiceCodeActionData {
|
|
5
5
|
uri: string;
|
|
6
6
|
version: number;
|
|
7
7
|
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
|
8
8
|
pluginIndex: number;
|
|
9
9
|
}
|
|
10
|
-
export declare function register(context: LanguageServiceContext): (
|
|
10
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
6
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
7
6
|
const common_1 = require("../utils/common");
|
|
8
7
|
const dedupe = require("../utils/dedupe");
|
|
9
8
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
10
9
|
const transform_1 = require("../utils/transform");
|
|
11
10
|
function register(context) {
|
|
12
|
-
return async (
|
|
13
|
-
const uri = _uri instanceof vscode_uri_1.URI ? _uri : vscode_uri_1.URI.from(_uri);
|
|
11
|
+
return async (uri, range, codeActionContext, token = cancellation_1.NoneCancellationToken) => {
|
|
14
12
|
const sourceScript = context.language.scripts.get(uri);
|
|
15
13
|
if (!sourceScript) {
|
|
16
14
|
return;
|
|
@@ -54,15 +52,20 @@ function register(context) {
|
|
|
54
52
|
diagnostics,
|
|
55
53
|
}, token);
|
|
56
54
|
codeActions?.forEach(codeAction => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
if (plugin[1].resolveCodeAction) {
|
|
56
|
+
codeAction.data = {
|
|
57
|
+
uri: uri.toString(),
|
|
58
|
+
version: document.version,
|
|
59
|
+
original: {
|
|
60
|
+
data: codeAction.data,
|
|
61
|
+
edit: codeAction.edit,
|
|
62
|
+
},
|
|
63
|
+
pluginIndex: context.plugins.indexOf(plugin),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
delete codeAction.data;
|
|
68
|
+
}
|
|
66
69
|
});
|
|
67
70
|
if (codeActions && plugin[1].transformCodeAction) {
|
|
68
71
|
for (let i = 0; i < codeActions.length; i++) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
|
-
import type { LanguageServiceContext
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export interface ServiceCodeLensData {
|
|
5
5
|
kind: 'normal';
|
|
6
6
|
uri: string;
|
|
@@ -14,4 +14,4 @@ export interface ServiceReferencesCodeLensData {
|
|
|
14
14
|
workerFileRange: vscode.Range;
|
|
15
15
|
pluginIndex: number;
|
|
16
16
|
}
|
|
17
|
-
export declare function register(context: LanguageServiceContext): (
|
|
17
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
6
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
7
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
7
|
function register(context) {
|
|
9
|
-
return async (
|
|
10
|
-
const uri = _uri instanceof vscode_uri_1.URI ? _uri : vscode_uri_1.URI.from(_uri);
|
|
8
|
+
return async (uri, token = cancellation_1.NoneCancellationToken) => {
|
|
11
9
|
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, docs => docs[2].mappings.some(mapping => (0, language_core_1.isCodeLensEnabled)(mapping.data)), async (plugin, document) => {
|
|
12
10
|
if (token.isCancellationRequested) {
|
|
13
11
|
return;
|
|
@@ -15,14 +13,19 @@ function register(context) {
|
|
|
15
13
|
let codeLens = await plugin[1].provideCodeLenses?.(document, token);
|
|
16
14
|
const pluginIndex = context.plugins.indexOf(plugin);
|
|
17
15
|
codeLens?.forEach(codeLens => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
if (plugin[1].resolveCodeLens) {
|
|
17
|
+
codeLens.data = {
|
|
18
|
+
kind: 'normal',
|
|
19
|
+
uri: uri.toString(),
|
|
20
|
+
original: {
|
|
21
|
+
data: codeLens.data,
|
|
22
|
+
},
|
|
23
|
+
pluginIndex,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
delete codeLens.data;
|
|
28
|
+
}
|
|
26
29
|
});
|
|
27
30
|
const ranges = await plugin[1].provideReferencesCodeLensRanges?.(document, token);
|
|
28
31
|
const referencesCodeLens = ranges?.map(range => ({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
|
-
import type { LanguageServiceContext
|
|
4
|
-
export declare function register(context: LanguageServiceContext): (
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
6
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
7
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
7
|
function register(context) {
|
|
9
|
-
return (
|
|
10
|
-
const uri = _uri instanceof vscode_uri_1.URI ? _uri : vscode_uri_1.URI.from(_uri);
|
|
8
|
+
return (uri, color, range, token = cancellation_1.NoneCancellationToken) => {
|
|
11
9
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => range, function* (docs) {
|
|
12
10
|
for (const mappedRange of (0, featureWorkers_1.getGeneratedRanges)(docs, range, language_core_1.isColorEnabled)) {
|
|
13
11
|
yield mappedRange;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
|
-
import type { LanguageServiceContext
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export interface ServiceCompletionData {
|
|
5
5
|
uri: string;
|
|
6
6
|
original: Pick<vscode.CompletionItem, 'additionalTextEdits' | 'textEdit' | 'data'>;
|
|
7
7
|
pluginIndex: number;
|
|
8
8
|
embeddedDocumentUri: string | undefined;
|
|
9
9
|
}
|
|
10
|
-
export declare function register(context: LanguageServiceContext): (
|
|
10
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;
|
|
@@ -8,8 +8,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
8
8
|
const transform_1 = require("../utils/transform");
|
|
9
9
|
function register(context) {
|
|
10
10
|
let lastResult;
|
|
11
|
-
return async (
|
|
12
|
-
const uri = _uri instanceof vscode_uri_1.URI ? _uri : vscode_uri_1.URI.from(_uri);
|
|
11
|
+
return async (uri, position, completionContext = { triggerKind: 1, }, token = cancellation_1.NoneCancellationToken) => {
|
|
13
12
|
let langaugeIdAndSnapshot;
|
|
14
13
|
let sourceScript;
|
|
15
14
|
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
@@ -53,16 +52,21 @@ function register(context) {
|
|
|
53
52
|
continue;
|
|
54
53
|
}
|
|
55
54
|
for (const item of cacheData.list.items) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
if (cacheData.plugin.resolveCompletionItem) {
|
|
56
|
+
item.data = {
|
|
57
|
+
uri: uri.toString(),
|
|
58
|
+
original: {
|
|
59
|
+
additionalTextEdits: item.additionalTextEdits,
|
|
60
|
+
textEdit: item.textEdit,
|
|
61
|
+
data: item.data,
|
|
62
|
+
},
|
|
63
|
+
pluginIndex: pluginIndex,
|
|
64
|
+
embeddedDocumentUri: embeddedDocument.uri,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
delete item.data;
|
|
69
|
+
}
|
|
66
70
|
}
|
|
67
71
|
cacheData.list = (0, transform_1.transformCompletionList)(cacheData.list, range => (0, featureWorkers_1.getSourceRange)(docs, range), embeddedDocument, context);
|
|
68
72
|
}
|
|
@@ -78,16 +82,21 @@ function register(context) {
|
|
|
78
82
|
continue;
|
|
79
83
|
}
|
|
80
84
|
for (const item of cacheData.list.items) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
if (cacheData.plugin.resolveCompletionItem) {
|
|
86
|
+
item.data = {
|
|
87
|
+
uri: uri.toString(),
|
|
88
|
+
original: {
|
|
89
|
+
additionalTextEdits: item.additionalTextEdits,
|
|
90
|
+
textEdit: item.textEdit,
|
|
91
|
+
data: item.data,
|
|
92
|
+
},
|
|
93
|
+
pluginIndex: pluginIndex,
|
|
94
|
+
embeddedDocumentUri: undefined,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
delete item.data;
|
|
99
|
+
}
|
|
91
100
|
}
|
|
92
101
|
}
|
|
93
102
|
}
|
|
@@ -137,16 +146,21 @@ function register(context) {
|
|
|
137
146
|
}
|
|
138
147
|
const pluginIndex = context.plugins.indexOf(plugin);
|
|
139
148
|
for (const item of completionList.items) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
if (plugin[1].resolveCompletionItem) {
|
|
150
|
+
item.data = {
|
|
151
|
+
uri: uri.toString(),
|
|
152
|
+
original: {
|
|
153
|
+
additionalTextEdits: item.additionalTextEdits,
|
|
154
|
+
textEdit: item.textEdit,
|
|
155
|
+
data: item.data,
|
|
156
|
+
},
|
|
157
|
+
pluginIndex,
|
|
158
|
+
embeddedDocumentUri: docs ? document.uri : undefined,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
delete item.data;
|
|
163
|
+
}
|
|
150
164
|
}
|
|
151
165
|
if (docs) {
|
|
152
166
|
completionList = (0, transform_1.transformCompletionList)(completionList, range => (0, featureWorkers_1.getSourceRange)(docs, range, language_core_1.isCompletionEnabled), document, context);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CodeInformation } from '@volar/language-core';
|
|
2
2
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
3
3
|
import { URI } from 'vscode-uri';
|
|
4
|
-
import type { LanguageServiceContext
|
|
5
|
-
export declare function register(context: LanguageServiceContext, apiName: 'provideDefinition' | 'provideTypeDefinition' | 'provideImplementation', isValidPosition: (data: CodeInformation) => boolean): (
|
|
4
|
+
import type { LanguageServiceContext } from '../types';
|
|
5
|
+
export declare function register(context: LanguageServiceContext, apiName: 'provideDeclaration' | 'provideDefinition' | 'provideTypeDefinition' | 'provideImplementation', isValidPosition: (data: CodeInformation) => boolean): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -6,8 +6,7 @@ const cancellation_1 = require("../utils/cancellation");
|
|
|
6
6
|
const dedupe = require("../utils/dedupe");
|
|
7
7
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
8
|
function register(context, apiName, isValidPosition) {
|
|
9
|
-
return (
|
|
10
|
-
const uri = _uri instanceof vscode_uri_1.URI ? _uri : vscode_uri_1.URI.from(_uri);
|
|
9
|
+
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
|
11
10
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, isValidPosition), async (plugin, document, position) => {
|
|
12
11
|
if (token.isCancellationRequested) {
|
|
13
12
|
return;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { type CodeInformation } from '@volar/language-core';
|
|
2
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
3
2
|
import { URI } from 'vscode-uri';
|
|
4
|
-
import type { LanguageServiceContext
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
5
4
|
import { DocumentsAndMap } from '../utils/featureWorkers';
|
|
6
|
-
export declare function updateRange(range: vscode.Range, change: {
|
|
7
|
-
range: vscode.Range;
|
|
8
|
-
newEnd: vscode.Position;
|
|
9
|
-
}): vscode.Range | undefined;
|
|
10
5
|
export interface ServiceDiagnosticData {
|
|
11
6
|
uri: string;
|
|
12
7
|
version: number;
|
|
@@ -19,5 +14,9 @@ export declare const errorMarkups: Map<URI, {
|
|
|
19
14
|
error: vscode.Diagnostic;
|
|
20
15
|
markup: vscode.MarkupContent;
|
|
21
16
|
}[]>;
|
|
22
|
-
export declare function register(context: LanguageServiceContext): (
|
|
23
|
-
export declare function transformDiagnostic(context: LanguageServiceContext, error: vscode.Diagnostic, docs: DocumentsAndMap | undefined
|
|
17
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, response?: (result: vscode.Diagnostic[]) => void, token?: vscode.CancellationToken) => Promise<vscode.Diagnostic[]>;
|
|
18
|
+
export declare function transformDiagnostic(context: LanguageServiceContext, error: vscode.Diagnostic, docs: DocumentsAndMap | undefined): vscode.Diagnostic | undefined;
|
|
19
|
+
export declare function updateRange(range: vscode.Range, change: {
|
|
20
|
+
range: vscode.Range;
|
|
21
|
+
newEnd: vscode.Position;
|
|
22
|
+
}): vscode.Range | undefined;
|