@volar/language-server 2.2.0-alpha.10 → 2.2.0-alpha.12
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/browser.d.ts +37 -6
- package/browser.js +26 -27
- package/lib/project/inferredCompilerOptions.d.ts +2 -2
- package/lib/project/inferredCompilerOptions.js +3 -3
- package/lib/project/simpleProject.d.ts +3 -4
- package/lib/project/simpleProject.js +5 -6
- package/lib/project/simpleProjectProvider.d.ts +4 -5
- package/lib/project/simpleProjectProvider.js +27 -37
- package/lib/project/typescriptProject.d.ts +8 -4
- package/lib/project/typescriptProject.js +16 -14
- package/lib/project/typescriptProjectProvider.d.ts +8 -2
- package/lib/project/typescriptProjectProvider.js +146 -151
- package/lib/register/registerEditorFeatures.d.ts +2 -3
- package/lib/register/registerEditorFeatures.js +21 -24
- package/lib/register/registerLanguageFeatures.d.ts +2 -3
- package/lib/register/registerLanguageFeatures.js +45 -45
- package/lib/server.d.ts +39 -27
- package/lib/server.js +138 -142
- package/lib/serverCapabilities.d.ts +2 -2
- package/lib/serverCapabilities.js +6 -21
- package/lib/types.d.ts +8 -29
- package/lib/types.js +1 -7
- package/node.d.ts +37 -6
- package/node.js +2 -3
- package/package.json +6 -6
- package/protocol.d.ts +0 -3
- package/protocol.js +1 -5
- package/lib/configurationHost.d.ts +0 -5
- package/lib/configurationHost.js +0 -43
package/lib/server.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.createServerBase = void 0;
|
|
4
18
|
const language_service_1 = require("@volar/language-service");
|
|
@@ -7,16 +21,19 @@ const l10n = require("@vscode/l10n");
|
|
|
7
21
|
const request_light_1 = require("request-light");
|
|
8
22
|
const vscode = require("vscode-languageserver");
|
|
9
23
|
const vscode_uri_1 = require("vscode-uri");
|
|
24
|
+
const registerEditorFeatures_js_1 = require("./register/registerEditorFeatures.js");
|
|
25
|
+
const registerLanguageFeatures_js_1 = require("./register/registerLanguageFeatures.js");
|
|
10
26
|
const serverCapabilities_js_1 = require("./serverCapabilities.js");
|
|
11
|
-
const types_js_1 = require("./types.js");
|
|
12
27
|
const uri_js_1 = require("./uri.js");
|
|
13
28
|
const uriMap_js_1 = require("./utils/uriMap.js");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
let projects;
|
|
17
|
-
let serverOptions;
|
|
29
|
+
__exportStar(require("@volar/snapshot-document"), exports);
|
|
30
|
+
function createServerBase(connection, getFs) {
|
|
18
31
|
let semanticTokensReq = 0;
|
|
19
32
|
let documentUpdatedReq = 0;
|
|
33
|
+
const didChangeWatchedFilesCallbacks = new Set();
|
|
34
|
+
const didChangeConfigurationCallbacks = new Set();
|
|
35
|
+
const workspaceFolders = (0, uriMap_js_1.createUriMap)(uri_js_1.fileNameToUri);
|
|
36
|
+
const configurations = new Map();
|
|
20
37
|
const documents = new vscode.TextDocuments({
|
|
21
38
|
create(uri, languageId, version, text) {
|
|
22
39
|
return new snapshot_document_1.SnapshotDocument(uri, languageId, version, text);
|
|
@@ -26,123 +43,111 @@ function createServerBase(connection, getRuntimeEnv) {
|
|
|
26
43
|
return snapshot;
|
|
27
44
|
},
|
|
28
45
|
});
|
|
29
|
-
const didChangeWatchedFilesCallbacks = new Set();
|
|
30
|
-
const didChangeConfigurationCallbacks = new Set();
|
|
31
|
-
const workspaceFolders = (0, uriMap_js_1.createUriMap)(uri_js_1.fileNameToUri);
|
|
32
|
-
const configurations = new Map();
|
|
33
46
|
documents.listen(connection);
|
|
34
|
-
|
|
47
|
+
const status = {
|
|
48
|
+
connection,
|
|
49
|
+
initializeParams: undefined,
|
|
50
|
+
languageServicePlugins: [],
|
|
51
|
+
projects: undefined,
|
|
52
|
+
fs: undefined,
|
|
53
|
+
semanticTokensLegend: undefined,
|
|
54
|
+
pullModelDiagnostics: false,
|
|
55
|
+
documents,
|
|
56
|
+
workspaceFolders,
|
|
35
57
|
initialize,
|
|
36
58
|
initialized,
|
|
37
59
|
shutdown,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
watchFiles,
|
|
61
|
+
getConfiguration,
|
|
62
|
+
onDidChangeConfiguration,
|
|
63
|
+
onDidChangeWatchedFiles,
|
|
64
|
+
clearPushDiagnostics,
|
|
65
|
+
refresh,
|
|
44
66
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (!params.capabilities.workspace?.configuration) {
|
|
56
|
-
return Promise.resolve(undefined);
|
|
57
|
-
}
|
|
58
|
-
if (!scopeUri && params.capabilities.workspace?.didChangeConfiguration) {
|
|
59
|
-
if (!configurations.has(section)) {
|
|
60
|
-
configurations.set(section, getConfigurationWorker(section, scopeUri));
|
|
61
|
-
}
|
|
62
|
-
return configurations.get(section);
|
|
63
|
-
}
|
|
64
|
-
return getConfigurationWorker(section, scopeUri);
|
|
65
|
-
async function getConfigurationWorker(section, scopeUri) {
|
|
66
|
-
return (await connection.workspace.getConfiguration({ scopeUri, section })) ?? undefined /* replace null to undefined */;
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
onDidChangeConfiguration(cb) {
|
|
70
|
-
didChangeConfigurationCallbacks.add(cb);
|
|
71
|
-
return {
|
|
72
|
-
dispose() {
|
|
73
|
-
didChangeConfigurationCallbacks.delete(cb);
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
},
|
|
77
|
-
onDidChangeWatchedFiles: cb => {
|
|
78
|
-
didChangeWatchedFilesCallbacks.add(cb);
|
|
79
|
-
return {
|
|
80
|
-
dispose: () => {
|
|
81
|
-
didChangeWatchedFilesCallbacks.delete(cb);
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
documents,
|
|
86
|
-
workspaceFolders,
|
|
87
|
-
reloadDiagnostics,
|
|
88
|
-
updateDiagnosticsAndSemanticTokens,
|
|
89
|
-
};
|
|
90
|
-
if (context.initializeParams.initializationOptions?.l10n) {
|
|
91
|
-
await l10n.config({ uri: context.initializeParams.initializationOptions.l10n.location });
|
|
67
|
+
return status;
|
|
68
|
+
function initialize(initializeParams, languageServicePlugins, projects, options) {
|
|
69
|
+
status.initializeParams = initializeParams;
|
|
70
|
+
status.languageServicePlugins = languageServicePlugins;
|
|
71
|
+
status.projects = projects;
|
|
72
|
+
status.semanticTokensLegend = options?.semanticTokensLegend ?? language_service_1.standardSemanticTokensLegend;
|
|
73
|
+
status.pullModelDiagnostics = options?.pullModelDiagnostics ?? false;
|
|
74
|
+
status.fs = createFsWithCache(getFs(initializeParams));
|
|
75
|
+
if (initializeParams.initializationOptions?.l10n) {
|
|
76
|
+
l10n.config({ uri: initializeParams.initializationOptions.l10n.location });
|
|
92
77
|
}
|
|
93
|
-
if (
|
|
94
|
-
for (const folder of
|
|
78
|
+
if (initializeParams.workspaceFolders?.length) {
|
|
79
|
+
for (const folder of initializeParams.workspaceFolders) {
|
|
95
80
|
workspaceFolders.uriSet(folder.uri, true);
|
|
96
81
|
}
|
|
97
82
|
}
|
|
98
|
-
else if (
|
|
99
|
-
workspaceFolders.uriSet(
|
|
83
|
+
else if (initializeParams.rootUri) {
|
|
84
|
+
workspaceFolders.uriSet(initializeParams.rootUri, true);
|
|
100
85
|
}
|
|
101
|
-
else if (
|
|
102
|
-
workspaceFolders.uriSet(vscode_uri_1.URI.file(
|
|
86
|
+
else if (initializeParams.rootPath) {
|
|
87
|
+
workspaceFolders.uriSet(vscode_uri_1.URI.file(initializeParams.rootPath).toString(), true);
|
|
103
88
|
}
|
|
104
|
-
const servicePlugins = await serverOptions.getServicePlugins();
|
|
105
|
-
const semanticTokensLegend = getSemanticTokensLegend();
|
|
106
|
-
projects = projectProviderFactory({ ...context }, servicePlugins, serverOptions.getLanguagePlugins, serverOptions.getLanguageId);
|
|
107
|
-
documents.onDidChangeContent(({ document }) => {
|
|
108
|
-
updateDiagnostics(document.uri);
|
|
109
|
-
});
|
|
110
|
-
documents.onDidClose(({ document }) => {
|
|
111
|
-
if (!isServerPushEnabled()) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
connection.sendDiagnostics({ uri: document.uri, diagnostics: [] });
|
|
115
|
-
});
|
|
116
|
-
context.onDidChangeConfiguration(updateDiagnosticsAndSemanticTokens);
|
|
117
|
-
(await import('./register/registerEditorFeatures.js')).registerEditorFeatures(connection, projects);
|
|
118
|
-
(await import('./register/registerLanguageFeatures.js')).registerLanguageFeatures(connection, projects, params, semanticTokensLegend);
|
|
119
89
|
const result = {
|
|
120
|
-
capabilities: (0, serverCapabilities_js_1.getServerCapabilities)(
|
|
90
|
+
capabilities: (0, serverCapabilities_js_1.getServerCapabilities)(status),
|
|
121
91
|
};
|
|
122
|
-
if (
|
|
92
|
+
if (!status.pullModelDiagnostics) {
|
|
123
93
|
result.capabilities.diagnosticProvider = undefined;
|
|
94
|
+
activateServerPushDiagnostics(projects);
|
|
124
95
|
}
|
|
96
|
+
(0, registerEditorFeatures_js_1.registerEditorFeatures)(status);
|
|
97
|
+
(0, registerLanguageFeatures_js_1.registerLanguageFeatures)(status);
|
|
125
98
|
return result;
|
|
126
99
|
}
|
|
127
100
|
function initialized() {
|
|
128
101
|
registerWorkspaceFolderWatcher();
|
|
129
102
|
registerConfigurationWatcher();
|
|
130
|
-
registerFileWatcher();
|
|
131
103
|
updateHttpSettings();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
104
|
+
onDidChangeConfiguration(updateHttpSettings);
|
|
105
|
+
}
|
|
106
|
+
async function shutdown() {
|
|
107
|
+
for (const project of await status.projects.all.call(status)) {
|
|
108
|
+
project.dispose();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function updateHttpSettings() {
|
|
112
|
+
const httpSettings = await getConfiguration('http');
|
|
113
|
+
(0, request_light_1.configure)(httpSettings?.proxy, httpSettings?.proxyStrictSSL ?? false);
|
|
114
|
+
}
|
|
115
|
+
function getConfiguration(section, scopeUri) {
|
|
116
|
+
if (!status.initializeParams?.capabilities.workspace?.configuration) {
|
|
117
|
+
return Promise.resolve(undefined);
|
|
118
|
+
}
|
|
119
|
+
if (!scopeUri && status.initializeParams.capabilities.workspace?.didChangeConfiguration) {
|
|
120
|
+
if (!configurations.has(section)) {
|
|
121
|
+
configurations.set(section, getConfigurationWorker(section, scopeUri));
|
|
122
|
+
}
|
|
123
|
+
return configurations.get(section);
|
|
136
124
|
}
|
|
125
|
+
return getConfigurationWorker(section, scopeUri);
|
|
126
|
+
}
|
|
127
|
+
async function getConfigurationWorker(section, scopeUri) {
|
|
128
|
+
return (await connection.workspace.getConfiguration({ scopeUri, section })) ?? undefined /* replace null to undefined */;
|
|
129
|
+
}
|
|
130
|
+
function onDidChangeConfiguration(cb) {
|
|
131
|
+
didChangeConfigurationCallbacks.add(cb);
|
|
132
|
+
return {
|
|
133
|
+
dispose() {
|
|
134
|
+
didChangeConfigurationCallbacks.delete(cb);
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
138
|
+
function onDidChangeWatchedFiles(cb) {
|
|
139
|
+
didChangeWatchedFilesCallbacks.add(cb);
|
|
140
|
+
return {
|
|
141
|
+
dispose: () => {
|
|
142
|
+
didChangeWatchedFilesCallbacks.delete(cb);
|
|
143
|
+
},
|
|
144
|
+
};
|
|
140
145
|
}
|
|
141
146
|
function createFsWithCache(fs) {
|
|
142
147
|
const readFileCache = new Map();
|
|
143
148
|
const statCache = new Map();
|
|
144
149
|
const readDirectoryCache = new Map();
|
|
145
|
-
|
|
150
|
+
onDidChangeWatchedFiles(({ changes }) => {
|
|
146
151
|
for (const change of changes) {
|
|
147
152
|
if (change.type === vscode.FileChangeType.Deleted) {
|
|
148
153
|
readFileCache.set(change.uri, undefined);
|
|
@@ -183,20 +188,8 @@ function createServerBase(connection, getRuntimeEnv) {
|
|
|
183
188
|
},
|
|
184
189
|
};
|
|
185
190
|
}
|
|
186
|
-
function getSemanticTokensLegend() {
|
|
187
|
-
return {
|
|
188
|
-
tokenTypes: [
|
|
189
|
-
...language_service_1.standardSemanticTokensLegend.tokenTypes,
|
|
190
|
-
...context.initializeParams.initializationOptions?.semanticTokensLegend?.tokenTypes ?? [],
|
|
191
|
-
],
|
|
192
|
-
tokenModifiers: [
|
|
193
|
-
...language_service_1.standardSemanticTokensLegend.tokenModifiers,
|
|
194
|
-
...context.initializeParams.initializationOptions?.semanticTokensLegend?.tokenModifiers ?? [],
|
|
195
|
-
],
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
191
|
function registerConfigurationWatcher() {
|
|
199
|
-
const didChangeConfiguration =
|
|
192
|
+
const didChangeConfiguration = status.initializeParams?.capabilities.workspace?.didChangeConfiguration;
|
|
200
193
|
if (didChangeConfiguration) {
|
|
201
194
|
connection.onDidChangeConfiguration(params => {
|
|
202
195
|
configurations.clear();
|
|
@@ -209,9 +202,10 @@ function createServerBase(connection, getRuntimeEnv) {
|
|
|
209
202
|
}
|
|
210
203
|
}
|
|
211
204
|
}
|
|
212
|
-
function
|
|
213
|
-
const didChangeWatchedFiles =
|
|
214
|
-
|
|
205
|
+
function watchFiles(patterns) {
|
|
206
|
+
const didChangeWatchedFiles = status.initializeParams?.capabilities.workspace?.didChangeWatchedFiles;
|
|
207
|
+
const fileOperations = status.initializeParams?.capabilities.workspace?.fileOperations;
|
|
208
|
+
if (didChangeWatchedFiles) {
|
|
215
209
|
connection.onDidChangeWatchedFiles(e => {
|
|
216
210
|
for (const cb of didChangeWatchedFilesCallbacks) {
|
|
217
211
|
cb(e);
|
|
@@ -219,17 +213,18 @@ function createServerBase(connection, getRuntimeEnv) {
|
|
|
219
213
|
});
|
|
220
214
|
if (didChangeWatchedFiles.dynamicRegistration) {
|
|
221
215
|
connection.client.register(vscode.DidChangeWatchedFilesNotification.type, {
|
|
222
|
-
watchers:
|
|
223
|
-
{
|
|
224
|
-
globPattern: `**/*.{${serverOptions.watchFileExtensions.join(',')}}`
|
|
225
|
-
},
|
|
226
|
-
]
|
|
216
|
+
watchers: patterns.map(pattern => ({ globPattern: pattern })),
|
|
227
217
|
});
|
|
228
218
|
}
|
|
229
219
|
}
|
|
220
|
+
if (fileOperations?.dynamicRegistration && fileOperations.willRename) {
|
|
221
|
+
connection.client.register(vscode.WillRenameFilesRequest.type, {
|
|
222
|
+
filters: patterns.map(pattern => ({ pattern: { glob: pattern } })),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
230
225
|
}
|
|
231
226
|
function registerWorkspaceFolderWatcher() {
|
|
232
|
-
if (
|
|
227
|
+
if (status.initializeParams?.capabilities.workspace?.workspaceFolders) {
|
|
233
228
|
connection.workspace.onDidChangeWorkspaceFolders(e => {
|
|
234
229
|
for (const folder of e.added) {
|
|
235
230
|
workspaceFolders.uriSet(folder.uri, true);
|
|
@@ -237,42 +232,46 @@ function createServerBase(connection, getRuntimeEnv) {
|
|
|
237
232
|
for (const folder of e.removed) {
|
|
238
233
|
workspaceFolders.uriDelete(folder.uri);
|
|
239
234
|
}
|
|
240
|
-
projects.reloadProjects();
|
|
235
|
+
// projects.reloadProjects();
|
|
241
236
|
});
|
|
242
237
|
}
|
|
243
238
|
}
|
|
244
|
-
function
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
239
|
+
function activateServerPushDiagnostics(projects) {
|
|
240
|
+
documents.onDidChangeContent(({ document }) => {
|
|
241
|
+
pushAllDiagnostics(projects, document.uri);
|
|
242
|
+
});
|
|
243
|
+
documents.onDidClose(({ document }) => {
|
|
249
244
|
connection.sendDiagnostics({ uri: document.uri, diagnostics: [] });
|
|
245
|
+
});
|
|
246
|
+
onDidChangeConfiguration(() => refresh(projects));
|
|
247
|
+
}
|
|
248
|
+
function clearPushDiagnostics() {
|
|
249
|
+
if (!status.pullModelDiagnostics) {
|
|
250
|
+
for (const document of documents.all()) {
|
|
251
|
+
connection.sendDiagnostics({ uri: document.uri, diagnostics: [] });
|
|
252
|
+
}
|
|
250
253
|
}
|
|
251
|
-
updateDiagnosticsAndSemanticTokens();
|
|
252
254
|
}
|
|
253
|
-
async function
|
|
255
|
+
async function refresh(projects) {
|
|
254
256
|
const req = ++semanticTokensReq;
|
|
255
|
-
|
|
257
|
+
if (!status.pullModelDiagnostics) {
|
|
258
|
+
await pushAllDiagnostics(projects);
|
|
259
|
+
}
|
|
256
260
|
const delay = 250;
|
|
257
261
|
await sleep(delay);
|
|
258
262
|
if (req === semanticTokensReq) {
|
|
259
|
-
if (
|
|
263
|
+
if (status.initializeParams?.capabilities.workspace?.semanticTokens?.refreshSupport) {
|
|
260
264
|
connection.languages.semanticTokens.refresh();
|
|
261
265
|
}
|
|
262
|
-
if (
|
|
266
|
+
if (status.initializeParams?.capabilities.workspace?.inlayHint?.refreshSupport) {
|
|
263
267
|
connection.languages.inlayHint.refresh();
|
|
264
268
|
}
|
|
265
|
-
if (
|
|
266
|
-
|
|
267
|
-
connection.languages.diagnostics.refresh();
|
|
268
|
-
}
|
|
269
|
+
if (status.pullModelDiagnostics && status.initializeParams?.capabilities.workspace?.diagnostics?.refreshSupport) {
|
|
270
|
+
connection.languages.diagnostics.refresh();
|
|
269
271
|
}
|
|
270
272
|
}
|
|
271
273
|
}
|
|
272
|
-
async function
|
|
273
|
-
if (!isServerPushEnabled()) {
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
274
|
+
async function pushAllDiagnostics(projects, docUri) {
|
|
276
275
|
const req = ++documentUpdatedReq;
|
|
277
276
|
const delay = 250;
|
|
278
277
|
const token = {
|
|
@@ -288,26 +287,23 @@ function createServerBase(connection, getRuntimeEnv) {
|
|
|
288
287
|
if (token.isCancellationRequested) {
|
|
289
288
|
return;
|
|
290
289
|
}
|
|
291
|
-
await
|
|
290
|
+
await pushDiagnostics(projects, changeDoc.uri, changeDoc.version, token);
|
|
292
291
|
}
|
|
293
292
|
for (const doc of otherDocs) {
|
|
294
293
|
await sleep(delay);
|
|
295
294
|
if (token.isCancellationRequested) {
|
|
296
295
|
break;
|
|
297
296
|
}
|
|
298
|
-
await
|
|
297
|
+
await pushDiagnostics(projects, doc.uri, doc.version, token);
|
|
299
298
|
}
|
|
300
299
|
}
|
|
301
|
-
async function
|
|
302
|
-
const languageService = (await projects.
|
|
300
|
+
async function pushDiagnostics(projects, uri, version, cancel) {
|
|
301
|
+
const languageService = (await projects.get.call(status, uri)).getLanguageService();
|
|
303
302
|
const errors = await languageService.doValidation(uri, cancel, result => {
|
|
304
303
|
connection.sendDiagnostics({ uri: uri, diagnostics: result, version });
|
|
305
304
|
});
|
|
306
305
|
connection.sendDiagnostics({ uri: uri, diagnostics: errors, version });
|
|
307
306
|
}
|
|
308
|
-
function isServerPushEnabled() {
|
|
309
|
-
return (context.initializeParams.initializationOptions?.diagnosticModel ?? types_js_1.DiagnosticModel.Push) === types_js_1.DiagnosticModel.Push;
|
|
310
|
-
}
|
|
311
307
|
}
|
|
312
308
|
exports.createServerBase = createServerBase;
|
|
313
309
|
function sleep(ms) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { LanguageServicePlugin } from '@volar/language-service';
|
|
2
1
|
import * as vscode from 'vscode-languageserver';
|
|
3
|
-
|
|
2
|
+
import type { ServerBase } from './types';
|
|
3
|
+
export declare function getServerCapabilities(server: ServerBase): vscode.ServerCapabilities<any>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getServerCapabilities = void 0;
|
|
4
4
|
const vscode = require("vscode-languageserver");
|
|
5
|
-
function getServerCapabilities(
|
|
5
|
+
function getServerCapabilities(server) {
|
|
6
6
|
const capabilities = {
|
|
7
7
|
textDocumentSync: vscode.TextDocumentSyncKind.Incremental,
|
|
8
8
|
workspace: {
|
|
@@ -27,11 +27,11 @@ function getServerCapabilities(watchExts, servicePlugins, semanticTokensLegend)
|
|
|
27
27
|
hoverProvider: true,
|
|
28
28
|
renameProvider: { prepareProvider: true },
|
|
29
29
|
signatureHelpProvider: {
|
|
30
|
-
triggerCharacters: [...new Set(
|
|
31
|
-
retriggerCharacters: [...new Set(
|
|
30
|
+
triggerCharacters: [...new Set(server.languageServicePlugins.map(service => service.signatureHelpTriggerCharacters ?? []).flat())],
|
|
31
|
+
retriggerCharacters: [...new Set(server.languageServicePlugins.map(service => service.signatureHelpRetriggerCharacters ?? []).flat())],
|
|
32
32
|
},
|
|
33
33
|
completionProvider: {
|
|
34
|
-
triggerCharacters: [...new Set(
|
|
34
|
+
triggerCharacters: [...new Set(server.languageServicePlugins.map(service => service.triggerCharacters ?? []).flat())],
|
|
35
35
|
resolveProvider: true,
|
|
36
36
|
},
|
|
37
37
|
documentHighlightProvider: true,
|
|
@@ -40,7 +40,7 @@ function getServerCapabilities(watchExts, servicePlugins, semanticTokensLegend)
|
|
|
40
40
|
semanticTokensProvider: {
|
|
41
41
|
range: true,
|
|
42
42
|
full: false,
|
|
43
|
-
legend: semanticTokensLegend,
|
|
43
|
+
legend: server.semanticTokensLegend,
|
|
44
44
|
},
|
|
45
45
|
codeActionProvider: {
|
|
46
46
|
codeActionKinds: [
|
|
@@ -63,28 +63,13 @@ function getServerCapabilities(watchExts, servicePlugins, semanticTokensLegend)
|
|
|
63
63
|
workspaceDiagnostics: false,
|
|
64
64
|
},
|
|
65
65
|
};
|
|
66
|
-
const characters = [...new Set(
|
|
66
|
+
const characters = [...new Set(server.languageServicePlugins.map(service => service.autoFormatTriggerCharacters ?? []).flat())];
|
|
67
67
|
if (characters.length) {
|
|
68
68
|
capabilities.documentOnTypeFormattingProvider = {
|
|
69
69
|
firstTriggerCharacter: characters[0],
|
|
70
70
|
moreTriggerCharacter: characters.slice(1),
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
if (watchExts.length) {
|
|
74
|
-
capabilities.workspace = {
|
|
75
|
-
fileOperations: {
|
|
76
|
-
willRename: {
|
|
77
|
-
filters: [
|
|
78
|
-
{
|
|
79
|
-
pattern: {
|
|
80
|
-
glob: `**/*.{${watchExts.join(',')}}`
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
73
|
return capabilities;
|
|
89
74
|
}
|
|
90
75
|
exports.getServerCapabilities = getServerCapabilities;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,44 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageService } from '@volar/language-service';
|
|
2
2
|
import type * as vscode from 'vscode-languageserver';
|
|
3
|
-
import type {
|
|
4
|
-
import type { createSys } from '@volar/typescript';
|
|
5
|
-
export interface ServerRuntimeEnvironment {
|
|
6
|
-
fs: FileSystem;
|
|
7
|
-
}
|
|
8
|
-
export interface ProjectContext {
|
|
9
|
-
typescript?: {
|
|
10
|
-
configFileName: string | undefined;
|
|
11
|
-
host: TypeScriptProjectHost;
|
|
12
|
-
sys: ReturnType<typeof createSys>;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export declare enum DiagnosticModel {
|
|
16
|
-
None = 0,
|
|
17
|
-
Push = 1,
|
|
18
|
-
Pull = 2
|
|
19
|
-
}
|
|
3
|
+
import type { createServerBase } from './server';
|
|
20
4
|
export interface InitializationOptions {
|
|
21
5
|
l10n?: {
|
|
22
6
|
location: string;
|
|
23
7
|
};
|
|
24
|
-
diagnosticModel?: DiagnosticModel;
|
|
25
8
|
maxFileSize?: number;
|
|
26
|
-
/**
|
|
27
|
-
* Extra semantic token types and modifiers that are supported by the client.
|
|
28
|
-
*/
|
|
29
|
-
semanticTokensLegend?: vscode.SemanticTokensLegend;
|
|
30
9
|
codegenStack?: boolean;
|
|
31
10
|
}
|
|
11
|
+
export type VolarInitializeParams = Omit<vscode.InitializeParams, 'initializationOptions'> & {
|
|
12
|
+
initializationOptions?: InitializationOptions;
|
|
13
|
+
};
|
|
32
14
|
export interface ServerProject {
|
|
33
15
|
getLanguageService(): LanguageService;
|
|
34
16
|
getLanguageServiceDontCreate(): LanguageService | undefined;
|
|
35
17
|
dispose(): void;
|
|
36
18
|
}
|
|
37
19
|
export interface ServerProjectProvider {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
reloadProjects(): Promise<void> | void;
|
|
41
|
-
}
|
|
42
|
-
export interface ServerProjectProviderFactory {
|
|
43
|
-
(context: ServerContext, servicePlugins: LanguageServicePlugin[], getLanguagePlugins: ServerOptions['getLanguagePlugins'], getLanguageId: ServerOptions['getLanguageId']): ServerProjectProvider;
|
|
20
|
+
get(this: ServerBase, uri: string): Promise<ServerProject>;
|
|
21
|
+
all(this: ServerBase): Promise<ServerProject[]>;
|
|
44
22
|
}
|
|
23
|
+
export type ServerBase = ReturnType<typeof createServerBase>;
|
package/lib/types.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
var DiagnosticModel;
|
|
5
|
-
(function (DiagnosticModel) {
|
|
6
|
-
DiagnosticModel[DiagnosticModel["None"] = 0] = "None";
|
|
7
|
-
DiagnosticModel[DiagnosticModel["Push"] = 1] = "Push";
|
|
8
|
-
DiagnosticModel[DiagnosticModel["Pull"] = 2] = "Pull";
|
|
9
|
-
})(DiagnosticModel || (exports.DiagnosticModel = DiagnosticModel = {}));
|
|
3
|
+
;
|
|
10
4
|
//# sourceMappingURL=types.js.map
|
package/node.d.ts
CHANGED
|
@@ -5,16 +5,47 @@ export * from 'vscode-languageserver/node';
|
|
|
5
5
|
export * from './index';
|
|
6
6
|
export * from './lib/project/simpleProjectProvider';
|
|
7
7
|
export * from './lib/project/typescriptProjectProvider';
|
|
8
|
+
export * from './lib/server';
|
|
8
9
|
export declare function createFs(options: InitializationOptions): FileSystem;
|
|
9
10
|
export declare function createConnection(): vscode._Connection<vscode._, vscode._, vscode._, vscode._, vscode._, vscode._, import("vscode-languageserver/lib/common/inlineCompletion.proposed").InlineCompletionFeatureShape, vscode._>;
|
|
10
11
|
export declare function createServer(connection: vscode.Connection): {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
connection: vscode.Connection;
|
|
13
|
+
initializeParams: import("./index").VolarInitializeParams;
|
|
14
|
+
languageServicePlugins: import("@volar/language-service").LanguageServicePlugin<any>[];
|
|
15
|
+
projects: import("./index").ServerProjectProvider;
|
|
16
|
+
fs: FileSystem;
|
|
17
|
+
semanticTokensLegend: vscode.SemanticTokensLegend;
|
|
18
|
+
pullModelDiagnostics: boolean;
|
|
19
|
+
documents: vscode.TextDocuments<import("@volar/snapshot-document/lib/snapshotDocument").SnapshotDocument>;
|
|
20
|
+
workspaceFolders: {
|
|
21
|
+
clear: () => void;
|
|
22
|
+
values: () => IterableIterator<boolean>;
|
|
23
|
+
uriKeys: () => IterableIterator<string>;
|
|
24
|
+
uriDelete: (_uri: string) => boolean;
|
|
25
|
+
uriGet: (_uri: string) => boolean | undefined;
|
|
26
|
+
uriHas: (_uri: string) => boolean;
|
|
27
|
+
uriSet: (_uri: string, item: boolean) => void;
|
|
28
|
+
pathDelete: (path: string) => boolean;
|
|
29
|
+
pathGet: (path: string) => boolean | undefined;
|
|
30
|
+
pathHas: (path: string) => boolean | undefined;
|
|
31
|
+
pathSet: (path: string, item: boolean) => void;
|
|
32
|
+
};
|
|
33
|
+
initialize: (initializeParams: import("./index").VolarInitializeParams, languageServicePlugins: import("@volar/language-service").LanguageServicePlugin<any>[], projects: import("./index").ServerProjectProvider, options?: {
|
|
34
|
+
semanticTokensLegend?: vscode.SemanticTokensLegend | undefined;
|
|
35
|
+
pullModelDiagnostics?: boolean | undefined;
|
|
36
|
+
} | undefined) => vscode.InitializeResult<any>;
|
|
14
37
|
initialized: () => void;
|
|
15
|
-
shutdown: () => void
|
|
16
|
-
|
|
17
|
-
|
|
38
|
+
shutdown: () => Promise<void>;
|
|
39
|
+
watchFiles: (patterns: string[]) => void;
|
|
40
|
+
getConfiguration: <T>(section: string, scopeUri?: string | undefined) => Promise<T | undefined>;
|
|
41
|
+
onDidChangeConfiguration: (cb: vscode.NotificationHandler<vscode.DidChangeConfigurationParams>) => {
|
|
42
|
+
dispose(): void;
|
|
43
|
+
};
|
|
44
|
+
onDidChangeWatchedFiles: (cb: vscode.NotificationHandler<vscode.DidChangeWatchedFilesParams>) => {
|
|
45
|
+
dispose: () => void;
|
|
46
|
+
};
|
|
47
|
+
clearPushDiagnostics: () => void;
|
|
48
|
+
refresh: (projects: import("./index").ServerProjectProvider) => Promise<void>;
|
|
18
49
|
};
|
|
19
50
|
export declare function loadTsdkByPath(tsdk: string, locale: string | undefined): {
|
|
20
51
|
typescript: typeof import("typescript");
|
package/node.js
CHANGED
|
@@ -25,6 +25,7 @@ __exportStar(require("vscode-languageserver/node"), exports);
|
|
|
25
25
|
__exportStar(require("./index"), exports);
|
|
26
26
|
__exportStar(require("./lib/project/simpleProjectProvider"), exports);
|
|
27
27
|
__exportStar(require("./lib/project/typescriptProjectProvider"), exports);
|
|
28
|
+
__exportStar(require("./lib/server"), exports);
|
|
28
29
|
function createFs(options) {
|
|
29
30
|
return {
|
|
30
31
|
stat(uri) {
|
|
@@ -94,9 +95,7 @@ function createConnection() {
|
|
|
94
95
|
}
|
|
95
96
|
exports.createConnection = createConnection;
|
|
96
97
|
function createServer(connection) {
|
|
97
|
-
return (0, server_1.createServerBase)(connection, params => ({
|
|
98
|
-
fs: createFs(params.initializationOptions ?? {}),
|
|
99
|
-
}));
|
|
98
|
+
return (0, server_1.createServerBase)(connection, params => createFs(params.initializationOptions ?? {}));
|
|
100
99
|
}
|
|
101
100
|
exports.createServer = createServer;
|
|
102
101
|
function loadTsdkByPath(tsdk, locale) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"directory": "packages/language-server"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.2.0-alpha.
|
|
16
|
-
"@volar/language-service": "2.2.0-alpha.
|
|
17
|
-
"@volar/snapshot-document": "2.2.0-alpha.
|
|
18
|
-
"@volar/typescript": "2.2.0-alpha.
|
|
15
|
+
"@volar/language-core": "2.2.0-alpha.12",
|
|
16
|
+
"@volar/language-service": "2.2.0-alpha.12",
|
|
17
|
+
"@volar/snapshot-document": "2.2.0-alpha.12",
|
|
18
|
+
"@volar/typescript": "2.2.0-alpha.12",
|
|
19
19
|
"@vscode/l10n": "^0.0.16",
|
|
20
20
|
"path-browserify": "^1.0.1",
|
|
21
21
|
"request-light": "^0.7.0",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/path-browserify": "latest"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "bf61f7a5a4a51669621e951f32ddf102f03a333d"
|
|
31
31
|
}
|
package/protocol.d.ts
CHANGED
|
@@ -49,9 +49,6 @@ export declare namespace AutoInsertRequest {
|
|
|
49
49
|
export declare namespace WriteVirtualFilesNotification {
|
|
50
50
|
const type: vscode.NotificationType<vscode.TextDocumentIdentifier>;
|
|
51
51
|
}
|
|
52
|
-
export declare namespace ReloadProjectNotification {
|
|
53
|
-
const type: vscode.NotificationType<vscode.TextDocumentIdentifier>;
|
|
54
|
-
}
|
|
55
52
|
/**
|
|
56
53
|
* Document Drop
|
|
57
54
|
*/
|