@volar/language-server 1.3.0-alpha.3 → 1.4.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/out/browser/fileSystems.js +82 -102
- package/out/browser/index.js +11 -24
- package/out/browser/typescript/core.js +1 -1
- package/out/browser/typescript/corePublic.js +2 -2
- package/out/common/cancellationPipe.js +1 -1
- package/out/common/configurationHost.js +12 -28
- package/out/common/documents.js +2 -3
- package/out/common/features/customFeatures.js +34 -47
- package/out/common/features/languageFeatures.d.ts +1 -0
- package/out/common/features/languageFeatures.js +161 -191
- package/out/common/project.d.ts +75 -85
- package/out/common/project.js +212 -227
- package/out/common/server.js +72 -112
- package/out/common/utils/inferredCompilerOptions.js +57 -61
- package/out/common/utils/registerFeatures.d.ts +2 -2
- package/out/common/utils/registerFeatures.js +27 -74
- package/out/common/utils/serverConfig.js +2 -2
- package/out/common/utils/uriMap.js +1 -1
- package/out/common/workspace.d.ts +675 -747
- package/out/common/workspace.js +164 -197
- package/out/common/workspaces.d.ts +826 -913
- package/out/common/workspaces.js +86 -106
- package/out/node/fileSystem.js +4 -14
- package/out/node/index.js +8 -19
- package/out/types.d.ts +6 -12
- package/out/types.js +1 -1
- package/package.json +4 -5
|
@@ -1,91 +1,80 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.register = void 0;
|
|
2
|
+
exports.sleep = exports.register = void 0;
|
|
12
3
|
const embedded = require("@volar/language-service");
|
|
13
4
|
const vscode = require("vscode-languageserver");
|
|
14
5
|
const protocol_1 = require("../../protocol");
|
|
15
|
-
const
|
|
6
|
+
const types_1 = require("../../types");
|
|
16
7
|
function register(connection, projects, initParams, initOptions, cancelHost, semanticTokensLegend, runtime, documents) {
|
|
17
8
|
let lastCompleteUri;
|
|
18
9
|
let lastCompleteLs;
|
|
19
10
|
let lastCodeLensLs;
|
|
20
11
|
let lastCodeActionLs;
|
|
21
12
|
let lastCallHierarchyLs;
|
|
22
|
-
connection.onDocumentFormatting((params, token) =>
|
|
13
|
+
connection.onDocumentFormatting(async (params, token) => {
|
|
23
14
|
return worker(params.textDocument.uri, token, service => {
|
|
24
|
-
return service.format(params.textDocument.uri, params.options);
|
|
15
|
+
return service.format(params.textDocument.uri, params.options, undefined, undefined, token);
|
|
25
16
|
});
|
|
26
|
-
})
|
|
27
|
-
connection.onDocumentRangeFormatting((params, token) =>
|
|
17
|
+
});
|
|
18
|
+
connection.onDocumentRangeFormatting(async (params, token) => {
|
|
28
19
|
return worker(params.textDocument.uri, token, service => {
|
|
29
|
-
return service.format(params.textDocument.uri, params.options, params.range);
|
|
20
|
+
return service.format(params.textDocument.uri, params.options, params.range, undefined, token);
|
|
30
21
|
});
|
|
31
|
-
})
|
|
32
|
-
connection.onDocumentOnTypeFormatting((params, token) =>
|
|
22
|
+
});
|
|
23
|
+
connection.onDocumentOnTypeFormatting(async (params, token) => {
|
|
33
24
|
return worker(params.textDocument.uri, token, service => {
|
|
34
|
-
return service.format(params.textDocument.uri, params.options, undefined, params);
|
|
25
|
+
return service.format(params.textDocument.uri, params.options, undefined, params, token);
|
|
35
26
|
});
|
|
36
|
-
})
|
|
37
|
-
connection.onSelectionRanges((params, token) =>
|
|
27
|
+
});
|
|
28
|
+
connection.onSelectionRanges(async (params, token) => {
|
|
38
29
|
return worker(params.textDocument.uri, token, service => {
|
|
39
|
-
return service.getSelectionRanges(params.textDocument.uri, params.positions);
|
|
30
|
+
return service.getSelectionRanges(params.textDocument.uri, params.positions, token);
|
|
40
31
|
});
|
|
41
|
-
})
|
|
42
|
-
connection.onFoldingRanges((params, token) =>
|
|
32
|
+
});
|
|
33
|
+
connection.onFoldingRanges(async (params, token) => {
|
|
43
34
|
return worker(params.textDocument.uri, token, service => {
|
|
44
|
-
return service.getFoldingRanges(params.textDocument.uri);
|
|
35
|
+
return service.getFoldingRanges(params.textDocument.uri, token);
|
|
45
36
|
});
|
|
46
|
-
})
|
|
47
|
-
connection.languages.onLinkedEditingRange((params, token) =>
|
|
37
|
+
});
|
|
38
|
+
connection.languages.onLinkedEditingRange(async (params, token) => {
|
|
48
39
|
return worker(params.textDocument.uri, token, service => {
|
|
49
|
-
return service.findLinkedEditingRanges(params.textDocument.uri, params.position);
|
|
40
|
+
return service.findLinkedEditingRanges(params.textDocument.uri, params.position, token);
|
|
50
41
|
});
|
|
51
|
-
})
|
|
52
|
-
connection.onDocumentSymbol((params, token) =>
|
|
42
|
+
});
|
|
43
|
+
connection.onDocumentSymbol(async (params, token) => {
|
|
53
44
|
return worker(params.textDocument.uri, token, service => {
|
|
54
|
-
return service.findDocumentSymbols(params.textDocument.uri);
|
|
45
|
+
return service.findDocumentSymbols(params.textDocument.uri, token);
|
|
55
46
|
});
|
|
56
|
-
})
|
|
57
|
-
connection.onDocumentColor((params, token) =>
|
|
47
|
+
});
|
|
48
|
+
connection.onDocumentColor(async (params, token) => {
|
|
58
49
|
return worker(params.textDocument.uri, token, service => {
|
|
59
|
-
return service.findDocumentColors(params.textDocument.uri);
|
|
50
|
+
return service.findDocumentColors(params.textDocument.uri, token);
|
|
60
51
|
});
|
|
61
|
-
})
|
|
62
|
-
connection.onColorPresentation((params, token) =>
|
|
52
|
+
});
|
|
53
|
+
connection.onColorPresentation(async (params, token) => {
|
|
63
54
|
return worker(params.textDocument.uri, token, service => {
|
|
64
|
-
return service.getColorPresentations(params.textDocument.uri, params.color, params.range);
|
|
55
|
+
return service.getColorPresentations(params.textDocument.uri, params.color, params.range, token);
|
|
65
56
|
});
|
|
66
|
-
})
|
|
67
|
-
connection.onCompletion((params, token) =>
|
|
68
|
-
return worker(params.textDocument.uri, token, (service) =>
|
|
69
|
-
var _a;
|
|
57
|
+
});
|
|
58
|
+
connection.onCompletion(async (params, token) => {
|
|
59
|
+
return worker(params.textDocument.uri, token, async (service) => {
|
|
70
60
|
lastCompleteUri = params.textDocument.uri;
|
|
71
61
|
lastCompleteLs = service;
|
|
72
|
-
const document =
|
|
73
|
-
const list =
|
|
62
|
+
const document = documents.data.uriGet(params.textDocument.uri)?.getDocument();
|
|
63
|
+
const list = await service.doComplete(params.textDocument.uri, params.position, params.context, token);
|
|
74
64
|
for (const item of list.items) {
|
|
75
65
|
fixTextEdit(item);
|
|
76
66
|
}
|
|
77
67
|
if (!initOptions.fullCompletionList && document) {
|
|
78
68
|
list.items = list.items.filter(item => {
|
|
79
|
-
var _a, _b;
|
|
80
69
|
const range = item.textEdit ? (vscode.InsertReplaceEdit.is(item.textEdit)
|
|
81
70
|
? item.textEdit.replace
|
|
82
|
-
: item.textEdit.range) :
|
|
71
|
+
: item.textEdit.range) : list.itemDefaults?.editRange ? (vscode.Range.is(list.itemDefaults.editRange)
|
|
83
72
|
? list.itemDefaults.editRange
|
|
84
73
|
: list.itemDefaults.editRange.replace) : undefined;
|
|
85
74
|
if (range) {
|
|
86
75
|
const sourceText = document.getText(range).toLowerCase();
|
|
87
76
|
if (sourceText.trim()) {
|
|
88
|
-
let filterText = (
|
|
77
|
+
let filterText = (item.filterText ?? item.label).toLowerCase();
|
|
89
78
|
for (const char of sourceText) {
|
|
90
79
|
const index = filterText.indexOf(char);
|
|
91
80
|
if (index === -1) {
|
|
@@ -99,50 +88,49 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
99
88
|
});
|
|
100
89
|
}
|
|
101
90
|
return list;
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
connection.onCompletionResolve((item) =>
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
connection.onCompletionResolve(async (item, token) => {
|
|
105
94
|
if (lastCompleteUri && lastCompleteLs) {
|
|
106
|
-
item =
|
|
95
|
+
item = await lastCompleteLs.doCompletionResolve(item, token);
|
|
107
96
|
fixTextEdit(item);
|
|
108
97
|
}
|
|
109
98
|
return item;
|
|
110
|
-
})
|
|
111
|
-
connection.onHover((params, token) =>
|
|
99
|
+
});
|
|
100
|
+
connection.onHover(async (params, token) => {
|
|
112
101
|
return worker(params.textDocument.uri, token, service => {
|
|
113
|
-
return service.doHover(params.textDocument.uri, params.position);
|
|
102
|
+
return service.doHover(params.textDocument.uri, params.position, token);
|
|
114
103
|
});
|
|
115
|
-
})
|
|
116
|
-
connection.onSignatureHelp((params, token) =>
|
|
104
|
+
});
|
|
105
|
+
connection.onSignatureHelp(async (params, token) => {
|
|
117
106
|
return worker(params.textDocument.uri, token, service => {
|
|
118
|
-
return service.getSignatureHelp(params.textDocument.uri, params.position, params.context);
|
|
107
|
+
return service.getSignatureHelp(params.textDocument.uri, params.position, params.context, token);
|
|
119
108
|
});
|
|
120
|
-
})
|
|
121
|
-
connection.onPrepareRename((params, token) =>
|
|
109
|
+
});
|
|
110
|
+
connection.onPrepareRename(async (params, token) => {
|
|
122
111
|
return worker(params.textDocument.uri, token, service => {
|
|
123
|
-
return service.prepareRename(params.textDocument.uri, params.position);
|
|
112
|
+
return service.prepareRename(params.textDocument.uri, params.position, token);
|
|
124
113
|
});
|
|
125
|
-
})
|
|
126
|
-
connection.onRenameRequest((params, token) =>
|
|
114
|
+
});
|
|
115
|
+
connection.onRenameRequest(async (params, token) => {
|
|
127
116
|
return worker(params.textDocument.uri, token, service => {
|
|
128
|
-
return service.doRename(params.textDocument.uri, params.position, params.newName);
|
|
117
|
+
return service.doRename(params.textDocument.uri, params.position, params.newName, token);
|
|
129
118
|
});
|
|
130
|
-
})
|
|
131
|
-
connection.onCodeLens((params, token) =>
|
|
132
|
-
return worker(params.textDocument.uri, token, (service) =>
|
|
119
|
+
});
|
|
120
|
+
connection.onCodeLens(async (params, token) => {
|
|
121
|
+
return worker(params.textDocument.uri, token, async (service) => {
|
|
133
122
|
lastCodeLensLs = service;
|
|
134
|
-
return service.doCodeLens(params.textDocument.uri);
|
|
135
|
-
})
|
|
136
|
-
})
|
|
137
|
-
connection.onCodeLensResolve((codeLens) =>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
connection.onExecuteCommand((params) => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
return service.doCodeLens(params.textDocument.uri, token);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
connection.onCodeLensResolve(async (codeLens, token) => {
|
|
127
|
+
return await lastCodeLensLs?.doCodeLensResolve(codeLens, token) ?? codeLens;
|
|
128
|
+
});
|
|
129
|
+
connection.onExecuteCommand(async (params) => {
|
|
142
130
|
if (params.command === embedded.showReferencesCommand
|
|
143
131
|
&& params.arguments) {
|
|
144
132
|
const args = params.arguments;
|
|
145
|
-
|
|
133
|
+
await connection.sendNotification(protocol_1.ShowReferencesNotification.type, {
|
|
146
134
|
textDocument: {
|
|
147
135
|
uri: args[0],
|
|
148
136
|
},
|
|
@@ -150,12 +138,11 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
150
138
|
references: args[2],
|
|
151
139
|
});
|
|
152
140
|
}
|
|
153
|
-
})
|
|
154
|
-
connection.onCodeAction((params, token) =>
|
|
155
|
-
return worker(params.textDocument.uri, token, (service) =>
|
|
156
|
-
var _c, _d, _e;
|
|
141
|
+
});
|
|
142
|
+
connection.onCodeAction(async (params, token) => {
|
|
143
|
+
return worker(params.textDocument.uri, token, async (service) => {
|
|
157
144
|
lastCodeActionLs = service;
|
|
158
|
-
let codeActions =
|
|
145
|
+
let codeActions = await service.doCodeActions(params.textDocument.uri, params.range, params.context, token) ?? [];
|
|
159
146
|
for (const codeAction of codeActions) {
|
|
160
147
|
if (codeAction.data && typeof codeAction.data === 'object') {
|
|
161
148
|
codeAction.data.uri = params.textDocument.uri;
|
|
@@ -164,105 +151,98 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
164
151
|
codeAction.data = { uri: params.textDocument.uri };
|
|
165
152
|
}
|
|
166
153
|
}
|
|
167
|
-
if (!
|
|
154
|
+
if (!initParams.capabilities.textDocument?.codeAction?.disabledSupport) {
|
|
168
155
|
codeActions = codeActions.filter(codeAction => !codeAction.disabled);
|
|
169
156
|
}
|
|
170
157
|
return codeActions;
|
|
171
|
-
}));
|
|
172
|
-
}));
|
|
173
|
-
connection.onCodeActionResolve((codeAction) => __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
var _f;
|
|
175
|
-
return (_f = yield lastCodeActionLs.doCodeActionResolve(codeAction)) !== null && _f !== void 0 ? _f : codeAction;
|
|
176
|
-
}));
|
|
177
|
-
connection.onReferences((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
return worker(params.textDocument.uri, token, service => {
|
|
179
|
-
return service.findReferences(params.textDocument.uri, params.position);
|
|
180
158
|
});
|
|
181
|
-
})
|
|
182
|
-
connection.
|
|
159
|
+
});
|
|
160
|
+
connection.onCodeActionResolve(async (codeAction, token) => {
|
|
161
|
+
return await lastCodeActionLs.doCodeActionResolve(codeAction, token) ?? codeAction;
|
|
162
|
+
});
|
|
163
|
+
connection.onReferences(async (params, token) => {
|
|
183
164
|
return worker(params.textDocument.uri, token, service => {
|
|
184
|
-
return service.
|
|
165
|
+
return service.findReferences(params.textDocument.uri, params.position, token);
|
|
185
166
|
});
|
|
186
|
-
})
|
|
187
|
-
connection.
|
|
167
|
+
});
|
|
168
|
+
connection.onRequest(protocol_1.FindFileReferenceRequest.type, async (params, token) => {
|
|
188
169
|
return worker(params.textDocument.uri, token, service => {
|
|
189
|
-
return service.
|
|
170
|
+
return service.findFileReferences(params.textDocument.uri, token);
|
|
190
171
|
});
|
|
191
|
-
})
|
|
192
|
-
connection.
|
|
172
|
+
});
|
|
173
|
+
connection.onImplementation(async (params, token) => {
|
|
193
174
|
return worker(params.textDocument.uri, token, service => {
|
|
194
|
-
return service.
|
|
175
|
+
return service.findImplementations(params.textDocument.uri, params.position, token);
|
|
195
176
|
});
|
|
196
|
-
})
|
|
197
|
-
connection.
|
|
177
|
+
});
|
|
178
|
+
connection.onDefinition(async (params, token) => {
|
|
198
179
|
return worker(params.textDocument.uri, token, service => {
|
|
199
|
-
return service.
|
|
180
|
+
return service.findDefinition(params.textDocument.uri, params.position, token);
|
|
200
181
|
});
|
|
201
|
-
})
|
|
202
|
-
connection.
|
|
182
|
+
});
|
|
183
|
+
connection.onTypeDefinition(async (params, token) => {
|
|
203
184
|
return worker(params.textDocument.uri, token, service => {
|
|
204
|
-
return service.
|
|
185
|
+
return service.findTypeDefinition(params.textDocument.uri, params.position, token);
|
|
205
186
|
});
|
|
206
|
-
})
|
|
207
|
-
connection.
|
|
187
|
+
});
|
|
188
|
+
connection.onDocumentHighlight(async (params, token) => {
|
|
208
189
|
return worker(params.textDocument.uri, token, service => {
|
|
209
|
-
return service.
|
|
190
|
+
return service.findDocumentHighlights(params.textDocument.uri, params.position, token);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
connection.onDocumentLinks(async (params, token) => {
|
|
194
|
+
return await worker(params.textDocument.uri, token, service => {
|
|
195
|
+
return service.findDocumentLinks(params.textDocument.uri, token);
|
|
210
196
|
});
|
|
211
|
-
})
|
|
212
|
-
connection.onWorkspaceSymbol((params, token) =>
|
|
197
|
+
});
|
|
198
|
+
connection.onWorkspaceSymbol(async (params, token) => {
|
|
213
199
|
let results = [];
|
|
214
200
|
for (const _workspace of projects.workspaces.values()) {
|
|
215
|
-
const workspace =
|
|
201
|
+
const workspace = await _workspace;
|
|
216
202
|
let projects = [...workspace.projects.values()];
|
|
217
203
|
projects = projects.length ? projects : [workspace.getInferredProject()];
|
|
218
204
|
for (const project of projects) {
|
|
219
205
|
if (token.isCancellationRequested)
|
|
220
206
|
return;
|
|
221
|
-
const service = (
|
|
222
|
-
results = results.concat(
|
|
207
|
+
const service = (await project).getLanguageService();
|
|
208
|
+
results = results.concat(await service.findWorkspaceSymbols(params.query, token));
|
|
223
209
|
}
|
|
224
210
|
}
|
|
225
211
|
return results;
|
|
226
|
-
})
|
|
227
|
-
connection.languages.callHierarchy.onPrepare((params, token) =>
|
|
228
|
-
|
|
229
|
-
return (_g = yield worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
});
|
|
213
|
+
connection.languages.callHierarchy.onPrepare(async (params, token) => {
|
|
214
|
+
return await worker(params.textDocument.uri, token, async (service) => {
|
|
230
215
|
lastCallHierarchyLs = service;
|
|
231
|
-
return service.callHierarchy.doPrepare(params.textDocument.uri, params.position);
|
|
232
|
-
})
|
|
233
|
-
})
|
|
234
|
-
connection.languages.callHierarchy.onIncomingCalls((params) =>
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return (_m = yield worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
255
|
-
var _o;
|
|
256
|
-
const result = (_o = yield (service === null || service === void 0 ? void 0 : service.getSemanticTokens(params.textDocument.uri, params.range, semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _o !== void 0 ? _o : [];
|
|
257
|
-
return buildTokens(result);
|
|
258
|
-
}))) !== null && _m !== void 0 ? _m : buildTokens([]);
|
|
259
|
-
}));
|
|
260
|
-
connection.languages.diagnostics.on((params, token, _workDoneProgressReporter, resultProgressReporter) => __awaiter(this, void 0, void 0, function* () {
|
|
261
|
-
const result = yield worker(params.textDocument.uri, token, service => {
|
|
216
|
+
return service.callHierarchy.doPrepare(params.textDocument.uri, params.position, token);
|
|
217
|
+
}) ?? [];
|
|
218
|
+
});
|
|
219
|
+
connection.languages.callHierarchy.onIncomingCalls(async (params, token) => {
|
|
220
|
+
return await lastCallHierarchyLs?.callHierarchy.getIncomingCalls(params.item, token) ?? [];
|
|
221
|
+
});
|
|
222
|
+
connection.languages.callHierarchy.onOutgoingCalls(async (params, token) => {
|
|
223
|
+
return await lastCallHierarchyLs?.callHierarchy.getOutgoingCalls(params.item, token) ?? [];
|
|
224
|
+
});
|
|
225
|
+
connection.languages.semanticTokens.on(async (params, token, _, resultProgress) => {
|
|
226
|
+
await sleep(200);
|
|
227
|
+
return await worker(params.textDocument.uri, token, async (service) => {
|
|
228
|
+
return await service?.getSemanticTokens(params.textDocument.uri, undefined, semanticTokensLegend, token, tokens => resultProgress?.report(tokens));
|
|
229
|
+
}) ?? { data: [] };
|
|
230
|
+
});
|
|
231
|
+
connection.languages.semanticTokens.onRange(async (params, token, _, resultProgress) => {
|
|
232
|
+
await sleep(200);
|
|
233
|
+
return await worker(params.textDocument.uri, token, async (service) => {
|
|
234
|
+
return await service?.getSemanticTokens(params.textDocument.uri, params.range, semanticTokensLegend, token, tokens => resultProgress?.report(tokens));
|
|
235
|
+
}) ?? { data: [] };
|
|
236
|
+
});
|
|
237
|
+
connection.languages.diagnostics.on(async (params, token, _workDoneProgressReporter, resultProgressReporter) => {
|
|
238
|
+
const result = await worker(params.textDocument.uri, token, service => {
|
|
262
239
|
const tsToken = cancelHost.createCancellationToken(token);
|
|
263
|
-
|
|
240
|
+
const mode = initOptions.serverMode === types_1.ServerMode.PartialSemantic ? 'semantic'
|
|
241
|
+
: initOptions.serverMode === types_1.ServerMode.Syntactic ? 'syntactic'
|
|
242
|
+
: 'all';
|
|
243
|
+
return service.doValidation(params.textDocument.uri, tsToken, mode, errors => {
|
|
264
244
|
// resultProgressReporter is undefined in vscode
|
|
265
|
-
resultProgressReporter
|
|
245
|
+
resultProgressReporter?.report({
|
|
266
246
|
relatedDocuments: {
|
|
267
247
|
[params.textDocument.uri]: {
|
|
268
248
|
kind: vscode.DocumentDiagnosticReportKind.Full,
|
|
@@ -274,57 +254,55 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
274
254
|
});
|
|
275
255
|
return {
|
|
276
256
|
kind: vscode.DocumentDiagnosticReportKind.Full,
|
|
277
|
-
items: result
|
|
257
|
+
items: result ?? [],
|
|
278
258
|
};
|
|
279
|
-
})
|
|
280
|
-
connection.languages.inlayHint.on((params, token) =>
|
|
281
|
-
return worker(params.textDocument.uri, token, (service) =>
|
|
282
|
-
return service.getInlayHints(params.textDocument.uri, params.range);
|
|
283
|
-
})
|
|
284
|
-
})
|
|
259
|
+
});
|
|
260
|
+
connection.languages.inlayHint.on(async (params, token) => {
|
|
261
|
+
return worker(params.textDocument.uri, token, async (service) => {
|
|
262
|
+
return service.getInlayHints(params.textDocument.uri, params.range, token);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
285
265
|
// TODO: connection.languages.inlayHint.resolve
|
|
286
|
-
connection.workspace.onWillRenameFiles((params, token) =>
|
|
287
|
-
const config =
|
|
266
|
+
connection.workspace.onWillRenameFiles(async (params, token) => {
|
|
267
|
+
const config = await connection.workspace.getConfiguration('volar.updateImportsOnFileMove.enabled');
|
|
288
268
|
if (!config) {
|
|
289
269
|
return null;
|
|
290
270
|
}
|
|
291
|
-
const _edits =
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
})));
|
|
298
|
-
const edits = _edits.filter(shared.notEmpty);
|
|
271
|
+
const _edits = await Promise.all(params.files.map(async (file) => {
|
|
272
|
+
return await worker(file.oldUri, token, service => {
|
|
273
|
+
return service.getEditsForFileRename(file.oldUri, file.newUri, token) ?? null;
|
|
274
|
+
}) ?? null;
|
|
275
|
+
}));
|
|
276
|
+
const edits = _edits.filter((edit) => !!edit);
|
|
299
277
|
if (edits.length) {
|
|
300
278
|
embedded.mergeWorkspaceEdits(edits[0], ...edits.slice(1));
|
|
301
279
|
return edits[0];
|
|
302
280
|
}
|
|
303
281
|
return null;
|
|
304
|
-
})
|
|
305
|
-
connection.onRequest(protocol_1.AutoInsertRequest.type, (params, token) =>
|
|
282
|
+
});
|
|
283
|
+
connection.onRequest(protocol_1.AutoInsertRequest.type, async (params, token) => {
|
|
306
284
|
return worker(params.textDocument.uri, token, service => {
|
|
307
|
-
return service.doAutoInsert(params.textDocument.uri, params.position, params.options);
|
|
285
|
+
return service.doAutoInsert(params.textDocument.uri, params.position, params.options, token);
|
|
308
286
|
});
|
|
309
|
-
})
|
|
287
|
+
});
|
|
310
288
|
function worker(uri, token, cb) {
|
|
311
289
|
return new Promise(resolve => {
|
|
312
|
-
runtime.timer.setImmediate(() =>
|
|
290
|
+
runtime.timer.setImmediate(async () => {
|
|
313
291
|
if (token.isCancellationRequested) {
|
|
314
292
|
resolve(undefined);
|
|
315
293
|
return;
|
|
316
294
|
}
|
|
317
|
-
const service =
|
|
295
|
+
const service = await getLanguageService(uri);
|
|
318
296
|
if (service) {
|
|
319
297
|
try { // handle TS cancel throw
|
|
320
|
-
const result =
|
|
298
|
+
const result = await cb(service);
|
|
321
299
|
if (token.isCancellationRequested) {
|
|
322
300
|
resolve(undefined);
|
|
323
301
|
return;
|
|
324
302
|
}
|
|
325
303
|
resolve(result);
|
|
326
304
|
}
|
|
327
|
-
catch
|
|
305
|
+
catch {
|
|
328
306
|
resolve(undefined);
|
|
329
307
|
return;
|
|
330
308
|
}
|
|
@@ -332,27 +310,15 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
332
310
|
else {
|
|
333
311
|
resolve(undefined);
|
|
334
312
|
}
|
|
335
|
-
})
|
|
313
|
+
});
|
|
336
314
|
});
|
|
337
315
|
}
|
|
338
|
-
function
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
for (const token of sortedTokens) {
|
|
342
|
-
builder.push(...token);
|
|
343
|
-
}
|
|
344
|
-
return builder.build();
|
|
345
|
-
}
|
|
346
|
-
function getLanguageService(uri) {
|
|
347
|
-
var _a;
|
|
348
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
349
|
-
const project = (_a = (yield projects.getProject(uri))) === null || _a === void 0 ? void 0 : _a.project;
|
|
350
|
-
return project === null || project === void 0 ? void 0 : project.getLanguageService();
|
|
351
|
-
});
|
|
316
|
+
async function getLanguageService(uri) {
|
|
317
|
+
const project = (await projects.getProject(uri))?.project;
|
|
318
|
+
return project?.getLanguageService();
|
|
352
319
|
}
|
|
353
320
|
function fixTextEdit(item) {
|
|
354
|
-
|
|
355
|
-
const insertReplaceSupport = (_d = (_c = (_b = (_a = initParams.capabilities.textDocument) === null || _a === void 0 ? void 0 : _a.completion) === null || _b === void 0 ? void 0 : _b.completionItem) === null || _c === void 0 ? void 0 : _c.insertReplaceSupport) !== null && _d !== void 0 ? _d : false;
|
|
321
|
+
const insertReplaceSupport = initParams.capabilities.textDocument?.completion?.completionItem?.insertReplaceSupport ?? false;
|
|
356
322
|
if (!insertReplaceSupport) {
|
|
357
323
|
if (item.textEdit && vscode.InsertReplaceEdit.is(item.textEdit)) {
|
|
358
324
|
item.textEdit = vscode.TextEdit.replace(item.textEdit.insert, item.textEdit.newText);
|
|
@@ -361,4 +327,8 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
361
327
|
}
|
|
362
328
|
}
|
|
363
329
|
exports.register = register;
|
|
330
|
+
function sleep(ms) {
|
|
331
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
332
|
+
}
|
|
333
|
+
exports.sleep = sleep;
|
|
364
334
|
//# sourceMappingURL=languageFeatures.js.map
|