@volar/language-service 2.0.0-alpha.8 → 2.0.0
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/documents.d.ts +7 -7
- package/lib/documents.js +18 -23
- package/lib/features/provideCallHierarchyItems.js +22 -15
- package/lib/features/provideCodeActions.js +5 -3
- package/lib/features/provideColorPresentations.js +4 -2
- package/lib/features/provideCompletionItems.js +46 -24
- package/lib/features/provideDefinition.js +13 -8
- package/lib/features/provideDiagnostics.js +9 -5
- package/lib/features/provideDocumentDropEdits.js +1 -1
- package/lib/features/provideDocumentFormattingEdits.js +55 -51
- package/lib/features/provideDocumentHighlights.js +10 -6
- package/lib/features/provideDocumentSemanticTokens.js +5 -3
- package/lib/features/provideDocumentSymbols.js +2 -1
- package/lib/features/provideFileReferences.js +4 -4
- package/lib/features/provideFileRenameEdits.js +7 -17
- package/lib/features/provideInlayHints.js +3 -2
- package/lib/features/provideLinkedEditingRanges.js +2 -1
- package/lib/features/provideReferences.js +14 -10
- package/lib/features/provideRenameEdits.js +22 -13
- package/lib/features/provideSelectionRanges.js +2 -1
- package/lib/features/provideSignatureHelp.js +1 -1
- package/lib/features/provideWorkspaceSymbols.js +6 -3
- package/lib/features/resolveCodeAction.js +2 -1
- package/lib/features/resolveCodeLens.js +2 -1
- package/lib/features/resolveCompletionItem.js +5 -4
- package/lib/features/resolveDocumentLink.js +5 -4
- package/lib/features/resolveInlayHint.js +2 -1
- package/lib/languageService.d.ts +2 -2
- package/lib/languageService.js +9 -5
- package/lib/types.d.ts +17 -18
- package/lib/utils/common.d.ts +1 -1
- package/lib/utils/common.js +10 -5
- package/lib/utils/dedupe.d.ts +1 -1
- package/lib/utils/featureWorkers.d.ts +3 -2
- package/lib/utils/featureWorkers.js +44 -17
- package/lib/utils/transform.d.ts +1 -1
- package/lib/utils/transform.js +26 -21
- package/package.json +3 -3
package/lib/documents.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { CodeInformation, CodeRangeKey,
|
|
2
|
-
import type * as ts from 'typescript
|
|
1
|
+
import { CodeInformation, CodeRangeKey, FileRegistry, LinkedCodeMap, Mapping, SourceMap, VirtualCode } from '@volar/language-core';
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
3
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
4
4
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
5
|
-
import type { RuntimeEnvironment } from '../lib/types';
|
|
6
5
|
export type DocumentProvider = ReturnType<typeof createDocumentProvider>;
|
|
7
6
|
export declare class SourceMapWithDocuments<Data = any> {
|
|
8
7
|
sourceFileDocument: TextDocument;
|
|
@@ -30,9 +29,10 @@ export declare class LinkedCodeMapWithDocument extends SourceMapWithDocuments {
|
|
|
30
29
|
constructor(document: TextDocument, linkedMap: LinkedCodeMap);
|
|
31
30
|
getLinkedCodePositions(posotion: vscode.Position): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
|
|
32
31
|
}
|
|
33
|
-
export declare function createDocumentProvider(
|
|
32
|
+
export declare function createDocumentProvider(files: FileRegistry): {
|
|
34
33
|
get: (uri: string, languageId: string, snapshot: ts.IScriptSnapshot) => TextDocument;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
getMaps(virtualCode: VirtualCode): Generator<SourceMapWithDocuments<CodeInformation>, void, unknown>;
|
|
35
|
+
getLinkedCodeMap(virtualCode: VirtualCode): LinkedCodeMapWithDocument | undefined;
|
|
36
|
+
getVirtualCodeByUri(uri: string): readonly [VirtualCode<string>, import("@volar/language-core").SourceFile] | readonly [undefined, undefined];
|
|
37
|
+
getVirtualCodeUri(sourceFileUri: string, virtualCodeId: string): string;
|
|
38
38
|
};
|
package/lib/documents.js
CHANGED
|
@@ -113,46 +113,41 @@ class LinkedCodeMapWithDocument extends SourceMapWithDocuments {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
exports.LinkedCodeMapWithDocument = LinkedCodeMapWithDocument;
|
|
116
|
-
function createDocumentProvider(
|
|
116
|
+
function createDocumentProvider(files) {
|
|
117
117
|
let version = 0;
|
|
118
118
|
const map2DocMap = new WeakMap();
|
|
119
119
|
const mirrorMap2DocMirrorMap = new WeakMap();
|
|
120
120
|
const snapshot2Doc = new WeakMap();
|
|
121
121
|
return {
|
|
122
122
|
get,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const result = [];
|
|
126
|
-
for (const virtualFile of (0, language_core_1.forEachEmbeddedFile)(source.virtualFile[0])) {
|
|
127
|
-
for (const [sourceUri, [sourceSnapshot, map]] of files.getMaps(virtualFile)) {
|
|
128
|
-
if (sourceSnapshot === source.snapshot) {
|
|
129
|
-
if (!map2DocMap.has(map)) {
|
|
130
|
-
map2DocMap.set(map, new SourceMapWithDocuments(get(sourceUri, source.languageId, sourceSnapshot), get(env.fileNameToUri(virtualFile.fileName), virtualFile.languageId, virtualFile.snapshot), map));
|
|
131
|
-
}
|
|
132
|
-
result.push([virtualFile, map2DocMap.get(map)]);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return result;
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
*getMaps(virtualFile) {
|
|
140
|
-
for (const [sourceFileName, [sourceSnapshot, map]] of files.getMaps(virtualFile)) {
|
|
123
|
+
*getMaps(virtualCode) {
|
|
124
|
+
for (const [sourceFileUri, [sourceSnapshot, map]] of files.getMaps(virtualCode)) {
|
|
141
125
|
if (!map2DocMap.has(map)) {
|
|
142
|
-
map2DocMap.set(map, new SourceMapWithDocuments(get(
|
|
126
|
+
map2DocMap.set(map, new SourceMapWithDocuments(get(sourceFileUri, files.get(sourceFileUri).languageId, sourceSnapshot), get(this.getVirtualCodeUri(sourceFileUri, virtualCode.id), virtualCode.languageId, virtualCode.snapshot), map));
|
|
143
127
|
}
|
|
144
128
|
yield map2DocMap.get(map);
|
|
145
129
|
}
|
|
146
130
|
},
|
|
147
|
-
getLinkedCodeMap(
|
|
148
|
-
const map = files.getLinkedCodeMap(
|
|
131
|
+
getLinkedCodeMap(virtualCode) {
|
|
132
|
+
const map = files.getLinkedCodeMap(virtualCode);
|
|
149
133
|
if (map) {
|
|
150
134
|
if (!mirrorMap2DocMirrorMap.has(map)) {
|
|
151
|
-
mirrorMap2DocMirrorMap.set(map, new LinkedCodeMapWithDocument(get(
|
|
135
|
+
mirrorMap2DocMirrorMap.set(map, new LinkedCodeMapWithDocument(get(this.getVirtualCodeUri(files.getByVirtualCode(virtualCode).id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot), map));
|
|
152
136
|
}
|
|
153
137
|
return mirrorMap2DocMirrorMap.get(map);
|
|
154
138
|
}
|
|
155
139
|
},
|
|
140
|
+
getVirtualCodeByUri(uri) {
|
|
141
|
+
if (uri.includes('?virtualCodeId=')) {
|
|
142
|
+
const sourceFileUri = uri.split('?virtualCodeId=')[0];
|
|
143
|
+
const virtualCodeId = uri.split('?virtualCodeId=')[1];
|
|
144
|
+
return files.getVirtualCode(sourceFileUri, virtualCodeId);
|
|
145
|
+
}
|
|
146
|
+
return [undefined, undefined];
|
|
147
|
+
},
|
|
148
|
+
getVirtualCodeUri(sourceFileUri, virtualCodeId) {
|
|
149
|
+
return sourceFileUri + `?virtualCodeId=${virtualCodeId}`;
|
|
150
|
+
},
|
|
156
151
|
};
|
|
157
152
|
function get(uri, languageId, snapshot) {
|
|
158
153
|
if (!snapshot2Doc.has(snapshot)) {
|
|
@@ -39,17 +39,19 @@ function register(context) {
|
|
|
39
39
|
let incomingItems = [];
|
|
40
40
|
if (data) {
|
|
41
41
|
const service = context.services[data.serviceIndex];
|
|
42
|
-
if (!service[1].provideCallHierarchyIncomingCalls)
|
|
42
|
+
if (!service[1].provideCallHierarchyIncomingCalls) {
|
|
43
43
|
return incomingItems;
|
|
44
|
+
}
|
|
44
45
|
Object.assign(item, data.original);
|
|
45
46
|
if (data.virtualDocumentUri) {
|
|
46
|
-
const [
|
|
47
|
-
if (
|
|
47
|
+
const [virtualCode] = context.documents.getVirtualCodeByUri(data.virtualDocumentUri);
|
|
48
|
+
if (virtualCode) {
|
|
48
49
|
const _calls = await service[1].provideCallHierarchyIncomingCalls(item, token);
|
|
49
50
|
for (const _call of _calls) {
|
|
50
51
|
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
51
|
-
if (!calls)
|
|
52
|
+
if (!calls) {
|
|
52
53
|
continue;
|
|
54
|
+
}
|
|
53
55
|
incomingItems.push({
|
|
54
56
|
from: calls[0],
|
|
55
57
|
fromRanges: calls[1],
|
|
@@ -61,8 +63,9 @@ function register(context) {
|
|
|
61
63
|
const _calls = await service[1].provideCallHierarchyIncomingCalls(item, token);
|
|
62
64
|
for (const _call of _calls) {
|
|
63
65
|
const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);
|
|
64
|
-
if (!calls)
|
|
66
|
+
if (!calls) {
|
|
65
67
|
continue;
|
|
68
|
+
}
|
|
66
69
|
incomingItems.push({
|
|
67
70
|
from: calls[0],
|
|
68
71
|
fromRanges: calls[1],
|
|
@@ -77,17 +80,19 @@ function register(context) {
|
|
|
77
80
|
let items = [];
|
|
78
81
|
if (data) {
|
|
79
82
|
const service = context.services[data.serviceIndex];
|
|
80
|
-
if (!service[1].provideCallHierarchyOutgoingCalls)
|
|
83
|
+
if (!service[1].provideCallHierarchyOutgoingCalls) {
|
|
81
84
|
return items;
|
|
85
|
+
}
|
|
82
86
|
Object.assign(item, data.original);
|
|
83
87
|
if (data.virtualDocumentUri) {
|
|
84
|
-
const [
|
|
85
|
-
if (
|
|
88
|
+
const [virtualCode] = context.documents.getVirtualCodeByUri(data.virtualDocumentUri);
|
|
89
|
+
if (virtualCode) {
|
|
86
90
|
const _calls = await service[1].provideCallHierarchyOutgoingCalls(item, token);
|
|
87
91
|
for (const call of _calls) {
|
|
88
92
|
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
89
|
-
if (!calls)
|
|
93
|
+
if (!calls) {
|
|
90
94
|
continue;
|
|
95
|
+
}
|
|
91
96
|
items.push({
|
|
92
97
|
to: calls[0],
|
|
93
98
|
fromRanges: calls[1],
|
|
@@ -99,8 +104,9 @@ function register(context) {
|
|
|
99
104
|
const _calls = await service[1].provideCallHierarchyOutgoingCalls(item, token);
|
|
100
105
|
for (const call of _calls) {
|
|
101
106
|
const calls = transformCallHierarchyItem(call.to, call.fromRanges);
|
|
102
|
-
if (!calls)
|
|
107
|
+
if (!calls) {
|
|
103
108
|
continue;
|
|
109
|
+
}
|
|
104
110
|
items.push({
|
|
105
111
|
to: calls[0],
|
|
106
112
|
fromRanges: calls[1],
|
|
@@ -112,10 +118,11 @@ function register(context) {
|
|
|
112
118
|
},
|
|
113
119
|
};
|
|
114
120
|
function transformCallHierarchyItem(tsItem, tsRanges) {
|
|
115
|
-
const [
|
|
116
|
-
if (!
|
|
121
|
+
const [virtualCode] = context.documents.getVirtualCodeByUri(tsItem.uri);
|
|
122
|
+
if (!virtualCode) {
|
|
117
123
|
return [tsItem, tsRanges];
|
|
118
|
-
|
|
124
|
+
}
|
|
125
|
+
for (const map of context.documents.getMaps(virtualCode)) {
|
|
119
126
|
let range = map.getSourceRange(tsItem.range);
|
|
120
127
|
if (!range) {
|
|
121
128
|
// TODO: <script> range
|
|
@@ -125,8 +132,9 @@ function register(context) {
|
|
|
125
132
|
};
|
|
126
133
|
}
|
|
127
134
|
const selectionRange = map.getSourceRange(tsItem.selectionRange);
|
|
128
|
-
if (!selectionRange)
|
|
135
|
+
if (!selectionRange) {
|
|
129
136
|
continue;
|
|
137
|
+
}
|
|
130
138
|
const vueRanges = tsRanges.map(tsRange => map.getSourceRange(tsRange)).filter(common_1.notEmpty);
|
|
131
139
|
const vueItem = {
|
|
132
140
|
...tsItem,
|
|
@@ -144,7 +152,6 @@ function register(context) {
|
|
|
144
152
|
end: selectionRange.end,
|
|
145
153
|
},
|
|
146
154
|
};
|
|
147
|
-
selectionRange.end;
|
|
148
155
|
return [vueItem, vueRanges];
|
|
149
156
|
}
|
|
150
157
|
}
|
|
@@ -9,9 +9,10 @@ const transform_1 = require("../utils/transform");
|
|
|
9
9
|
const language_core_1 = require("@volar/language-core");
|
|
10
10
|
function register(context) {
|
|
11
11
|
return async (uri, range, codeActionContext, token = cancellation_1.NoneCancellationToken) => {
|
|
12
|
-
const sourceFile = context.language.files.
|
|
13
|
-
if (!sourceFile)
|
|
12
|
+
const sourceFile = context.language.files.get(uri);
|
|
13
|
+
if (!sourceFile) {
|
|
14
14
|
return;
|
|
15
|
+
}
|
|
15
16
|
const document = context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
|
|
16
17
|
const offsetRange = {
|
|
17
18
|
start: document.offsetAt(range.start),
|
|
@@ -93,8 +94,9 @@ function register(context) {
|
|
|
93
94
|
return codeActions;
|
|
94
95
|
}, actions => actions
|
|
95
96
|
.map(action => {
|
|
96
|
-
if (transformedCodeActions.has(action))
|
|
97
|
+
if (transformedCodeActions.has(action)) {
|
|
97
98
|
return action;
|
|
99
|
+
}
|
|
98
100
|
if (action.edit) {
|
|
99
101
|
const edit = (0, transform_1.transformWorkspaceEdit)(action.edit, context, 'codeAction');
|
|
100
102
|
if (!edit) {
|
|
@@ -24,15 +24,17 @@ function register(context) {
|
|
|
24
24
|
.map(colorPresentation => {
|
|
25
25
|
if (colorPresentation.textEdit) {
|
|
26
26
|
const range = map.getSourceRange(colorPresentation.textEdit.range);
|
|
27
|
-
if (!range)
|
|
27
|
+
if (!range) {
|
|
28
28
|
return undefined;
|
|
29
|
+
}
|
|
29
30
|
colorPresentation.textEdit.range = range;
|
|
30
31
|
}
|
|
31
32
|
if (colorPresentation.additionalTextEdits) {
|
|
32
33
|
for (const textEdit of colorPresentation.additionalTextEdits) {
|
|
33
34
|
const range = map.getSourceRange(textEdit.range);
|
|
34
|
-
if (!range)
|
|
35
|
+
if (!range) {
|
|
35
36
|
return undefined;
|
|
37
|
+
}
|
|
36
38
|
textEdit.range = range;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -8,20 +8,23 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
8
8
|
function register(context) {
|
|
9
9
|
let cache;
|
|
10
10
|
return async (uri, position, completionContext = { triggerKind: 1, }, token = cancellation_1.NoneCancellationToken) => {
|
|
11
|
-
const sourceFile = context.language.files.
|
|
11
|
+
const sourceFile = context.language.files.get(uri);
|
|
12
12
|
if (completionContext?.triggerKind === 3
|
|
13
13
|
&& cache?.uri === uri) {
|
|
14
14
|
for (const cacheData of cache.data) {
|
|
15
|
-
if (!cacheData.list.isIncomplete)
|
|
15
|
+
if (!cacheData.list.isIncomplete) {
|
|
16
16
|
continue;
|
|
17
|
+
}
|
|
17
18
|
if (cacheData.virtualDocumentUri) {
|
|
18
|
-
const [
|
|
19
|
-
if (!
|
|
19
|
+
const [virtualCode] = context.documents.getVirtualCodeByUri(cacheData.virtualDocumentUri);
|
|
20
|
+
if (!virtualCode) {
|
|
20
21
|
continue;
|
|
21
|
-
|
|
22
|
+
}
|
|
23
|
+
for (const map of context.documents.getMaps(virtualCode)) {
|
|
22
24
|
for (const mapped of map.getGeneratedPositions(position, data => (0, language_core_1.isCompletionEnabled)(data))) {
|
|
23
|
-
if (!cacheData.service.provideCompletionItems)
|
|
25
|
+
if (!cacheData.service.provideCompletionItems) {
|
|
24
26
|
continue;
|
|
27
|
+
}
|
|
25
28
|
const embeddedCompletionList = await cacheData.service.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
|
|
26
29
|
if (!embeddedCompletionList) {
|
|
27
30
|
cacheData.list.isIncomplete = false;
|
|
@@ -41,8 +44,9 @@ function register(context) {
|
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
else if (sourceFile) {
|
|
44
|
-
if (!cacheData.service.provideCompletionItems)
|
|
47
|
+
if (!cacheData.service.provideCompletionItems) {
|
|
45
48
|
continue;
|
|
49
|
+
}
|
|
46
50
|
const document = context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
|
|
47
51
|
const completionList = await cacheData.service.provideCompletionItems(document, position, completionContext, token);
|
|
48
52
|
if (!completionList) {
|
|
@@ -65,7 +69,7 @@ function register(context) {
|
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
else {
|
|
68
|
-
const rootVirtualFile = context.language.files.
|
|
72
|
+
const rootVirtualFile = context.language.files.get(uri)?.generated?.code;
|
|
69
73
|
cache = {
|
|
70
74
|
uri,
|
|
71
75
|
data: [],
|
|
@@ -75,30 +79,39 @@ function register(context) {
|
|
|
75
79
|
let isFirstMapping = true;
|
|
76
80
|
if (rootVirtualFile) {
|
|
77
81
|
await (0, featureWorkers_1.visitEmbedded)(context, rootVirtualFile, async (_, map) => {
|
|
78
|
-
const services = [...context.services]
|
|
82
|
+
const services = [...context.services]
|
|
83
|
+
.filter(service => !context.disabledServicePlugins.has(service[1]))
|
|
84
|
+
.sort((a, b) => sortServices(a[1], b[1]));
|
|
79
85
|
let _data;
|
|
80
86
|
for (const mapped of map.getGeneratedPositions(position, data => {
|
|
81
87
|
_data = data;
|
|
82
88
|
return (0, language_core_1.isCompletionEnabled)(data);
|
|
83
89
|
})) {
|
|
84
90
|
for (const service of services) {
|
|
85
|
-
if (token.isCancellationRequested)
|
|
91
|
+
if (token.isCancellationRequested) {
|
|
86
92
|
break;
|
|
87
|
-
|
|
93
|
+
}
|
|
94
|
+
if (!service[1].provideCompletionItems) {
|
|
88
95
|
continue;
|
|
89
|
-
|
|
96
|
+
}
|
|
97
|
+
if (service[1].isAdditionalCompletion && !isFirstMapping) {
|
|
90
98
|
continue;
|
|
91
|
-
|
|
99
|
+
}
|
|
100
|
+
if (completionContext?.triggerCharacter && !service[0].triggerCharacters?.includes(completionContext.triggerCharacter)) {
|
|
92
101
|
continue;
|
|
102
|
+
}
|
|
93
103
|
const isAdditional = _data && typeof _data.completion === 'object' && _data.completion.isAdditional || service[1].isAdditionalCompletion;
|
|
94
|
-
if (cache.mainCompletion && (!isAdditional || cache?.mainCompletion.documentUri !== map.virtualFileDocument.uri))
|
|
104
|
+
if (cache.mainCompletion && (!isAdditional || cache?.mainCompletion.documentUri !== map.virtualFileDocument.uri)) {
|
|
95
105
|
continue;
|
|
106
|
+
}
|
|
96
107
|
// avoid duplicate items with .vue and .vue.html
|
|
97
|
-
if (service[1].isAdditionalCompletion && cache?.data.some(data => data.service === service[1]))
|
|
108
|
+
if (service[1].isAdditionalCompletion && cache?.data.some(data => data.service === service[1])) {
|
|
98
109
|
continue;
|
|
110
|
+
}
|
|
99
111
|
const embeddedCompletionList = await service[1].provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
|
|
100
|
-
if (!embeddedCompletionList || !embeddedCompletionList.items.length)
|
|
112
|
+
if (!embeddedCompletionList || !embeddedCompletionList.items.length) {
|
|
101
113
|
continue;
|
|
114
|
+
}
|
|
102
115
|
if (typeof _data?.completion === 'object' && _data.completion.onlyImport) {
|
|
103
116
|
embeddedCompletionList.items = embeddedCompletionList.items.filter(item => !!item.labelDetails);
|
|
104
117
|
}
|
|
@@ -129,24 +142,33 @@ function register(context) {
|
|
|
129
142
|
}
|
|
130
143
|
if (sourceFile) {
|
|
131
144
|
const document = context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
|
|
132
|
-
const services = [...context.services]
|
|
145
|
+
const services = [...context.services]
|
|
146
|
+
.filter(service => !context.disabledServicePlugins.has(service[1]))
|
|
147
|
+
.sort((a, b) => sortServices(a[1], b[1]));
|
|
133
148
|
for (const service of services) {
|
|
134
|
-
if (token.isCancellationRequested)
|
|
149
|
+
if (token.isCancellationRequested) {
|
|
135
150
|
break;
|
|
136
|
-
|
|
151
|
+
}
|
|
152
|
+
if (!service[1].provideCompletionItems) {
|
|
137
153
|
continue;
|
|
138
|
-
|
|
154
|
+
}
|
|
155
|
+
if (service[1].isAdditionalCompletion && !isFirstMapping) {
|
|
139
156
|
continue;
|
|
140
|
-
|
|
157
|
+
}
|
|
158
|
+
if (completionContext?.triggerCharacter && !service[0].triggerCharacters?.includes(completionContext.triggerCharacter)) {
|
|
141
159
|
continue;
|
|
142
|
-
|
|
160
|
+
}
|
|
161
|
+
if (cache.mainCompletion && (!service[1].isAdditionalCompletion || cache.mainCompletion.documentUri !== document.uri)) {
|
|
143
162
|
continue;
|
|
163
|
+
}
|
|
144
164
|
// avoid duplicate items with .vue and .vue.html
|
|
145
|
-
if (service[1].isAdditionalCompletion && cache?.data.some(data => data.service === service[1]))
|
|
165
|
+
if (service[1].isAdditionalCompletion && cache?.data.some(data => data.service === service[1])) {
|
|
146
166
|
continue;
|
|
167
|
+
}
|
|
147
168
|
const completionList = await service[1].provideCompletionItems(document, position, completionContext, token);
|
|
148
|
-
if (!completionList || !completionList.items.length)
|
|
169
|
+
if (!completionList || !completionList.items.length) {
|
|
149
170
|
continue;
|
|
171
|
+
}
|
|
150
172
|
if (!service[1].isAdditionalCompletion) {
|
|
151
173
|
cache.mainCompletion = { documentUri: document.uri };
|
|
152
174
|
}
|
|
@@ -17,21 +17,24 @@ function register(context, apiName, isValidPosition) {
|
|
|
17
17
|
return result;
|
|
18
18
|
async function withMirrors(document, position, originDefinition) {
|
|
19
19
|
const api = service[1][apiName];
|
|
20
|
-
if (!api)
|
|
20
|
+
if (!api) {
|
|
21
21
|
return;
|
|
22
|
-
|
|
22
|
+
}
|
|
23
|
+
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } })) {
|
|
23
24
|
return;
|
|
25
|
+
}
|
|
24
26
|
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
25
27
|
const definitions = await api?.(document, position, token) ?? [];
|
|
26
28
|
for (const definition of definitions) {
|
|
27
29
|
let foundMirrorPosition = false;
|
|
28
30
|
recursiveChecker.add({ uri: definition.targetUri, range: { start: definition.targetRange.start, end: definition.targetRange.start } });
|
|
29
|
-
const [
|
|
30
|
-
const mirrorMap =
|
|
31
|
+
const [virtualCode] = context.documents.getVirtualCodeByUri(definition.targetUri);
|
|
32
|
+
const mirrorMap = virtualCode ? context.documents.getLinkedCodeMap(virtualCode) : undefined;
|
|
31
33
|
if (mirrorMap) {
|
|
32
34
|
for (const linkedPos of mirrorMap.getLinkedCodePositions(definition.targetSelectionRange.start)) {
|
|
33
|
-
if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: linkedPos, end: linkedPos } }))
|
|
35
|
+
if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: linkedPos, end: linkedPos } })) {
|
|
34
36
|
continue;
|
|
37
|
+
}
|
|
35
38
|
foundMirrorPosition = true;
|
|
36
39
|
await withMirrors(mirrorMap.document, linkedPos, originDefinition ?? definition);
|
|
37
40
|
}
|
|
@@ -52,17 +55,19 @@ function register(context, apiName, isValidPosition) {
|
|
|
52
55
|
}, (data, map) => data.map(link => {
|
|
53
56
|
if (link.originSelectionRange && map) {
|
|
54
57
|
const originSelectionRange = toSourcePositionPreferSurroundedPosition(map, link.originSelectionRange, position);
|
|
55
|
-
if (!originSelectionRange)
|
|
58
|
+
if (!originSelectionRange) {
|
|
56
59
|
return;
|
|
60
|
+
}
|
|
57
61
|
link.originSelectionRange = originSelectionRange;
|
|
58
62
|
}
|
|
59
63
|
let foundTargetSelectionRange = false;
|
|
60
|
-
const [targetVirtualFile] = context.
|
|
64
|
+
const [targetVirtualFile] = context.documents.getVirtualCodeByUri(link.targetUri);
|
|
61
65
|
if (targetVirtualFile) {
|
|
62
66
|
for (const targetSourceMap of context.documents.getMaps(targetVirtualFile)) {
|
|
63
67
|
const targetSelectionRange = targetSourceMap.getSourceRange(link.targetSelectionRange);
|
|
64
|
-
if (!targetSelectionRange)
|
|
68
|
+
if (!targetSelectionRange) {
|
|
65
69
|
continue;
|
|
70
|
+
}
|
|
66
71
|
foundTargetSelectionRange = true;
|
|
67
72
|
let targetRange = targetSourceMap.getSourceRange(link.targetRange);
|
|
68
73
|
link.targetUri = targetSourceMap.sourceFileDocument.uri;
|
|
@@ -91,9 +91,10 @@ function register(context) {
|
|
|
91
91
|
cacheMaps.syntactic.clear();
|
|
92
92
|
});
|
|
93
93
|
return async (uri, token = cancellation_1.NoneCancellationToken, response) => {
|
|
94
|
-
const sourceFile = context.language.files.
|
|
95
|
-
if (!sourceFile)
|
|
94
|
+
const sourceFile = context.language.files.get(uri);
|
|
95
|
+
if (!sourceFile) {
|
|
96
96
|
return [];
|
|
97
|
+
}
|
|
97
98
|
const document = context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
|
|
98
99
|
const lastResponse = lastResponses.get(uri) ?? lastResponses.set(uri, {
|
|
99
100
|
semantic: { errors: [] },
|
|
@@ -139,6 +140,9 @@ function register(context) {
|
|
|
139
140
|
exports.errorMarkups[uri] = [];
|
|
140
141
|
for (const error of errors) {
|
|
141
142
|
for (const service of context.services) {
|
|
143
|
+
if (context.disabledServicePlugins.has(service[1])) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
142
146
|
const markup = await service[1].provideDiagnosticMarkupContent?.(error, token);
|
|
143
147
|
if (markup) {
|
|
144
148
|
exports.errorMarkups[uri].push({ error, markup });
|
|
@@ -207,9 +211,9 @@ function register(context) {
|
|
|
207
211
|
if (_error.relatedInformation) {
|
|
208
212
|
const relatedInfos = [];
|
|
209
213
|
for (const info of _error.relatedInformation) {
|
|
210
|
-
const [
|
|
211
|
-
if (
|
|
212
|
-
for (const map of context.documents.getMaps(
|
|
214
|
+
const [virtualCode] = context.documents.getVirtualCodeByUri(info.location.uri);
|
|
215
|
+
if (virtualCode) {
|
|
216
|
+
for (const map of context.documents.getMaps(virtualCode)) {
|
|
213
217
|
const range = map.getSourceRange(info.location.range, filter);
|
|
214
218
|
if (range) {
|
|
215
219
|
relatedInfos.push({
|
|
@@ -15,7 +15,7 @@ function register(context) {
|
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
return service[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);
|
|
21
21
|
}
|