@volar/language-server 1.1.0-alpha.2 → 1.2.0-alpha.10
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/common/features/customFeatures.js +1 -1
- package/out/common/features/languageFeatures.js +78 -81
- package/out/common/project.d.ts +5 -7
- package/out/common/project.js +30 -35
- package/out/common/utils/registerFeatures.js +9 -9
- package/out/common/utils/serverConfig.d.ts +2 -5
- package/out/common/utils/serverConfig.js +3 -3
- package/out/common/workspace.d.ts +27 -45
- package/out/common/workspace.js +1 -1
- package/out/common/workspaces.d.ts +34 -56
- package/out/common/workspaces.js +2 -11
- package/out/types.d.ts +10 -5
- package/package.json +10 -10
|
@@ -78,7 +78,7 @@ function register(connection, projects) {
|
|
|
78
78
|
const rootVirtualFile = (_q = (_p = project.project) === null || _p === void 0 ? void 0 : _p.getLanguageService().context.core.virtualFiles.getSource(shared.uriToFileName(document.uri))) === null || _q === void 0 ? void 0 : _q.root;
|
|
79
79
|
if (rootVirtualFile) {
|
|
80
80
|
(0, language_core_1.forEachEmbeddedFile)(rootVirtualFile, e => {
|
|
81
|
-
if (e.snapshot.getLength() && e.kind === language_core_1.FileKind.TypeScriptHostFile) {
|
|
81
|
+
if (e.snapshot.getLength() && e.kind === language_core_1.FileKind.TypeScriptHostFile && e.capabilities.diagnostic) {
|
|
82
82
|
fileNames.push(e.fileName);
|
|
83
83
|
}
|
|
84
84
|
});
|
|
@@ -20,55 +20,55 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
20
20
|
let lastCodeActionLs;
|
|
21
21
|
let lastCallHierarchyLs;
|
|
22
22
|
connection.onDocumentFormatting((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
return worker(params.textDocument.uri, token,
|
|
24
|
-
return
|
|
23
|
+
return worker(params.textDocument.uri, token, service => {
|
|
24
|
+
return service.format(params.textDocument.uri, params.options);
|
|
25
25
|
});
|
|
26
26
|
}));
|
|
27
27
|
connection.onDocumentRangeFormatting((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
return worker(params.textDocument.uri, token,
|
|
29
|
-
return
|
|
28
|
+
return worker(params.textDocument.uri, token, service => {
|
|
29
|
+
return service.format(params.textDocument.uri, params.options, params.range);
|
|
30
30
|
});
|
|
31
31
|
}));
|
|
32
32
|
connection.onDocumentOnTypeFormatting((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
return worker(params.textDocument.uri, token,
|
|
34
|
-
return
|
|
33
|
+
return worker(params.textDocument.uri, token, service => {
|
|
34
|
+
return service.format(params.textDocument.uri, params.options, undefined, params);
|
|
35
35
|
});
|
|
36
36
|
}));
|
|
37
37
|
connection.onSelectionRanges((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
return worker(params.textDocument.uri, token,
|
|
39
|
-
return
|
|
38
|
+
return worker(params.textDocument.uri, token, service => {
|
|
39
|
+
return service.getSelectionRanges(params.textDocument.uri, params.positions);
|
|
40
40
|
});
|
|
41
41
|
}));
|
|
42
42
|
connection.onFoldingRanges((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
return worker(params.textDocument.uri, token,
|
|
44
|
-
return
|
|
43
|
+
return worker(params.textDocument.uri, token, service => {
|
|
44
|
+
return service.getFoldingRanges(params.textDocument.uri);
|
|
45
45
|
});
|
|
46
46
|
}));
|
|
47
47
|
connection.languages.onLinkedEditingRange((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
return worker(params.textDocument.uri, token,
|
|
49
|
-
return
|
|
48
|
+
return worker(params.textDocument.uri, token, service => {
|
|
49
|
+
return service.findLinkedEditingRanges(params.textDocument.uri, params.position);
|
|
50
50
|
});
|
|
51
51
|
}));
|
|
52
52
|
connection.onDocumentSymbol((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
return worker(params.textDocument.uri, token,
|
|
54
|
-
return
|
|
53
|
+
return worker(params.textDocument.uri, token, service => {
|
|
54
|
+
return service.findDocumentSymbols(params.textDocument.uri);
|
|
55
55
|
});
|
|
56
56
|
}));
|
|
57
57
|
connection.onDocumentColor((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
return worker(params.textDocument.uri, token,
|
|
59
|
-
return
|
|
58
|
+
return worker(params.textDocument.uri, token, service => {
|
|
59
|
+
return service.findDocumentColors(params.textDocument.uri);
|
|
60
60
|
});
|
|
61
61
|
}));
|
|
62
62
|
connection.onColorPresentation((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
return worker(params.textDocument.uri, token,
|
|
64
|
-
return
|
|
63
|
+
return worker(params.textDocument.uri, token, service => {
|
|
64
|
+
return service.getColorPresentations(params.textDocument.uri, params.color, params.range);
|
|
65
65
|
});
|
|
66
66
|
}));
|
|
67
67
|
connection.onCompletion((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return worker(params.textDocument.uri, token, (
|
|
68
|
+
return worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
69
69
|
lastCompleteUri = params.textDocument.uri;
|
|
70
|
-
lastCompleteLs =
|
|
71
|
-
const list = yield
|
|
70
|
+
lastCompleteLs = service;
|
|
71
|
+
const list = yield service.doComplete(params.textDocument.uri, params.position, params.context);
|
|
72
72
|
if (list) {
|
|
73
73
|
for (const item of list.items) {
|
|
74
74
|
fixTextEdit(item);
|
|
@@ -85,56 +85,53 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
85
85
|
return item;
|
|
86
86
|
}));
|
|
87
87
|
connection.onHover((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
return worker(params.textDocument.uri, token,
|
|
89
|
-
return
|
|
88
|
+
return worker(params.textDocument.uri, token, service => {
|
|
89
|
+
return service.doHover(params.textDocument.uri, params.position);
|
|
90
90
|
});
|
|
91
91
|
}));
|
|
92
92
|
connection.onSignatureHelp((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return worker(params.textDocument.uri, token,
|
|
94
|
-
return
|
|
93
|
+
return worker(params.textDocument.uri, token, service => {
|
|
94
|
+
return service.getSignatureHelp(params.textDocument.uri, params.position, params.context);
|
|
95
95
|
});
|
|
96
96
|
}));
|
|
97
97
|
connection.onPrepareRename((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
return worker(params.textDocument.uri, token,
|
|
99
|
-
return
|
|
98
|
+
return worker(params.textDocument.uri, token, service => {
|
|
99
|
+
return service.prepareRename(params.textDocument.uri, params.position);
|
|
100
100
|
});
|
|
101
101
|
}));
|
|
102
102
|
connection.onRenameRequest((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
return worker(params.textDocument.uri, token,
|
|
104
|
-
return
|
|
103
|
+
return worker(params.textDocument.uri, token, service => {
|
|
104
|
+
return service.doRename(params.textDocument.uri, params.position, params.newName);
|
|
105
105
|
});
|
|
106
106
|
}));
|
|
107
107
|
connection.onCodeLens((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
return worker(params.textDocument.uri, token, (
|
|
109
|
-
lastCodeLensLs =
|
|
110
|
-
return
|
|
108
|
+
return worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
lastCodeLensLs = service;
|
|
110
|
+
return service.doCodeLens(params.textDocument.uri);
|
|
111
111
|
}));
|
|
112
112
|
}));
|
|
113
113
|
connection.onCodeLensResolve((codeLens) => __awaiter(this, void 0, void 0, function* () {
|
|
114
114
|
var _a;
|
|
115
115
|
return (_a = yield (lastCodeLensLs === null || lastCodeLensLs === void 0 ? void 0 : lastCodeLensLs.doCodeLensResolve(codeLens))) !== null && _a !== void 0 ? _a : codeLens;
|
|
116
116
|
}));
|
|
117
|
-
connection.onExecuteCommand((params
|
|
118
|
-
if (params.command === embedded.
|
|
117
|
+
connection.onExecuteCommand((params) => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
if (params.command === embedded.showReferencesCommand
|
|
119
|
+
&& params.arguments) {
|
|
119
120
|
const args = params.arguments;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
workDoneProgress,
|
|
127
|
-
applyEdit: (paramOrEdit) => connection.workspace.applyEdit(paramOrEdit),
|
|
128
|
-
showReferences: (params) => connection.sendNotification(protocol_1.ShowReferencesNotification.type, params),
|
|
129
|
-
});
|
|
121
|
+
yield connection.sendNotification(protocol_1.ShowReferencesNotification.type, {
|
|
122
|
+
textDocument: {
|
|
123
|
+
uri: args[0],
|
|
124
|
+
},
|
|
125
|
+
position: args[1],
|
|
126
|
+
references: args[2],
|
|
130
127
|
});
|
|
131
128
|
}
|
|
132
129
|
}));
|
|
133
130
|
connection.onCodeAction((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
return worker(params.textDocument.uri, token, (
|
|
131
|
+
return worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
135
132
|
var _b, _c, _d;
|
|
136
|
-
lastCodeActionLs =
|
|
137
|
-
let codeActions = (_b = yield
|
|
133
|
+
lastCodeActionLs = service;
|
|
134
|
+
let codeActions = (_b = yield service.doCodeActions(params.textDocument.uri, params.range, params.context)) !== null && _b !== void 0 ? _b : [];
|
|
138
135
|
for (const codeAction of codeActions) {
|
|
139
136
|
if (codeAction.data && typeof codeAction.data === 'object') {
|
|
140
137
|
codeAction.data.uri = params.textDocument.uri;
|
|
@@ -154,38 +151,38 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
154
151
|
return (_e = yield lastCodeActionLs.doCodeActionResolve(codeAction)) !== null && _e !== void 0 ? _e : codeAction;
|
|
155
152
|
}));
|
|
156
153
|
connection.onReferences((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
return worker(params.textDocument.uri, token,
|
|
158
|
-
return
|
|
154
|
+
return worker(params.textDocument.uri, token, service => {
|
|
155
|
+
return service.findReferences(params.textDocument.uri, params.position);
|
|
159
156
|
});
|
|
160
157
|
}));
|
|
161
158
|
connection.onRequest(protocol_1.FindFileReferenceRequest.type, (params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
return worker(params.textDocument.uri, token,
|
|
163
|
-
return
|
|
159
|
+
return worker(params.textDocument.uri, token, service => {
|
|
160
|
+
return service.findFileReferences(params.textDocument.uri);
|
|
164
161
|
});
|
|
165
162
|
}));
|
|
166
163
|
connection.onImplementation((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
return worker(params.textDocument.uri, token,
|
|
168
|
-
return
|
|
164
|
+
return worker(params.textDocument.uri, token, service => {
|
|
165
|
+
return service.findImplementations(params.textDocument.uri, params.position);
|
|
169
166
|
});
|
|
170
167
|
}));
|
|
171
168
|
connection.onDefinition((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
return worker(params.textDocument.uri, token,
|
|
173
|
-
return
|
|
169
|
+
return worker(params.textDocument.uri, token, service => {
|
|
170
|
+
return service.findDefinition(params.textDocument.uri, params.position);
|
|
174
171
|
});
|
|
175
172
|
}));
|
|
176
173
|
connection.onTypeDefinition((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
return worker(params.textDocument.uri, token,
|
|
178
|
-
return
|
|
174
|
+
return worker(params.textDocument.uri, token, service => {
|
|
175
|
+
return service.findTypeDefinition(params.textDocument.uri, params.position);
|
|
179
176
|
});
|
|
180
177
|
}));
|
|
181
178
|
connection.onDocumentHighlight((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
return worker(params.textDocument.uri, token,
|
|
183
|
-
return
|
|
179
|
+
return worker(params.textDocument.uri, token, service => {
|
|
180
|
+
return service.findDocumentHighlights(params.textDocument.uri, params.position);
|
|
184
181
|
});
|
|
185
182
|
}));
|
|
186
183
|
connection.onDocumentLinks((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
return worker(params.textDocument.uri, token,
|
|
188
|
-
return
|
|
184
|
+
return worker(params.textDocument.uri, token, service => {
|
|
185
|
+
return service.findDocumentLinks(params.textDocument.uri);
|
|
189
186
|
});
|
|
190
187
|
}));
|
|
191
188
|
connection.onWorkspaceSymbol((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -197,17 +194,17 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
197
194
|
for (const project of projects) {
|
|
198
195
|
if (token.isCancellationRequested)
|
|
199
196
|
return;
|
|
200
|
-
const
|
|
201
|
-
results = results.concat(yield
|
|
197
|
+
const service = (yield project).getLanguageService();
|
|
198
|
+
results = results.concat(yield service.findWorkspaceSymbols(params.query));
|
|
202
199
|
}
|
|
203
200
|
}
|
|
204
201
|
return results;
|
|
205
202
|
}));
|
|
206
203
|
connection.languages.callHierarchy.onPrepare((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
207
204
|
var _f;
|
|
208
|
-
return (_f = yield worker(params.textDocument.uri, token, (
|
|
209
|
-
lastCallHierarchyLs =
|
|
210
|
-
return
|
|
205
|
+
return (_f = yield worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
lastCallHierarchyLs = service;
|
|
207
|
+
return service.callHierarchy.doPrepare(params.textDocument.uri, params.position);
|
|
211
208
|
}))) !== null && _f !== void 0 ? _f : [];
|
|
212
209
|
}));
|
|
213
210
|
connection.languages.callHierarchy.onIncomingCalls((params) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -221,25 +218,25 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
221
218
|
connection.languages.semanticTokens.on((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
|
|
222
219
|
var _j;
|
|
223
220
|
yield shared.sleep(200);
|
|
224
|
-
return (_j = yield worker(params.textDocument.uri, token, (
|
|
221
|
+
return (_j = yield worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
225
222
|
var _k;
|
|
226
|
-
const result = (_k = yield (
|
|
223
|
+
const result = (_k = yield (service === null || service === void 0 ? void 0 : service.getSemanticTokens(params.textDocument.uri, undefined, semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _k !== void 0 ? _k : [];
|
|
227
224
|
return buildTokens(result);
|
|
228
225
|
}))) !== null && _j !== void 0 ? _j : buildTokens([]);
|
|
229
226
|
}));
|
|
230
227
|
connection.languages.semanticTokens.onRange((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
|
|
231
228
|
var _l;
|
|
232
229
|
yield shared.sleep(200);
|
|
233
|
-
return (_l = yield worker(params.textDocument.uri, token, (
|
|
230
|
+
return (_l = yield worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
234
231
|
var _m;
|
|
235
|
-
const result = (_m = yield (
|
|
232
|
+
const result = (_m = 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 && _m !== void 0 ? _m : [];
|
|
236
233
|
return buildTokens(result);
|
|
237
234
|
}))) !== null && _l !== void 0 ? _l : buildTokens([]);
|
|
238
235
|
}));
|
|
239
236
|
connection.languages.diagnostics.on((params, token, _workDoneProgressReporter, resultProgressReporter) => __awaiter(this, void 0, void 0, function* () {
|
|
240
|
-
const result = yield worker(params.textDocument.uri, token,
|
|
237
|
+
const result = yield worker(params.textDocument.uri, token, service => {
|
|
241
238
|
const tsToken = cancelHost.createCancellationToken(token);
|
|
242
|
-
return
|
|
239
|
+
return service.doValidation(params.textDocument.uri, tsToken, errors => {
|
|
243
240
|
// resultProgressReporter is undefined in vscode
|
|
244
241
|
resultProgressReporter === null || resultProgressReporter === void 0 ? void 0 : resultProgressReporter.report({
|
|
245
242
|
relatedDocuments: {
|
|
@@ -257,8 +254,8 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
257
254
|
};
|
|
258
255
|
}));
|
|
259
256
|
connection.languages.inlayHint.on((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
260
|
-
return worker(params.textDocument.uri, token, (
|
|
261
|
-
return
|
|
257
|
+
return worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
258
|
+
return service.getInlayHints(params.textDocument.uri, params.range);
|
|
262
259
|
}));
|
|
263
260
|
}));
|
|
264
261
|
// TODO: connection.languages.inlayHint.resolve
|
|
@@ -269,9 +266,9 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
269
266
|
}
|
|
270
267
|
const _edits = yield Promise.all(params.files.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
271
268
|
var _o;
|
|
272
|
-
return (_o = yield worker(file.oldUri, token,
|
|
269
|
+
return (_o = yield worker(file.oldUri, token, service => {
|
|
273
270
|
var _a;
|
|
274
|
-
return (_a =
|
|
271
|
+
return (_a = service.getEditsForFileRename(file.oldUri, file.newUri)) !== null && _a !== void 0 ? _a : null;
|
|
275
272
|
})) !== null && _o !== void 0 ? _o : null;
|
|
276
273
|
})));
|
|
277
274
|
const edits = _edits.filter(shared.notEmpty);
|
|
@@ -282,8 +279,8 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
282
279
|
return null;
|
|
283
280
|
}));
|
|
284
281
|
connection.onRequest(protocol_1.AutoInsertRequest.type, (params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
285
|
-
return worker(params.textDocument.uri, token,
|
|
286
|
-
return
|
|
282
|
+
return worker(params.textDocument.uri, token, service => {
|
|
283
|
+
return service.doAutoInsert(params.textDocument.uri, params.position, params.options);
|
|
287
284
|
});
|
|
288
285
|
}));
|
|
289
286
|
function worker(uri, token, cb) {
|
|
@@ -293,10 +290,10 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
293
290
|
resolve(undefined);
|
|
294
291
|
return;
|
|
295
292
|
}
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
293
|
+
const service = yield getLanguageService(uri);
|
|
294
|
+
if (service) {
|
|
298
295
|
try { // handle TS cancel throw
|
|
299
|
-
const result = yield cb(
|
|
296
|
+
const result = yield cb(service);
|
|
300
297
|
if (token.isCancellationRequested) {
|
|
301
298
|
resolve(undefined);
|
|
302
299
|
return;
|
package/out/common/project.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import * as embedded from '@volar/language-core';
|
|
2
2
|
import * as embeddedLS from '@volar/language-service';
|
|
3
|
+
import { Config } from '@volar/language-service';
|
|
3
4
|
import * as path from 'typesafe-path';
|
|
4
5
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
5
6
|
import { URI } from 'vscode-uri';
|
|
6
7
|
import { WorkspaceContext } from './workspace';
|
|
7
|
-
import { ServerConfig } from './utils/serverConfig';
|
|
8
8
|
export interface ProjectContext {
|
|
9
9
|
workspace: WorkspaceContext;
|
|
10
10
|
rootUri: URI;
|
|
11
11
|
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
12
12
|
documentRegistry: ts.DocumentRegistry | undefined;
|
|
13
|
-
serverConfig:
|
|
13
|
+
serverConfig: Config | undefined;
|
|
14
14
|
}
|
|
15
15
|
export type Project = ReturnType<typeof createProject>;
|
|
16
16
|
export declare function createProject(context: ProjectContext): Promise<{
|
|
17
|
-
tsConfig:
|
|
17
|
+
tsConfig: ts.CompilerOptions | path.PosixPath;
|
|
18
18
|
scripts: {
|
|
19
19
|
clear: () => void;
|
|
20
20
|
values: () => IterableIterator<{
|
|
@@ -98,7 +98,6 @@ export declare function createProject(context: ProjectContext): Promise<{
|
|
|
98
98
|
text: string;
|
|
99
99
|
};
|
|
100
100
|
}) => Promise<NonNullable<string | embeddedLS.TextEdit | null | undefined> | undefined>;
|
|
101
|
-
doExecuteCommand: (command: string, args: embeddedLS.ExecutePluginCommandArgs, executeCommandContext: embeddedLS.ExecuteCommandContext) => Promise<void>;
|
|
102
101
|
getInlayHints: (uri: string, range: embeddedLS.Range) => Promise<embeddedLS.InlayHint[] | undefined>;
|
|
103
102
|
callHierarchy: {
|
|
104
103
|
doPrepare(uri: string, position: embeddedLS.Position): Promise<embeddedLS.CallHierarchyItem[] | undefined>;
|
|
@@ -106,7 +105,7 @@ export declare function createProject(context: ProjectContext): Promise<{
|
|
|
106
105
|
getOutgoingCalls(item: embeddedLS.CallHierarchyItem): Promise<embeddedLS.CallHierarchyOutgoingCall[]>;
|
|
107
106
|
};
|
|
108
107
|
dispose: () => void | undefined;
|
|
109
|
-
context: embeddedLS.
|
|
108
|
+
context: embeddedLS.LanguageServicePluginContext;
|
|
110
109
|
};
|
|
111
110
|
getLanguageServiceDontCreate: () => {
|
|
112
111
|
format: (uri: string, options: embeddedLS.FormattingOptions, range?: embeddedLS.Range | undefined, onTypeParams?: {
|
|
@@ -148,7 +147,6 @@ export declare function createProject(context: ProjectContext): Promise<{
|
|
|
148
147
|
text: string;
|
|
149
148
|
};
|
|
150
149
|
}) => Promise<NonNullable<string | embeddedLS.TextEdit | null | undefined> | undefined>;
|
|
151
|
-
doExecuteCommand: (command: string, args: embeddedLS.ExecutePluginCommandArgs, executeCommandContext: embeddedLS.ExecuteCommandContext) => Promise<void>;
|
|
152
150
|
getInlayHints: (uri: string, range: embeddedLS.Range) => Promise<embeddedLS.InlayHint[] | undefined>;
|
|
153
151
|
callHierarchy: {
|
|
154
152
|
doPrepare(uri: string, position: embeddedLS.Position): Promise<embeddedLS.CallHierarchyItem[] | undefined>;
|
|
@@ -156,7 +154,7 @@ export declare function createProject(context: ProjectContext): Promise<{
|
|
|
156
154
|
getOutgoingCalls(item: embeddedLS.CallHierarchyItem): Promise<embeddedLS.CallHierarchyOutgoingCall[]>;
|
|
157
155
|
};
|
|
158
156
|
dispose: () => void | undefined;
|
|
159
|
-
context: embeddedLS.
|
|
157
|
+
context: embeddedLS.LanguageServicePluginContext;
|
|
160
158
|
} | undefined;
|
|
161
159
|
getParsedCommandLine: () => ts.ParsedCommandLine;
|
|
162
160
|
tryAddFile: (fileName: string) => void;
|
package/out/common/project.js
CHANGED
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.createProject = void 0;
|
|
12
|
-
const embedded = require("@volar/language-core");
|
|
13
12
|
const embeddedLS = require("@volar/language-service");
|
|
14
13
|
const shared = require("@volar/shared");
|
|
15
14
|
const path = require("typesafe-path");
|
|
@@ -63,37 +62,38 @@ function createProject(context) {
|
|
|
63
62
|
dispose,
|
|
64
63
|
};
|
|
65
64
|
function getLanguageService() {
|
|
65
|
+
var _a, _b, _c, _d, _e, _f;
|
|
66
66
|
if (!languageService) {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const config = {
|
|
68
|
+
languages: Object.assign({}, (_a = context.serverConfig) === null || _a === void 0 ? void 0 : _a.languages),
|
|
69
|
+
plugins: Object.assign({}, (_b = context.serverConfig) === null || _b === void 0 ? void 0 : _b.plugins),
|
|
70
|
+
lint: Object.assign(Object.assign({}, (_c = context.serverConfig) === null || _c === void 0 ? void 0 : _c.lint), { rules: Object.assign({}, (_e = (_d = context.serverConfig) === null || _d === void 0 ? void 0 : _d.lint) === null || _e === void 0 ? void 0 : _e.rules) }),
|
|
71
|
+
};
|
|
72
|
+
const env = {
|
|
73
|
+
rootUri: context.rootUri,
|
|
74
|
+
locale: context.workspace.workspaces.initParams.locale,
|
|
75
|
+
configurationHost: context.workspace.workspaces.configurationHost,
|
|
76
|
+
fileSystemProvider: context.workspace.workspaces.server.runtimeEnv.fileSystemProvide,
|
|
77
|
+
documentContext: getDocumentContext(context.workspace.workspaces.ts, languageServiceHost, context.rootUri.toString()),
|
|
78
|
+
schemaRequestService: (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const protocol = uri.substring(0, uri.indexOf(':'));
|
|
80
|
+
const builtInHandler = context.workspace.workspaces.server.runtimeEnv.schemaRequestHandlers[protocol];
|
|
81
|
+
if (builtInHandler) {
|
|
82
|
+
return yield builtInHandler(uri);
|
|
83
|
+
}
|
|
84
|
+
return '';
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
const lsCtx = {
|
|
88
|
+
project: context,
|
|
89
|
+
env,
|
|
90
|
+
sys,
|
|
70
91
|
host: languageServiceHost,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
...context.workspace.workspaces.plugins.map(plugin => { var _a, _b; return (_b = (_a = plugin.getLanguageServicePlugins) === null || _a === void 0 ? void 0 : _a.call(plugin, languageServiceHost, languageServiceContext)) !== null && _b !== void 0 ? _b : []; }).flat(),
|
|
77
|
-
];
|
|
78
|
-
},
|
|
79
|
-
env: {
|
|
80
|
-
rootUri: context.rootUri,
|
|
81
|
-
configurationHost: context.workspace.workspaces.configurationHost,
|
|
82
|
-
fileSystemProvider: context.workspace.workspaces.server.runtimeEnv.fileSystemProvide,
|
|
83
|
-
documentContext: getDocumentContext(context.workspace.workspaces.ts, languageServiceHost, context.rootUri.toString()),
|
|
84
|
-
schemaRequestService: (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const protocol = uri.substring(0, uri.indexOf(':'));
|
|
86
|
-
const builtInHandler = context.workspace.workspaces.server.runtimeEnv.schemaRequestHandlers[protocol];
|
|
87
|
-
if (builtInHandler) {
|
|
88
|
-
return yield builtInHandler(uri);
|
|
89
|
-
}
|
|
90
|
-
return '';
|
|
91
|
-
}),
|
|
92
|
-
},
|
|
93
|
-
documentRegistry: context.documentRegistry,
|
|
94
|
-
getLanguageService: () => languageService,
|
|
95
|
-
});
|
|
96
|
-
languageService = embeddedLS.createLanguageService(languageServiceContext);
|
|
92
|
+
};
|
|
93
|
+
for (const plugin of context.workspace.workspaces.plugins) {
|
|
94
|
+
(_f = plugin.resolveConfig) === null || _f === void 0 ? void 0 : _f.call(plugin, config, lsCtx);
|
|
95
|
+
}
|
|
96
|
+
languageService = embeddedLS.createLanguageService(languageServiceHost, config, env, context.documentRegistry);
|
|
97
97
|
}
|
|
98
98
|
return languageService;
|
|
99
99
|
}
|
|
@@ -184,11 +184,6 @@ function createProject(context) {
|
|
|
184
184
|
if (context.workspace.workspaces.tsLocalized) {
|
|
185
185
|
host.getLocalizedDiagnosticMessages = () => context.workspace.workspaces.tsLocalized;
|
|
186
186
|
}
|
|
187
|
-
for (const plugin of context.workspace.workspaces.plugins) {
|
|
188
|
-
if (context.workspace.workspaces.ts && plugin.resolveLanguageServiceHost) {
|
|
189
|
-
host = plugin.resolveLanguageServiceHost(context.workspace.workspaces.ts, sys, context.tsConfig, host);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
187
|
return host;
|
|
193
188
|
function getScriptVersion(fileName) {
|
|
194
189
|
var _a, _b;
|
|
@@ -4,7 +4,7 @@ const embedded = require("@volar/language-service");
|
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
const vscode = require("vscode-languageserver");
|
|
6
6
|
function setupCapabilities(params, server, initOptions, plugins, semanticTokensLegend) {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
8
8
|
// Syntactic
|
|
9
9
|
if (!initOptions.respectClientCapabilities || ((_a = params.textDocument) === null || _a === void 0 ? void 0 : _a.selectionRange)) {
|
|
10
10
|
server.selectionRangeProvider = true;
|
|
@@ -85,17 +85,17 @@ function setupCapabilities(params, server, initOptions, plugins, semanticTokensL
|
|
|
85
85
|
server.codeLensProvider = {
|
|
86
86
|
resolveProvider: true,
|
|
87
87
|
};
|
|
88
|
-
|
|
89
|
-
server.executeCommandProvider.commands.push(embedded.
|
|
88
|
+
(_x = server.executeCommandProvider) !== null && _x !== void 0 ? _x : (server.executeCommandProvider = { commands: [] });
|
|
89
|
+
server.executeCommandProvider.commands.push(embedded.showReferencesCommand);
|
|
90
90
|
}
|
|
91
|
-
if (!initOptions.respectClientCapabilities || ((
|
|
91
|
+
if (!initOptions.respectClientCapabilities || ((_y = params.textDocument) === null || _y === void 0 ? void 0 : _y.semanticTokens)) {
|
|
92
92
|
server.semanticTokensProvider = {
|
|
93
93
|
range: true,
|
|
94
94
|
full: false,
|
|
95
95
|
legend: semanticTokensLegend,
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
if (!initOptions.respectClientCapabilities || ((
|
|
98
|
+
if (!initOptions.respectClientCapabilities || ((_z = params.textDocument) === null || _z === void 0 ? void 0 : _z.codeAction)) {
|
|
99
99
|
server.codeActionProvider = {
|
|
100
100
|
codeActionKinds: [
|
|
101
101
|
vscode.CodeActionKind.Empty,
|
|
@@ -111,10 +111,10 @@ function setupCapabilities(params, server, initOptions, plugins, semanticTokensL
|
|
|
111
111
|
resolveProvider: true,
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
-
if (!initOptions.respectClientCapabilities || ((
|
|
114
|
+
if (!initOptions.respectClientCapabilities || ((_0 = params.textDocument) === null || _0 === void 0 ? void 0 : _0.inlayHint)) {
|
|
115
115
|
server.inlayHintProvider = true;
|
|
116
116
|
}
|
|
117
|
-
if ((!initOptions.respectClientCapabilities || ((
|
|
117
|
+
if ((!initOptions.respectClientCapabilities || ((_1 = params.textDocument) === null || _1 === void 0 ? void 0 : _1.diagnostic)) && ((_2 = initOptions.diagnosticModel) !== null && _2 !== void 0 ? _2 : types_1.DiagnosticModel.Push) === types_1.DiagnosticModel.Pull) {
|
|
118
118
|
const selector = plugins.map(plugin => { var _a; return (_a = plugin.diagnosticDocumentSelector) !== null && _a !== void 0 ? _a : []; }).flat();
|
|
119
119
|
if (selector) {
|
|
120
120
|
server.diagnosticProvider = {
|
|
@@ -125,7 +125,7 @@ function setupCapabilities(params, server, initOptions, plugins, semanticTokensL
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
// cross file features
|
|
128
|
-
if (!initOptions.respectClientCapabilities || ((
|
|
128
|
+
if (!initOptions.respectClientCapabilities || ((_3 = params.workspace) === null || _3 === void 0 ? void 0 : _3.fileOperations)) {
|
|
129
129
|
const exts = plugins.map(plugin => plugin.extensions.fileRenameOperationFilter).flat();
|
|
130
130
|
if (exts.length) {
|
|
131
131
|
server.workspace = {
|
|
@@ -143,7 +143,7 @@ function setupCapabilities(params, server, initOptions, plugins, semanticTokensL
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
if (!initOptions.respectClientCapabilities || ((
|
|
146
|
+
if (!initOptions.respectClientCapabilities || ((_4 = params.workspace) === null || _4 === void 0 ? void 0 : _4.symbol)) {
|
|
147
147
|
server.workspaceSymbolProvider = true;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
plugins?: LanguageServicePlugin[];
|
|
4
|
-
}
|
|
5
|
-
export declare function loadServerConfig(dir: string, configFile: string | undefined): ServerConfig | undefined;
|
|
1
|
+
import { Config } from "@volar/language-service";
|
|
2
|
+
export declare function loadConfig(dir: string, configFile: string | undefined): Config | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
3
|
-
function
|
|
2
|
+
exports.loadConfig = void 0;
|
|
3
|
+
function loadConfig(dir, configFile) {
|
|
4
4
|
let configPath;
|
|
5
5
|
try {
|
|
6
6
|
configPath = require.resolve(configFile !== null && configFile !== void 0 ? configFile : './volar.config.js', { paths: [dir] });
|
|
@@ -17,5 +17,5 @@ function loadServerConfig(dir, configFile) {
|
|
|
17
17
|
console.log(err);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
exports.
|
|
20
|
+
exports.loadConfig = loadConfig;
|
|
21
21
|
//# sourceMappingURL=serverConfig.js.map
|