@volar/language-service 2.2.5 → 2.3.0-alpha.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/index.d.ts +1 -2
- package/index.js +2 -41
- package/lib/documents.d.ts +20 -18
- package/lib/documents.js +5 -3
- package/lib/features/provideAutoInsertSnippet.d.ts +8 -0
- package/lib/features/{provideAutoInsertionEdit.js → provideAutoInsertSnippet.js} +8 -17
- package/lib/features/provideCallHierarchyItems.d.ts +5 -4
- package/lib/features/provideCallHierarchyItems.js +18 -17
- package/lib/features/provideCodeActions.d.ts +4 -3
- package/lib/features/provideCodeActions.js +9 -9
- package/lib/features/provideCodeLenses.d.ts +4 -3
- package/lib/features/provideCodeLenses.js +9 -9
- package/lib/features/provideColorPresentations.d.ts +3 -2
- package/lib/features/provideColorPresentations.js +5 -5
- package/lib/features/provideCompletionItems.d.ts +4 -3
- package/lib/features/provideCompletionItems.js +26 -25
- package/lib/features/provideDefinition.d.ts +3 -2
- package/lib/features/provideDefinition.js +6 -5
- package/lib/features/provideDiagnostics.d.ts +4 -3
- package/lib/features/provideDiagnostics.js +13 -11
- package/lib/features/provideDocumentColors.d.ts +3 -2
- package/lib/features/provideDocumentColors.js +2 -2
- package/lib/features/provideDocumentDropEdits.d.ts +3 -2
- package/lib/features/provideDocumentDropEdits.js +3 -3
- package/lib/features/provideDocumentFormattingEdits.d.ts +3 -2
- package/lib/features/provideDocumentFormattingEdits.js +17 -15
- package/lib/features/provideDocumentHighlights.d.ts +3 -2
- package/lib/features/provideDocumentHighlights.js +9 -8
- package/lib/features/provideDocumentLinks.d.ts +4 -3
- package/lib/features/provideDocumentLinks.js +6 -6
- package/lib/features/provideDocumentSemanticTokens.d.ts +3 -2
- package/lib/features/provideDocumentSemanticTokens.js +3 -3
- package/lib/features/provideDocumentSymbols.d.ts +3 -2
- package/lib/features/provideDocumentSymbols.js +5 -5
- package/lib/features/provideFileReferences.d.ts +3 -2
- package/lib/features/provideFileReferences.js +8 -7
- package/lib/features/provideFileRenameEdits.d.ts +3 -2
- package/lib/features/provideFileRenameEdits.js +6 -6
- package/lib/features/provideFoldingRanges.d.ts +3 -2
- package/lib/features/provideFoldingRanges.js +4 -4
- package/lib/features/provideHover.d.ts +3 -2
- package/lib/features/provideHover.js +7 -7
- package/lib/features/provideInlayHints.d.ts +4 -3
- package/lib/features/provideInlayHints.js +6 -6
- package/lib/features/provideLinkedEditingRanges.d.ts +3 -2
- package/lib/features/provideLinkedEditingRanges.js +5 -5
- package/lib/features/provideReferences.d.ts +3 -2
- package/lib/features/provideReferences.js +9 -8
- package/lib/features/provideRenameEdits.d.ts +3 -2
- package/lib/features/provideRenameEdits.js +5 -4
- package/lib/features/provideRenameRange.d.ts +3 -2
- package/lib/features/provideRenameRange.js +4 -4
- package/lib/features/provideSelectionRanges.d.ts +3 -2
- package/lib/features/provideSelectionRanges.js +3 -3
- package/lib/features/provideSignatureHelp.d.ts +3 -2
- package/lib/features/provideSignatureHelp.js +6 -6
- package/lib/features/provideWorkspaceSymbols.d.ts +2 -2
- package/lib/features/provideWorkspaceSymbols.js +6 -5
- package/lib/features/resolveCodeAction.d.ts +2 -2
- package/lib/features/resolveCodeAction.js +4 -4
- package/lib/features/resolveCodeLens.d.ts +2 -2
- package/lib/features/resolveCodeLens.js +6 -5
- package/lib/features/resolveCompletionItem.d.ts +2 -2
- package/lib/features/resolveCompletionItem.js +7 -6
- package/lib/features/resolveDocumentLink.d.ts +2 -2
- package/lib/features/resolveDocumentLink.js +4 -4
- package/lib/features/resolveInlayHint.d.ts +2 -2
- package/lib/features/resolveInlayHint.js +3 -3
- package/lib/languageService.d.ts +37 -32
- package/lib/languageService.js +42 -29
- package/lib/types.d.ts +77 -36
- package/lib/utils/dedupe.d.ts +1 -1
- package/lib/utils/featureWorkers.d.ts +7 -6
- package/lib/utils/featureWorkers.js +25 -18
- package/lib/utils/transform.d.ts +7 -6
- package/lib/utils/transform.js +18 -15
- package/lib/utils/uriMap.d.ts +3 -0
- package/lib/utils/uriMap.js +69 -0
- package/package.json +3 -3
- package/lib/features/provideAutoInsertionEdit.d.ts +0 -7
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
5
6
|
const cancellation_1 = require("../utils/cancellation");
|
|
6
|
-
const transform_1 = require("../utils/transform");
|
|
7
7
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
|
+
const transform_1 = require("../utils/transform");
|
|
8
9
|
function register(context) {
|
|
9
10
|
let lastResult;
|
|
10
11
|
return async (uri, position, completionContext = { triggerKind: 1, }, token = cancellation_1.NoneCancellationToken) => {
|
|
@@ -16,12 +17,12 @@ function register(context) {
|
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
if (completionContext?.triggerKind === 3
|
|
19
|
-
&& lastResult?.uri === uri) {
|
|
20
|
+
&& lastResult?.uri.toString() === uri.toString()) {
|
|
20
21
|
for (const cacheData of lastResult.results) {
|
|
21
22
|
if (!cacheData.list?.isIncomplete) {
|
|
22
23
|
continue;
|
|
23
24
|
}
|
|
24
|
-
const
|
|
25
|
+
const pluginIndex = context.plugins.findIndex(plugin => plugin[1] === cacheData.plugin);
|
|
25
26
|
if (cacheData.embeddedDocumentUri) {
|
|
26
27
|
const decoded = context.decodeEmbeddedDocumentUri(cacheData.embeddedDocumentUri);
|
|
27
28
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
@@ -31,22 +32,22 @@ function register(context) {
|
|
|
31
32
|
}
|
|
32
33
|
for (const map of context.documents.getMaps(virtualCode)) {
|
|
33
34
|
for (const mapped of map.getGeneratedPositions(position, data => (0, language_core_1.isCompletionEnabled)(data))) {
|
|
34
|
-
if (!cacheData.
|
|
35
|
+
if (!cacheData.plugin.provideCompletionItems) {
|
|
35
36
|
continue;
|
|
36
37
|
}
|
|
37
|
-
cacheData.list = await cacheData.
|
|
38
|
+
cacheData.list = await cacheData.plugin.provideCompletionItems(map.embeddedDocument, mapped, completionContext, token);
|
|
38
39
|
if (!cacheData.list) {
|
|
39
40
|
continue;
|
|
40
41
|
}
|
|
41
42
|
for (const item of cacheData.list.items) {
|
|
42
43
|
item.data = {
|
|
43
|
-
uri,
|
|
44
|
+
uri: uri.toString(),
|
|
44
45
|
original: {
|
|
45
46
|
additionalTextEdits: item.additionalTextEdits,
|
|
46
47
|
textEdit: item.textEdit,
|
|
47
48
|
data: item.data,
|
|
48
49
|
},
|
|
49
|
-
|
|
50
|
+
pluginIndex: pluginIndex,
|
|
50
51
|
embeddedDocumentUri: map.embeddedDocument.uri,
|
|
51
52
|
};
|
|
52
53
|
}
|
|
@@ -55,23 +56,23 @@ function register(context) {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
58
|
-
if (!cacheData.
|
|
59
|
+
if (!cacheData.plugin.provideCompletionItems) {
|
|
59
60
|
continue;
|
|
60
61
|
}
|
|
61
62
|
const document = context.documents.get(uri, sourceScript.languageId, sourceScript.snapshot);
|
|
62
|
-
cacheData.list = await cacheData.
|
|
63
|
+
cacheData.list = await cacheData.plugin.provideCompletionItems(document, position, completionContext, token);
|
|
63
64
|
if (!cacheData.list) {
|
|
64
65
|
continue;
|
|
65
66
|
}
|
|
66
67
|
for (const item of cacheData.list.items) {
|
|
67
68
|
item.data = {
|
|
68
|
-
uri,
|
|
69
|
+
uri: uri.toString(),
|
|
69
70
|
original: {
|
|
70
71
|
additionalTextEdits: item.additionalTextEdits,
|
|
71
72
|
textEdit: item.textEdit,
|
|
72
73
|
data: item.data,
|
|
73
74
|
},
|
|
74
|
-
|
|
75
|
+
pluginIndex: pluginIndex,
|
|
75
76
|
embeddedDocumentUri: undefined,
|
|
76
77
|
};
|
|
77
78
|
}
|
|
@@ -86,32 +87,32 @@ function register(context) {
|
|
|
86
87
|
// monky fix https://github.com/johnsoncodehk/volar/issues/1358
|
|
87
88
|
let isFirstMapping = true;
|
|
88
89
|
let mainCompletionUri;
|
|
89
|
-
const
|
|
90
|
-
.filter(
|
|
90
|
+
const sortedPlugins = [...context.plugins]
|
|
91
|
+
.filter(plugin => !context.disabledServicePlugins.has(plugin[1]))
|
|
91
92
|
.sort((a, b) => sortServices(a[1], b[1]));
|
|
92
93
|
const worker = async (document, position, map, codeInfo) => {
|
|
93
|
-
for (const
|
|
94
|
+
for (const plugin of sortedPlugins) {
|
|
94
95
|
if (token.isCancellationRequested) {
|
|
95
96
|
break;
|
|
96
97
|
}
|
|
97
|
-
if (!
|
|
98
|
+
if (!plugin[1].provideCompletionItems) {
|
|
98
99
|
continue;
|
|
99
100
|
}
|
|
100
|
-
if (
|
|
101
|
+
if (plugin[1].isAdditionalCompletion && !isFirstMapping) {
|
|
101
102
|
continue;
|
|
102
103
|
}
|
|
103
|
-
if (completionContext?.triggerCharacter && !
|
|
104
|
+
if (completionContext?.triggerCharacter && !plugin[0].capabilities.completionProvider?.triggerCharacters?.includes(completionContext.triggerCharacter)) {
|
|
104
105
|
continue;
|
|
105
106
|
}
|
|
106
|
-
const isAdditional = (codeInfo && typeof codeInfo.completion === 'object' && codeInfo.completion.isAdditional) ||
|
|
107
|
+
const isAdditional = (codeInfo && typeof codeInfo.completion === 'object' && codeInfo.completion.isAdditional) || plugin[1].isAdditionalCompletion;
|
|
107
108
|
if (mainCompletionUri && (!isAdditional || mainCompletionUri !== document.uri)) {
|
|
108
109
|
continue;
|
|
109
110
|
}
|
|
110
111
|
// avoid duplicate items with .vue and .vue.html
|
|
111
|
-
if (
|
|
112
|
+
if (plugin[1].isAdditionalCompletion && lastResult?.results.some(data => data.plugin === plugin[1])) {
|
|
112
113
|
continue;
|
|
113
114
|
}
|
|
114
|
-
let completionList = await
|
|
115
|
+
let completionList = await plugin[1].provideCompletionItems(document, position, completionContext, token);
|
|
115
116
|
if (!completionList || !completionList.items.length) {
|
|
116
117
|
continue;
|
|
117
118
|
}
|
|
@@ -121,16 +122,16 @@ function register(context) {
|
|
|
121
122
|
if (!isAdditional) {
|
|
122
123
|
mainCompletionUri = document.uri;
|
|
123
124
|
}
|
|
124
|
-
const
|
|
125
|
+
const pluginIndex = context.plugins.indexOf(plugin);
|
|
125
126
|
for (const item of completionList.items) {
|
|
126
127
|
item.data = {
|
|
127
|
-
uri,
|
|
128
|
+
uri: uri.toString(),
|
|
128
129
|
original: {
|
|
129
130
|
additionalTextEdits: item.additionalTextEdits,
|
|
130
131
|
textEdit: item.textEdit,
|
|
131
132
|
data: item.data,
|
|
132
133
|
},
|
|
133
|
-
|
|
134
|
+
pluginIndex,
|
|
134
135
|
embeddedDocumentUri: map ? document.uri : undefined,
|
|
135
136
|
};
|
|
136
137
|
}
|
|
@@ -138,8 +139,8 @@ function register(context) {
|
|
|
138
139
|
completionList = (0, transform_1.transformCompletionList)(completionList, range => map.getSourceRange(range, language_core_1.isCompletionEnabled), document, context);
|
|
139
140
|
}
|
|
140
141
|
lastResult?.results.push({
|
|
141
|
-
embeddedDocumentUri: map ? document.uri : undefined,
|
|
142
|
-
|
|
142
|
+
embeddedDocumentUri: map ? vscode_uri_1.URI.parse(document.uri) : undefined,
|
|
143
|
+
plugin: plugin[1],
|
|
143
144
|
list: completionList,
|
|
144
145
|
});
|
|
145
146
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CodeInformation } from '@volar/language-core';
|
|
2
2
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { URI } from 'vscode-uri';
|
|
4
|
+
import type { LanguageServiceContext } from '../types';
|
|
5
|
+
export declare function register(context: LanguageServiceContext, apiName: 'provideDefinition' | 'provideTypeDefinition' | 'provideImplementation', isValidPosition: (data: CodeInformation) => boolean): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
4
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
5
6
|
const common_1 = require("../utils/common");
|
|
6
7
|
const dedupe = require("../utils/dedupe");
|
|
7
8
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
9
|
function register(context, apiName, isValidPosition) {
|
|
9
10
|
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
|
10
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, isValidPosition), async (
|
|
11
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, isValidPosition), async (plugin, document, position) => {
|
|
11
12
|
if (token.isCancellationRequested) {
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
@@ -16,7 +17,7 @@ function register(context, apiName, isValidPosition) {
|
|
|
16
17
|
await withLinkedCode(document, position, undefined);
|
|
17
18
|
return result;
|
|
18
19
|
async function withLinkedCode(document, position, originDefinition) {
|
|
19
|
-
const api =
|
|
20
|
+
const api = plugin[1][apiName];
|
|
20
21
|
if (!api) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
@@ -28,7 +29,7 @@ function register(context, apiName, isValidPosition) {
|
|
|
28
29
|
for (const definition of definitions) {
|
|
29
30
|
let foundMirrorPosition = false;
|
|
30
31
|
recursiveChecker.add({ uri: definition.targetUri, range: { start: definition.targetRange.start, end: definition.targetRange.start } });
|
|
31
|
-
const decoded = context.decodeEmbeddedDocumentUri(definition.targetUri);
|
|
32
|
+
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(definition.targetUri));
|
|
32
33
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
33
34
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
34
35
|
const linkedCodeMap = virtualCode && sourceScript
|
|
@@ -65,7 +66,7 @@ function register(context, apiName, isValidPosition) {
|
|
|
65
66
|
link.originSelectionRange = originSelectionRange;
|
|
66
67
|
}
|
|
67
68
|
let foundTargetSelectionRange = false;
|
|
68
|
-
const decoded = context.decodeEmbeddedDocumentUri(link.targetUri);
|
|
69
|
+
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(link.targetUri));
|
|
69
70
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
70
71
|
const targetVirtualFile = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
71
72
|
if (targetVirtualFile) {
|
|
@@ -83,7 +84,7 @@ function register(context, apiName, isValidPosition) {
|
|
|
83
84
|
}
|
|
84
85
|
if (apiName === 'provideDefinition' && !foundTargetSelectionRange) {
|
|
85
86
|
for (const targetMap of context.documents.getMaps(targetVirtualFile)) {
|
|
86
|
-
if (targetMap && targetMap.sourceDocument.uri !== uri) {
|
|
87
|
+
if (targetMap && targetMap.sourceDocument.uri !== uri.toString()) {
|
|
87
88
|
return {
|
|
88
89
|
...link,
|
|
89
90
|
targetUri: targetMap.sourceDocument.uri,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import
|
|
2
|
+
import { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
3
4
|
export declare function updateRange(range: vscode.Range, change: {
|
|
4
5
|
range: vscode.Range;
|
|
5
6
|
newEnd: vscode.Position;
|
|
@@ -12,8 +13,8 @@ export interface ServiceDiagnosticData {
|
|
|
12
13
|
serviceIndex: number;
|
|
13
14
|
documentUri: string;
|
|
14
15
|
}
|
|
15
|
-
export declare const errorMarkups:
|
|
16
|
+
export declare const errorMarkups: Map<URI, {
|
|
16
17
|
error: vscode.Diagnostic;
|
|
17
18
|
markup: vscode.MarkupContent;
|
|
18
19
|
}[]>;
|
|
19
|
-
export declare function register(context:
|
|
20
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken, response?: (result: vscode.Diagnostic[]) => void) => Promise<vscode.Diagnostic[]>;
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = exports.errorMarkups = exports.updateRange = void 0;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
5
6
|
const cancellation_1 = require("../utils/cancellation");
|
|
6
7
|
const common_1 = require("../utils/common");
|
|
7
8
|
const dedupe = require("../utils/dedupe");
|
|
8
9
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
10
|
+
const uriMap_1 = require("../utils/uriMap");
|
|
9
11
|
function updateRange(range, change) {
|
|
10
12
|
if (!updatePosition(range.start, change, false)) {
|
|
11
13
|
return;
|
|
@@ -78,9 +80,9 @@ function updatePosition(position, change, isEnd) {
|
|
|
78
80
|
}
|
|
79
81
|
return false;
|
|
80
82
|
}
|
|
81
|
-
exports.errorMarkups =
|
|
83
|
+
exports.errorMarkups = (0, uriMap_1.createUriMap)();
|
|
82
84
|
function register(context) {
|
|
83
|
-
const lastResponses =
|
|
85
|
+
const lastResponses = (0, uriMap_1.createUriMap)();
|
|
84
86
|
const cacheMaps = {
|
|
85
87
|
semantic: new Map(),
|
|
86
88
|
syntactic: new Map(),
|
|
@@ -139,7 +141,7 @@ function register(context) {
|
|
|
139
141
|
return Object.values(lastResponse).flatMap(({ errors }) => errors);
|
|
140
142
|
}
|
|
141
143
|
async function worker(api, cacheMap, cache) {
|
|
142
|
-
const result = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isDiagnosticsEnabled)(mapping.data)), async (
|
|
144
|
+
const result = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isDiagnosticsEnabled)(mapping.data)), async (plugin, document) => {
|
|
143
145
|
if (token) {
|
|
144
146
|
if (Date.now() - lastCheckCancelAt >= 5) {
|
|
145
147
|
await (0, common_1.sleep)(5); // waiting LSP event polling
|
|
@@ -149,18 +151,18 @@ function register(context) {
|
|
|
149
151
|
return;
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
const cache =
|
|
154
|
+
const pluginIndex = context.plugins.indexOf(plugin);
|
|
155
|
+
const pluginCache = cacheMap.get(pluginIndex) ?? cacheMap.set(pluginIndex, new Map()).get(pluginIndex);
|
|
156
|
+
const cache = pluginCache.get(document.uri);
|
|
155
157
|
if (api !== 'provideSemanticDiagnostics' && cache && cache.documentVersion === document.version) {
|
|
156
158
|
return cache.errors;
|
|
157
159
|
}
|
|
158
|
-
const errors = await
|
|
160
|
+
const errors = await plugin[1][api]?.(document, token) || [];
|
|
159
161
|
errors.forEach(error => {
|
|
160
162
|
error.data = {
|
|
161
|
-
uri,
|
|
163
|
+
uri: uri.toString(),
|
|
162
164
|
version: document.version,
|
|
163
|
-
serviceIndex,
|
|
165
|
+
serviceIndex: pluginIndex,
|
|
164
166
|
isFormat: false,
|
|
165
167
|
original: {
|
|
166
168
|
data: error.data,
|
|
@@ -169,7 +171,7 @@ function register(context) {
|
|
|
169
171
|
};
|
|
170
172
|
});
|
|
171
173
|
errorsUpdated = true;
|
|
172
|
-
|
|
174
|
+
pluginCache.set(document.uri, {
|
|
173
175
|
documentVersion: document.version,
|
|
174
176
|
errors,
|
|
175
177
|
});
|
|
@@ -198,7 +200,7 @@ function register(context) {
|
|
|
198
200
|
if (_error.relatedInformation) {
|
|
199
201
|
const relatedInfos = [];
|
|
200
202
|
for (const info of _error.relatedInformation) {
|
|
201
|
-
const decoded = context.decodeEmbeddedDocumentUri(info.location.uri);
|
|
203
|
+
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(info.location.uri));
|
|
202
204
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
203
205
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
204
206
|
if (virtualCode) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
|
|
@@ -7,11 +7,11 @@ const common_1 = require("../utils/common");
|
|
|
7
7
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
8
|
function register(context) {
|
|
9
9
|
return (uri, token = cancellation_1.NoneCancellationToken) => {
|
|
10
|
-
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isColorEnabled)(mapping.data)), (
|
|
10
|
+
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isColorEnabled)(mapping.data)), (plugin, document) => {
|
|
11
11
|
if (token.isCancellationRequested) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
return
|
|
14
|
+
return plugin[1].provideDocumentColors?.(document, token);
|
|
15
15
|
}, (data, map) => {
|
|
16
16
|
if (!map) {
|
|
17
17
|
return data;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { URI } from 'vscode-uri';
|
|
3
|
+
import type { DataTransferItem, LanguageServiceContext } from '../types';
|
|
4
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, dataTransfer: Map<string, DataTransferItem>, token?: vscode.CancellationToken) => Promise<import("../types").DocumentDropEdit | undefined>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
-
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
5
4
|
const cancellation_1 = require("../utils/cancellation");
|
|
5
|
+
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
6
6
|
const transform_1 = require("../utils/transform");
|
|
7
7
|
function register(context) {
|
|
8
8
|
return (uri, position, dataTransfer, token = cancellation_1.NoneCancellationToken) => {
|
|
@@ -10,11 +10,11 @@ function register(context) {
|
|
|
10
10
|
for (const mappedPosition of map.getGeneratedPositions(position)) {
|
|
11
11
|
yield mappedPosition;
|
|
12
12
|
}
|
|
13
|
-
}, (
|
|
13
|
+
}, (plugin, document, arg) => {
|
|
14
14
|
if (token.isCancellationRequested) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
return
|
|
17
|
+
return plugin[1].provideDocumentDropEdits?.(document, arg, dataTransfer, token);
|
|
18
18
|
}, edit => {
|
|
19
19
|
if (edit.additionalEdit) {
|
|
20
20
|
edit.additionalEdit = (0, transform_1.transformWorkspaceEdit)(edit.additionalEdit, context, undefined);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
|
|
4
5
|
ch: string;
|
|
5
6
|
position: vscode.Position;
|
|
6
7
|
} | undefined, token?: vscode.CancellationToken) => Promise<vscode.TextEdit[] | undefined>;
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.register = void 0;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
6
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
6
7
|
const documents_1 = require("../documents");
|
|
7
8
|
const cancellation_1 = require("../utils/cancellation");
|
|
8
9
|
const common_1 = require("../utils/common");
|
|
9
10
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
11
|
+
const uriMap_1 = require("../utils/uriMap");
|
|
10
12
|
function register(context) {
|
|
11
13
|
let fakeVersion = 0;
|
|
12
14
|
return async (uri, options, range, onTypeParams, token = cancellation_1.NoneCancellationToken) => {
|
|
@@ -46,7 +48,7 @@ function register(context) {
|
|
|
46
48
|
try {
|
|
47
49
|
const originalDocument = document;
|
|
48
50
|
let tempSourceSnapshot = sourceScript.snapshot;
|
|
49
|
-
let tempVirtualFile = context.language.scripts.set(sourceScript.id + '.tmp', sourceScript.snapshot, sourceScript.languageId, [sourceScript.generated.languagePlugin])?.generated?.root;
|
|
51
|
+
let tempVirtualFile = context.language.scripts.set(vscode_uri_1.URI.parse(sourceScript.id.toString() + '.tmp'), sourceScript.snapshot, sourceScript.languageId, [sourceScript.generated.languagePlugin])?.generated?.root;
|
|
50
52
|
if (!tempVirtualFile) {
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
@@ -96,7 +98,7 @@ function register(context) {
|
|
|
96
98
|
const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, edits);
|
|
97
99
|
document = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version + 1, newText);
|
|
98
100
|
tempSourceSnapshot = (0, common_1.stringToSnapshot)(newText);
|
|
99
|
-
tempVirtualFile = context.language.scripts.set(sourceScript.id + '.tmp', tempSourceSnapshot, sourceScript.languageId, [sourceScript.generated.languagePlugin])?.generated?.root;
|
|
101
|
+
tempVirtualFile = context.language.scripts.set(vscode_uri_1.URI.parse(sourceScript.id.toString() + '.tmp'), tempSourceSnapshot, sourceScript.languageId, [sourceScript.generated.languagePlugin])?.generated?.root;
|
|
100
102
|
if (!tempVirtualFile) {
|
|
101
103
|
break;
|
|
102
104
|
}
|
|
@@ -116,10 +118,10 @@ function register(context) {
|
|
|
116
118
|
return [textEdit];
|
|
117
119
|
}
|
|
118
120
|
finally {
|
|
119
|
-
context.language.scripts.delete(sourceScript.id + '.tmp');
|
|
121
|
+
context.language.scripts.delete(vscode_uri_1.URI.parse(sourceScript.id.toString() + '.tmp'));
|
|
120
122
|
}
|
|
121
123
|
async function tryFormat(sourceDocument, document, sourceScript, virtualCode, embeddedLevel, rangeOrPosition, ch) {
|
|
122
|
-
if (context.disabledEmbeddedDocumentUris.
|
|
124
|
+
if (context.disabledEmbeddedDocumentUris.get(vscode_uri_1.URI.parse(document.uri))) {
|
|
123
125
|
return;
|
|
124
126
|
}
|
|
125
127
|
let codeOptions;
|
|
@@ -138,15 +140,15 @@ function register(context) {
|
|
|
138
140
|
const startPosition = sourceDocument.positionAt(startOffset);
|
|
139
141
|
codeOptions.initialIndentLevel = computeInitialIndent(sourceDocument.getText(), sourceDocument.offsetAt({ line: startPosition.line, character: 0 }), options);
|
|
140
142
|
}
|
|
141
|
-
for (const
|
|
142
|
-
if (context.disabledServicePlugins.has(
|
|
143
|
+
for (const plugin of context.plugins) {
|
|
144
|
+
if (context.disabledServicePlugins.has(plugin[1])) {
|
|
143
145
|
continue;
|
|
144
146
|
}
|
|
145
|
-
codeOptions = await
|
|
147
|
+
codeOptions = await plugin[1].resolveEmbeddedCodeFormattingOptions?.(sourceScript, virtualCode, codeOptions, token) ?? codeOptions;
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
|
-
for (const
|
|
149
|
-
if (context.disabledServicePlugins.has(
|
|
150
|
+
for (const plugin of context.plugins) {
|
|
151
|
+
if (context.disabledServicePlugins.has(plugin[1])) {
|
|
150
152
|
continue;
|
|
151
153
|
}
|
|
152
154
|
if (token.isCancellationRequested) {
|
|
@@ -155,12 +157,12 @@ function register(context) {
|
|
|
155
157
|
let edits;
|
|
156
158
|
try {
|
|
157
159
|
if (ch !== undefined && rangeOrPosition && 'line' in rangeOrPosition && 'character' in rangeOrPosition) {
|
|
158
|
-
if (
|
|
159
|
-
edits = await
|
|
160
|
+
if (plugin[0].capabilities.documentOnTypeFormattingProvider?.triggerCharacters?.includes(ch)) {
|
|
161
|
+
edits = await plugin[1].provideOnTypeFormattingEdits?.(document, rangeOrPosition, ch, options, codeOptions, token);
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
else if (ch === undefined && rangeOrPosition && 'start' in rangeOrPosition && 'end' in rangeOrPosition) {
|
|
163
|
-
edits = await
|
|
165
|
+
edits = await plugin[1].provideDocumentFormattingEdits?.(document, rangeOrPosition, options, codeOptions, token);
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
catch (err) {
|
|
@@ -170,14 +172,14 @@ function register(context) {
|
|
|
170
172
|
continue;
|
|
171
173
|
}
|
|
172
174
|
return {
|
|
173
|
-
|
|
175
|
+
plugin,
|
|
174
176
|
edits,
|
|
175
177
|
};
|
|
176
178
|
}
|
|
177
179
|
}
|
|
178
180
|
};
|
|
179
181
|
function createDocMap(virtualCode, documentUri, sourceLanguageId, _sourceSnapshot) {
|
|
180
|
-
const mapOfMap =
|
|
182
|
+
const mapOfMap = (0, uriMap_1.createUriMap)();
|
|
181
183
|
(0, language_core_1.updateVirtualCodeMapOfMap)(virtualCode, mapOfMap, sourceFileUri2 => {
|
|
182
184
|
if (!sourceFileUri2) {
|
|
183
185
|
return [documentUri, _sourceSnapshot];
|
|
@@ -186,7 +188,7 @@ function register(context) {
|
|
|
186
188
|
if (mapOfMap.has(documentUri) && mapOfMap.get(documentUri)[0] === _sourceSnapshot) {
|
|
187
189
|
const map = mapOfMap.get(documentUri);
|
|
188
190
|
const version = fakeVersion++;
|
|
189
|
-
return new documents_1.SourceMapWithDocuments(vscode_languageserver_textdocument_1.TextDocument.create(documentUri, sourceLanguageId, version, _sourceSnapshot.getText(0, _sourceSnapshot.getLength())), vscode_languageserver_textdocument_1.TextDocument.create(context.encodeEmbeddedDocumentUri(documentUri, virtualCode.id), virtualCode.languageId, version, virtualCode.snapshot.getText(0, virtualCode.snapshot.getLength())), map[1]);
|
|
191
|
+
return new documents_1.SourceMapWithDocuments(vscode_languageserver_textdocument_1.TextDocument.create(documentUri.toString(), sourceLanguageId, version, _sourceSnapshot.getText(0, _sourceSnapshot.getLength())), vscode_languageserver_textdocument_1.TextDocument.create(context.encodeEmbeddedDocumentUri(documentUri, virtualCode.id).toString(), virtualCode.languageId, version, virtualCode.snapshot.getText(0, virtualCode.snapshot.getLength())), map[1], virtualCode);
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
-
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
5
|
-
const dedupe = require("../utils/dedupe");
|
|
6
|
-
const common_1 = require("../utils/common");
|
|
7
|
-
const cancellation_1 = require("../utils/cancellation");
|
|
8
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
6
|
+
const cancellation_1 = require("../utils/cancellation");
|
|
7
|
+
const common_1 = require("../utils/common");
|
|
8
|
+
const dedupe = require("../utils/dedupe");
|
|
9
|
+
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
9
10
|
function register(context) {
|
|
10
11
|
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
|
11
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isHighlightEnabled), async (
|
|
12
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isHighlightEnabled), async (plugin, document, position) => {
|
|
12
13
|
if (token.isCancellationRequested) {
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
@@ -17,18 +18,18 @@ function register(context) {
|
|
|
17
18
|
await withLinkedCode(document, position);
|
|
18
19
|
return result;
|
|
19
20
|
async function withLinkedCode(document, position) {
|
|
20
|
-
if (!
|
|
21
|
+
if (!plugin[1].provideDocumentHighlights) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } })) {
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
27
|
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
27
|
-
const references = await
|
|
28
|
+
const references = await plugin[1].provideDocumentHighlights(document, position, token) ?? [];
|
|
28
29
|
for (const reference of references) {
|
|
29
30
|
let foundMirrorPosition = false;
|
|
30
31
|
recursiveChecker.add({ uri: document.uri, range: { start: reference.range.start, end: reference.range.start } });
|
|
31
|
-
const decoded = context.decodeEmbeddedDocumentUri(document.uri);
|
|
32
|
+
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
|
32
33
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
33
34
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
34
35
|
const linkedCodeMap = virtualCode && sourceScript
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
3
4
|
export interface DocumentLinkData {
|
|
4
5
|
uri: string;
|
|
5
6
|
original: Pick<vscode.DocumentLink, 'data'>;
|
|
6
|
-
|
|
7
|
+
pluginIndex: number;
|
|
7
8
|
}
|
|
8
|
-
export declare function register(context:
|
|
9
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
+
const language_core_1 = require("@volar/language-core");
|
|
4
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
5
6
|
const common_1 = require("../utils/common");
|
|
6
7
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
7
8
|
const transform_1 = require("../utils/transform");
|
|
8
|
-
const language_core_1 = require("@volar/language-core");
|
|
9
9
|
function register(context) {
|
|
10
10
|
return async (uri, token = cancellation_1.NoneCancellationToken) => {
|
|
11
|
-
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isDocumentLinkEnabled)(mapping.data)), async (
|
|
11
|
+
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isDocumentLinkEnabled)(mapping.data)), async (plugin, document) => {
|
|
12
12
|
if (token.isCancellationRequested) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
const links = await
|
|
15
|
+
const links = await plugin[1].provideDocumentLinks?.(document, token);
|
|
16
16
|
for (const link of links ?? []) {
|
|
17
17
|
link.data = {
|
|
18
|
-
uri,
|
|
18
|
+
uri: uri.toString(),
|
|
19
19
|
original: {
|
|
20
20
|
data: link.data,
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
pluginIndex: context.plugins.indexOf(plugin),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
return links;
|
|
@@ -38,7 +38,7 @@ function register(context) {
|
|
|
38
38
|
range,
|
|
39
39
|
};
|
|
40
40
|
if (link.target) {
|
|
41
|
-
link.target = (0, transform_1.transformDocumentLinkTarget)(link.target, context);
|
|
41
|
+
link.target = (0, transform_1.transformDocumentLinkTarget)(link.target, context).toString();
|
|
42
42
|
}
|
|
43
43
|
return link;
|
|
44
44
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken, _reportProgress?: (tokens: vscode.SemanticTokens) => void) => Promise<vscode.SemanticTokens | undefined>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
+
const language_core_1 = require("@volar/language-core");
|
|
4
5
|
const SemanticTokensBuilder_1 = require("../utils/SemanticTokensBuilder");
|
|
5
6
|
const cancellation_1 = require("../utils/cancellation");
|
|
6
7
|
const common_1 = require("../utils/common");
|
|
7
8
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
|
-
const language_core_1 = require("@volar/language-core");
|
|
9
9
|
function register(context) {
|
|
10
10
|
return async (uri, range, legend, token = cancellation_1.NoneCancellationToken, _reportProgress) => {
|
|
11
11
|
const sourceScript = context.language.scripts.get(uri);
|
|
@@ -27,11 +27,11 @@ function register(context) {
|
|
|
27
27
|
end: map.embeddedDocument.positionAt(mapped.end),
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
}, (
|
|
30
|
+
}, (plugin, document, range) => {
|
|
31
31
|
if (token?.isCancellationRequested) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return plugin[1].provideDocumentSemanticTokens?.(document, range, legend, token);
|
|
35
35
|
}, (tokens, map) => {
|
|
36
36
|
if (!map) {
|
|
37
37
|
return tokens;
|