@volar/language-server 2.0.0-alpha.9 → 2.0.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/browser.d.ts +4 -2
- package/browser.js +4 -4
- package/lib/project/inferredCompilerOptions.d.ts +1 -1
- package/lib/project/simpleProject.d.ts +3 -4
- package/lib/project/simpleProject.js +6 -7
- package/lib/project/simpleProjectProvider.d.ts +5 -22
- package/lib/project/simpleProjectProvider.js +20 -21
- package/lib/project/typescriptProject.d.ts +4 -5
- package/lib/project/typescriptProject.js +27 -24
- package/lib/project/typescriptProjectProvider.d.ts +2 -4
- package/lib/project/typescriptProjectProvider.js +20 -19
- package/lib/register/registerEditorFeatures.js +45 -30
- package/lib/register/registerLanguageFeatures.js +2 -1
- package/lib/server.d.ts +22 -20
- package/lib/server.js +73 -96
- package/lib/types.d.ts +9 -4
- package/lib/utils/uriMap.js +2 -1
- package/lib/workspaceFolderManager.d.ts +6 -9
- package/lib/workspaceFolderManager.js +2 -2
- package/node.d.ts +4 -2
- package/node.js +5 -5
- package/package.json +6 -6
- package/protocol.d.ts +12 -12
- package/protocol.js +10 -10
- package/lib/cancellationToken.d.ts +0 -3
- package/lib/cancellationToken.js +0 -44
- package/lib/config.js +0 -32
package/lib/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createServerBase = void 0;
|
|
4
4
|
const language_service_1 = require("@volar/language-service");
|
|
5
5
|
const l10n = require("@vscode/l10n");
|
|
6
6
|
const request_light_1 = require("request-light");
|
|
@@ -11,14 +11,9 @@ const configurationHost_js_1 = require("./configurationHost.js");
|
|
|
11
11
|
const setupCapabilities_js_1 = require("./setupCapabilities.js");
|
|
12
12
|
const workspaceFolderManager_js_1 = require("./workspaceFolderManager.js");
|
|
13
13
|
const snapshot_document_1 = require("@volar/snapshot-document");
|
|
14
|
-
function
|
|
15
|
-
let initParams;
|
|
16
|
-
let options;
|
|
17
|
-
let projects;
|
|
14
|
+
function createServerBase(connection, getRuntimeEnv) {
|
|
18
15
|
let context;
|
|
19
|
-
let
|
|
20
|
-
let tsLocalized;
|
|
21
|
-
let env;
|
|
16
|
+
let projects;
|
|
22
17
|
let serverOptions;
|
|
23
18
|
let semanticTokensReq = 0;
|
|
24
19
|
let documentUpdatedReq = 0;
|
|
@@ -31,9 +26,9 @@ function createServer(connection, getRuntimeEnv) {
|
|
|
31
26
|
return snapshot;
|
|
32
27
|
},
|
|
33
28
|
});
|
|
34
|
-
documents.listen(connection);
|
|
35
29
|
const didChangeWatchedFilesCallbacks = new Set();
|
|
36
30
|
const workspaceFolderManager = (0, workspaceFolderManager_js_1.createWorkspaceFolderManager)();
|
|
31
|
+
documents.listen(connection);
|
|
37
32
|
return {
|
|
38
33
|
initialize,
|
|
39
34
|
initialized,
|
|
@@ -42,64 +37,59 @@ function createServer(connection, getRuntimeEnv) {
|
|
|
42
37
|
return projects;
|
|
43
38
|
},
|
|
44
39
|
get env() {
|
|
45
|
-
return
|
|
40
|
+
return context.runtimeEnv;
|
|
46
41
|
},
|
|
47
42
|
get modules() {
|
|
48
43
|
return {
|
|
49
|
-
typescript: ts,
|
|
44
|
+
typescript: context.ts,
|
|
50
45
|
};
|
|
51
46
|
}
|
|
52
47
|
};
|
|
53
|
-
async function initialize(
|
|
54
|
-
initParams = _params;
|
|
48
|
+
async function initialize(params, projectProviderFactory, _serverOptions) {
|
|
55
49
|
serverOptions = _serverOptions;
|
|
56
|
-
|
|
57
|
-
env = getRuntimeEnv(initParams, options);
|
|
50
|
+
const env = getRuntimeEnv(params);
|
|
58
51
|
context = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
fs: createFsWithCache(env.fs),
|
|
65
|
-
},
|
|
66
|
-
configurationHost: initParams.capabilities.workspace?.configuration ? (0, configurationHost_js_1.createConfigurationHost)(initParams, connection) : undefined,
|
|
67
|
-
onDidChangeWatchedFiles: cb => {
|
|
68
|
-
didChangeWatchedFilesCallbacks.add(cb);
|
|
69
|
-
return {
|
|
70
|
-
dispose: () => {
|
|
71
|
-
didChangeWatchedFilesCallbacks.delete(cb);
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
},
|
|
52
|
+
initializeParams: params,
|
|
53
|
+
connection,
|
|
54
|
+
runtimeEnv: {
|
|
55
|
+
...env,
|
|
56
|
+
fs: createFsWithCache(env.fs),
|
|
75
57
|
},
|
|
58
|
+
configurationHost: params.capabilities.workspace?.configuration
|
|
59
|
+
? (0, configurationHost_js_1.createConfigurationHost)(params, connection)
|
|
60
|
+
: undefined,
|
|
61
|
+
onDidChangeWatchedFiles: cb => {
|
|
62
|
+
didChangeWatchedFilesCallbacks.add(cb);
|
|
63
|
+
return {
|
|
64
|
+
dispose: () => {
|
|
65
|
+
didChangeWatchedFilesCallbacks.delete(cb);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
ts: undefined,
|
|
70
|
+
tsLocalized: undefined,
|
|
71
|
+
documents,
|
|
72
|
+
workspaceFolders: workspaceFolderManager,
|
|
73
|
+
reloadDiagnostics,
|
|
74
|
+
updateDiagnosticsAndSemanticTokens,
|
|
76
75
|
};
|
|
77
|
-
ts = await context.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
: undefined;
|
|
81
|
-
if (options.l10n) {
|
|
82
|
-
await l10n.config({ uri: options.l10n.location });
|
|
76
|
+
context.ts = await env.loadTypeScript(context.initializeParams.initializationOptions ?? {});
|
|
77
|
+
if (context.initializeParams.locale) {
|
|
78
|
+
context.tsLocalized = await env.loadTypeScriptLocalized(context.initializeParams.initializationOptions ?? {}, context.initializeParams.locale);
|
|
83
79
|
}
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
if (context.initializeParams.initializationOptions?.l10n) {
|
|
81
|
+
await l10n.config({ uri: context.initializeParams.initializationOptions.l10n.location });
|
|
82
|
+
}
|
|
83
|
+
if (params.capabilities.workspace?.workspaceFolders && params.workspaceFolders) {
|
|
84
|
+
for (const folder of params.workspaceFolders) {
|
|
85
|
+
workspaceFolderManager.add(vscode_uri_1.URI.parse(folder.uri));
|
|
90
86
|
}
|
|
91
87
|
}
|
|
92
|
-
else if (
|
|
93
|
-
workspaceFolderManager.add(
|
|
94
|
-
uri: vscode_uri_1.URI.parse(initParams.rootUri),
|
|
95
|
-
name: '',
|
|
96
|
-
});
|
|
88
|
+
else if (params.rootUri) {
|
|
89
|
+
workspaceFolderManager.add(vscode_uri_1.URI.parse(params.rootUri));
|
|
97
90
|
}
|
|
98
|
-
else if (
|
|
99
|
-
workspaceFolderManager.add(
|
|
100
|
-
uri: vscode_uri_1.URI.file(initParams.rootPath),
|
|
101
|
-
name: '',
|
|
102
|
-
});
|
|
91
|
+
else if (params.rootPath) {
|
|
92
|
+
workspaceFolderManager.add(vscode_uri_1.URI.file(params.rootPath));
|
|
103
93
|
}
|
|
104
94
|
const result = {
|
|
105
95
|
capabilities: {
|
|
@@ -113,28 +103,20 @@ function createServer(connection, getRuntimeEnv) {
|
|
|
113
103
|
},
|
|
114
104
|
},
|
|
115
105
|
};
|
|
116
|
-
|
|
106
|
+
const servicePlugins = await serverOptions.getServicePlugins();
|
|
107
|
+
(0, setupCapabilities_js_1.setupCapabilities)(result.capabilities, context.initializeParams.initializationOptions ?? {}, serverOptions.watchFileExtensions ?? [], servicePlugins, getSemanticTokensLegend());
|
|
117
108
|
projects = projectProviderFactory({
|
|
118
109
|
...context,
|
|
119
|
-
|
|
120
|
-
ts,
|
|
121
|
-
tsLocalized,
|
|
122
|
-
initOptions: options,
|
|
123
|
-
documents,
|
|
124
|
-
workspaceFolders: workspaceFolderManager,
|
|
125
|
-
reloadDiagnostics,
|
|
126
|
-
updateDiagnosticsAndSemanticTokens,
|
|
127
|
-
},
|
|
128
|
-
}, serverOptions);
|
|
110
|
+
}, serverOptions, servicePlugins);
|
|
129
111
|
documents.onDidChangeContent(({ document }) => {
|
|
130
112
|
updateDiagnostics(document.uri);
|
|
131
113
|
});
|
|
132
114
|
documents.onDidClose(({ document }) => {
|
|
133
|
-
context.
|
|
115
|
+
context.connection.sendDiagnostics({ uri: document.uri, diagnostics: [] });
|
|
134
116
|
});
|
|
135
|
-
context.
|
|
136
|
-
(await import('./register/registerEditorFeatures.js')).registerEditorFeatures(connection, projects, context.
|
|
137
|
-
(await import('./register/registerLanguageFeatures.js')).registerLanguageFeatures(connection, projects,
|
|
117
|
+
context.configurationHost?.onDidChangeConfiguration?.(updateDiagnosticsAndSemanticTokens);
|
|
118
|
+
(await import('./register/registerEditorFeatures.js')).registerEditorFeatures(connection, projects, context.runtimeEnv);
|
|
119
|
+
(await import('./register/registerLanguageFeatures.js')).registerLanguageFeatures(connection, projects, params, context.initializeParams.initializationOptions ?? {}, getSemanticTokensLegend(), context.runtimeEnv, documents);
|
|
138
120
|
try {
|
|
139
121
|
// show version on LSP logs
|
|
140
122
|
const packageJson = require('../package.json');
|
|
@@ -147,26 +129,20 @@ function createServer(connection, getRuntimeEnv) {
|
|
|
147
129
|
return result;
|
|
148
130
|
}
|
|
149
131
|
function initialized() {
|
|
150
|
-
context.
|
|
151
|
-
context.
|
|
132
|
+
context.configurationHost?.ready();
|
|
133
|
+
context.configurationHost?.onDidChangeConfiguration?.(updateHttpSettings);
|
|
152
134
|
updateHttpSettings();
|
|
153
|
-
if (
|
|
135
|
+
if (context.initializeParams.capabilities.workspace?.workspaceFolders) {
|
|
154
136
|
connection.workspace.onDidChangeWorkspaceFolders(e => {
|
|
155
137
|
for (const folder of e.added) {
|
|
156
|
-
workspaceFolderManager.add(
|
|
157
|
-
name: folder.name,
|
|
158
|
-
uri: vscode_uri_1.URI.parse(folder.uri),
|
|
159
|
-
});
|
|
138
|
+
workspaceFolderManager.add(vscode_uri_1.URI.parse(folder.uri));
|
|
160
139
|
}
|
|
161
140
|
for (const folder of e.removed) {
|
|
162
|
-
workspaceFolderManager.remove(
|
|
163
|
-
name: folder.name,
|
|
164
|
-
uri: vscode_uri_1.URI.parse(folder.uri),
|
|
165
|
-
});
|
|
141
|
+
workspaceFolderManager.remove(vscode_uri_1.URI.parse(folder.uri));
|
|
166
142
|
}
|
|
167
143
|
});
|
|
168
144
|
}
|
|
169
|
-
if (
|
|
145
|
+
if (context.initializeParams.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration) {
|
|
170
146
|
if (serverOptions.watchFileExtensions?.length) {
|
|
171
147
|
connection.client.register(vscode.DidChangeWatchedFilesNotification.type, {
|
|
172
148
|
watchers: [
|
|
@@ -183,7 +159,7 @@ function createServer(connection, getRuntimeEnv) {
|
|
|
183
159
|
}
|
|
184
160
|
}
|
|
185
161
|
async function updateHttpSettings() {
|
|
186
|
-
const httpSettings = await context.
|
|
162
|
+
const httpSettings = await context.configurationHost?.getConfiguration?.('http');
|
|
187
163
|
(0, request_light_1.configure)(httpSettings?.proxy, httpSettings?.proxyStrictSSL ?? false);
|
|
188
164
|
}
|
|
189
165
|
}
|
|
@@ -236,17 +212,17 @@ function createServer(connection, getRuntimeEnv) {
|
|
|
236
212
|
};
|
|
237
213
|
}
|
|
238
214
|
function getSemanticTokensLegend() {
|
|
239
|
-
if (!
|
|
215
|
+
if (!context.initializeParams.initializationOptions?.semanticTokensLegend) {
|
|
240
216
|
return language_service_1.standardSemanticTokensLegend;
|
|
241
217
|
}
|
|
242
218
|
return {
|
|
243
|
-
tokenTypes: [...language_service_1.standardSemanticTokensLegend.tokenTypes, ...
|
|
244
|
-
tokenModifiers: [...language_service_1.standardSemanticTokensLegend.tokenModifiers, ...
|
|
219
|
+
tokenTypes: [...language_service_1.standardSemanticTokensLegend.tokenTypes, ...context.initializeParams.initializationOptions.semanticTokensLegend.tokenTypes],
|
|
220
|
+
tokenModifiers: [...language_service_1.standardSemanticTokensLegend.tokenModifiers, ...context.initializeParams.initializationOptions.semanticTokensLegend.tokenModifiers],
|
|
245
221
|
};
|
|
246
222
|
}
|
|
247
223
|
function reloadDiagnostics() {
|
|
248
224
|
for (const document of documents.all()) {
|
|
249
|
-
context.
|
|
225
|
+
context.connection.sendDiagnostics({ uri: document.uri, diagnostics: [] });
|
|
250
226
|
}
|
|
251
227
|
updateDiagnosticsAndSemanticTokens();
|
|
252
228
|
}
|
|
@@ -256,22 +232,23 @@ function createServer(connection, getRuntimeEnv) {
|
|
|
256
232
|
const delay = 250;
|
|
257
233
|
await sleep(delay);
|
|
258
234
|
if (req === semanticTokensReq) {
|
|
259
|
-
if (context.
|
|
260
|
-
context.
|
|
235
|
+
if (context.initializeParams.capabilities.workspace?.semanticTokens?.refreshSupport) {
|
|
236
|
+
context.connection.languages.semanticTokens.refresh();
|
|
261
237
|
}
|
|
262
|
-
if (context.
|
|
263
|
-
context.
|
|
238
|
+
if (context.initializeParams.capabilities.workspace?.inlayHint?.refreshSupport) {
|
|
239
|
+
context.connection.languages.inlayHint.refresh();
|
|
264
240
|
}
|
|
265
|
-
if ((
|
|
266
|
-
if (context.
|
|
267
|
-
context.
|
|
241
|
+
if ((context.initializeParams.initializationOptions?.diagnosticModel ?? types_js_1.DiagnosticModel.Push) === types_js_1.DiagnosticModel.Pull) {
|
|
242
|
+
if (context.initializeParams.capabilities.workspace?.diagnostics?.refreshSupport) {
|
|
243
|
+
context.connection.languages.diagnostics.refresh();
|
|
268
244
|
}
|
|
269
245
|
}
|
|
270
246
|
}
|
|
271
247
|
}
|
|
272
248
|
async function updateDiagnostics(docUri) {
|
|
273
|
-
if ((
|
|
249
|
+
if ((context.initializeParams.initializationOptions?.diagnosticModel ?? types_js_1.DiagnosticModel.Push) !== types_js_1.DiagnosticModel.Push) {
|
|
274
250
|
return;
|
|
251
|
+
}
|
|
275
252
|
const req = ++documentUpdatedReq;
|
|
276
253
|
const delay = 250;
|
|
277
254
|
const token = {
|
|
@@ -300,12 +277,12 @@ function createServer(connection, getRuntimeEnv) {
|
|
|
300
277
|
async function sendDocumentDiagnostics(uri, version, cancel) {
|
|
301
278
|
const languageService = (await projects.getProject(uri)).getLanguageService();
|
|
302
279
|
const errors = await languageService.doValidation(uri, cancel, result => {
|
|
303
|
-
context.
|
|
280
|
+
context.connection.sendDiagnostics({ uri: uri, diagnostics: result, version });
|
|
304
281
|
});
|
|
305
|
-
context.
|
|
282
|
+
context.connection.sendDiagnostics({ uri: uri, diagnostics: errors, version });
|
|
306
283
|
}
|
|
307
284
|
}
|
|
308
|
-
exports.
|
|
285
|
+
exports.createServerBase = createServerBase;
|
|
309
286
|
function sleep(ms) {
|
|
310
287
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
311
288
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import type { Console, FileSystem, LanguageService, ServiceEnvironment } from '@volar/language-service';
|
|
2
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
1
|
+
import type { Console, FileSystem, LanguageService, ServiceEnvironment, ServicePlugin, TypeScriptProjectHost } from '@volar/language-service';
|
|
3
2
|
import type * as vscode from 'vscode-languageserver';
|
|
3
|
+
import type { ServerContext, ServerOptions } from './server';
|
|
4
|
+
import type { createSys } from '@volar/typescript';
|
|
4
5
|
export interface Timer {
|
|
5
6
|
setImmediate(callback: (...args: any[]) => void, ...args: any[]): vscode.Disposable;
|
|
6
7
|
}
|
|
7
8
|
export interface ServerRuntimeEnvironment {
|
|
8
9
|
uriToFileName(uri: string): string;
|
|
9
10
|
fileNameToUri(fileName: string): string;
|
|
10
|
-
loadTypeScript(options: InitializationOptions): Promise<typeof import('typescript
|
|
11
|
+
loadTypeScript(options: InitializationOptions): Promise<typeof import('typescript') | undefined>;
|
|
11
12
|
loadTypeScriptLocalized(options: InitializationOptions, locale: string): Promise<{} | undefined>;
|
|
12
13
|
fs: FileSystem;
|
|
13
14
|
timer: Timer;
|
|
@@ -16,7 +17,8 @@ export interface ServerRuntimeEnvironment {
|
|
|
16
17
|
export interface ProjectContext {
|
|
17
18
|
typescript?: {
|
|
18
19
|
configFileName: string | undefined;
|
|
19
|
-
|
|
20
|
+
host: TypeScriptProjectHost;
|
|
21
|
+
sys: ReturnType<typeof createSys>;
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
export declare enum DiagnosticModel {
|
|
@@ -69,3 +71,6 @@ export interface ServerProjectProvider {
|
|
|
69
71
|
getProjects(): Promise<ServerProject[]>;
|
|
70
72
|
reloadProjects(): Promise<void> | void;
|
|
71
73
|
}
|
|
74
|
+
export interface ServerProjectProviderFactory {
|
|
75
|
+
(context: ServerContext, serverOptions: ServerOptions, servicePlugins: ServicePlugin[]): ServerProjectProvider;
|
|
76
|
+
}
|
package/lib/utils/uriMap.js
CHANGED
|
@@ -20,8 +20,9 @@ function createUriMap(fileNameToUri, map = new Map()) {
|
|
|
20
20
|
pathSet,
|
|
21
21
|
};
|
|
22
22
|
function getUriByUri(uri) {
|
|
23
|
-
if (!uriToUri.has(uri))
|
|
23
|
+
if (!uriToUri.has(uri)) {
|
|
24
24
|
uriToUri.set(uri, normalizeUri(uri).toLowerCase());
|
|
25
|
+
}
|
|
25
26
|
return uriToUri.get(uri);
|
|
26
27
|
}
|
|
27
28
|
function getUriByPath(path) {
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { URI } from 'vscode-uri';
|
|
2
2
|
export type WorkspaceFolderManager = ReturnType<typeof createWorkspaceFolderManager>;
|
|
3
3
|
export declare function createWorkspaceFolderManager(): {
|
|
4
|
-
add(folder:
|
|
5
|
-
remove(folder:
|
|
6
|
-
getAll():
|
|
7
|
-
|
|
8
|
-
uri: import("vscode-uri").URI;
|
|
9
|
-
}[];
|
|
10
|
-
onDidAdd(cb: (folder: ServiceEnvironment['workspaceFolder']) => void): {
|
|
4
|
+
add(folder: URI): void;
|
|
5
|
+
remove(folder: URI): void;
|
|
6
|
+
getAll(): URI[];
|
|
7
|
+
onDidAdd(cb: (folder: URI) => void): {
|
|
11
8
|
dispose(): void;
|
|
12
9
|
};
|
|
13
|
-
onDidRemove(cb: (folder:
|
|
10
|
+
onDidRemove(cb: (folder: URI) => void): {
|
|
14
11
|
dispose(): void;
|
|
15
12
|
};
|
|
16
13
|
};
|
|
@@ -7,12 +7,12 @@ function createWorkspaceFolderManager() {
|
|
|
7
7
|
const onDidRemoveCallbacks = new Set();
|
|
8
8
|
return {
|
|
9
9
|
add(folder) {
|
|
10
|
-
if (!folders.some(
|
|
10
|
+
if (!folders.some(uri => uri.toString() === folder.toString())) {
|
|
11
11
|
folders.push(folder);
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
remove(folder) {
|
|
15
|
-
folders = folders.filter(
|
|
15
|
+
folders = folders.filter(uri => uri.toString() !== folder.toString());
|
|
16
16
|
},
|
|
17
17
|
getAll() {
|
|
18
18
|
return folders;
|
package/node.d.ts
CHANGED
|
@@ -9,8 +9,10 @@ export declare const uriToFileName: (uri: string) => string;
|
|
|
9
9
|
export declare const fileNameToUri: (fileName: string) => string;
|
|
10
10
|
export declare function createFs(options: InitializationOptions): FileSystem;
|
|
11
11
|
export declare function createConnection(): vscode._Connection<vscode._, vscode._, vscode._, vscode._, vscode._, vscode._, import("vscode-languageserver/lib/common/inlineCompletion.proposed").InlineCompletionFeatureShape, vscode._>;
|
|
12
|
-
export declare function
|
|
13
|
-
initialize: (
|
|
12
|
+
export declare function createServer(connection: vscode.Connection): {
|
|
13
|
+
initialize: (params: Omit<vscode.InitializeParams, "initializationOptions"> & {
|
|
14
|
+
initializationOptions?: InitializationOptions | undefined;
|
|
15
|
+
}, projectProviderFactory: import("./index").ServerProjectProviderFactory, _serverOptions: import("./lib/server").ServerOptions) => Promise<vscode.InitializeResult<any>>;
|
|
14
16
|
initialized: () => void;
|
|
15
17
|
shutdown: () => void;
|
|
16
18
|
readonly projects: import("./index").ServerProjectProvider;
|
package/node.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.createServer = exports.createConnection = exports.createFs = exports.fileNameToUri = exports.uriToFileName = void 0;
|
|
18
18
|
const language_service_1 = require("@volar/language-service");
|
|
19
19
|
const fs = require("fs");
|
|
20
20
|
const vscode = require("vscode-languageserver/node");
|
|
@@ -97,8 +97,8 @@ function createConnection() {
|
|
|
97
97
|
return vscode.createConnection(vscode.ProposedFeatures.all);
|
|
98
98
|
}
|
|
99
99
|
exports.createConnection = createConnection;
|
|
100
|
-
function
|
|
101
|
-
return (0, server_1.
|
|
100
|
+
function createServer(connection) {
|
|
101
|
+
return (0, server_1.createServerBase)(connection, params => ({
|
|
102
102
|
uriToFileName: exports.uriToFileName,
|
|
103
103
|
fileNameToUri: exports.fileNameToUri,
|
|
104
104
|
console: connection.console,
|
|
@@ -143,8 +143,8 @@ function createNodeServer(connection) {
|
|
|
143
143
|
}
|
|
144
144
|
catch { }
|
|
145
145
|
},
|
|
146
|
-
fs: createFs(
|
|
146
|
+
fs: createFs(params.initializationOptions ?? {}),
|
|
147
147
|
}));
|
|
148
148
|
}
|
|
149
|
-
exports.
|
|
149
|
+
exports.createServer = createServer;
|
|
150
150
|
//# sourceMappingURL=node.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
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.0.
|
|
16
|
-
"@volar/language-service": "2.0.
|
|
17
|
-
"@volar/snapshot-document": "2.0.
|
|
18
|
-
"@volar/typescript": "2.0.
|
|
15
|
+
"@volar/language-core": "2.0.1",
|
|
16
|
+
"@volar/language-service": "2.0.1",
|
|
17
|
+
"@volar/snapshot-document": "2.0.1",
|
|
18
|
+
"@volar/typescript": "2.0.1",
|
|
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": "b1fbf6eed522624ccccfb17a8999edfbc1d8d9bb"
|
|
31
31
|
}
|
package/protocol.d.ts
CHANGED
|
@@ -86,10 +86,10 @@ export declare namespace DocumentDrop_DataTransferItemFileDataRequest {
|
|
|
86
86
|
/**
|
|
87
87
|
* Labs
|
|
88
88
|
*/
|
|
89
|
-
export declare namespace
|
|
89
|
+
export declare namespace UpdateVirtualCodeStateNotification {
|
|
90
90
|
type ParamsType = {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
fileUri: string;
|
|
92
|
+
virtualCodeId: string;
|
|
93
93
|
disabled: boolean;
|
|
94
94
|
};
|
|
95
95
|
const type: vscode.NotificationType<ParamsType>;
|
|
@@ -113,24 +113,24 @@ export declare namespace GetServicePluginsRequest {
|
|
|
113
113
|
type ErrorType = never;
|
|
114
114
|
const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
|
|
115
115
|
}
|
|
116
|
-
export declare namespace
|
|
117
|
-
type
|
|
118
|
-
|
|
116
|
+
export declare namespace GetVirtualFileRequest {
|
|
117
|
+
type VirtualCodeInfo = {
|
|
118
|
+
fileUri: string;
|
|
119
|
+
virtualCodeId: string;
|
|
119
120
|
languageId: string;
|
|
120
|
-
tsScriptKind?: number;
|
|
121
121
|
version: number;
|
|
122
122
|
disabled: boolean;
|
|
123
|
-
|
|
123
|
+
embeddedCodes: VirtualCodeInfo[];
|
|
124
124
|
};
|
|
125
125
|
type ParamsType = vscode.TextDocumentIdentifier;
|
|
126
|
-
type ResponseType =
|
|
126
|
+
type ResponseType = VirtualCodeInfo | null | undefined;
|
|
127
127
|
type ErrorType = never;
|
|
128
128
|
const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
|
|
129
129
|
}
|
|
130
|
-
export declare namespace
|
|
130
|
+
export declare namespace GetVirtualCodeRequest {
|
|
131
131
|
type ParamsType = {
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
fileUri: string;
|
|
133
|
+
virtualCodeId: string;
|
|
134
134
|
};
|
|
135
135
|
type ResponseType = {
|
|
136
136
|
content: string;
|
package/protocol.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoadedTSFilesMetaRequest = exports.
|
|
3
|
+
exports.LoadedTSFilesMetaRequest = exports.GetVirtualCodeRequest = exports.GetVirtualFileRequest = exports.GetServicePluginsRequest = exports.UpdateServicePluginStateNotification = exports.UpdateVirtualCodeStateNotification = exports.DocumentDrop_DataTransferItemFileDataRequest = exports.DocumentDrop_DataTransferItemAsStringRequest = exports.DocumentDropRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsStatRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = void 0;
|
|
4
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
5
5
|
/**
|
|
6
6
|
* Server request client
|
|
@@ -58,10 +58,10 @@ var DocumentDrop_DataTransferItemFileDataRequest;
|
|
|
58
58
|
/**
|
|
59
59
|
* Labs
|
|
60
60
|
*/
|
|
61
|
-
var
|
|
62
|
-
(function (
|
|
63
|
-
|
|
64
|
-
})(
|
|
61
|
+
var UpdateVirtualCodeStateNotification;
|
|
62
|
+
(function (UpdateVirtualCodeStateNotification) {
|
|
63
|
+
UpdateVirtualCodeStateNotification.type = new vscode.NotificationType('volar/client/labs/updateVirtualFileState');
|
|
64
|
+
})(UpdateVirtualCodeStateNotification || (exports.UpdateVirtualCodeStateNotification = UpdateVirtualCodeStateNotification = {}));
|
|
65
65
|
var UpdateServicePluginStateNotification;
|
|
66
66
|
(function (UpdateServicePluginStateNotification) {
|
|
67
67
|
UpdateServicePluginStateNotification.type = new vscode.NotificationType('volar/client/labs/updateServicePluginState');
|
|
@@ -70,14 +70,14 @@ var GetServicePluginsRequest;
|
|
|
70
70
|
(function (GetServicePluginsRequest) {
|
|
71
71
|
GetServicePluginsRequest.type = new vscode.RequestType('volar/client/servicePlugins');
|
|
72
72
|
})(GetServicePluginsRequest || (exports.GetServicePluginsRequest = GetServicePluginsRequest = {}));
|
|
73
|
-
var GetVirtualFilesRequest;
|
|
74
|
-
(function (GetVirtualFilesRequest) {
|
|
75
|
-
GetVirtualFilesRequest.type = new vscode.RequestType('volar/client/virtualFiles');
|
|
76
|
-
})(GetVirtualFilesRequest || (exports.GetVirtualFilesRequest = GetVirtualFilesRequest = {}));
|
|
77
73
|
var GetVirtualFileRequest;
|
|
78
74
|
(function (GetVirtualFileRequest) {
|
|
79
|
-
GetVirtualFileRequest.type = new vscode.RequestType('volar/client/
|
|
75
|
+
GetVirtualFileRequest.type = new vscode.RequestType('volar/client/virtualFiles');
|
|
80
76
|
})(GetVirtualFileRequest || (exports.GetVirtualFileRequest = GetVirtualFileRequest = {}));
|
|
77
|
+
var GetVirtualCodeRequest;
|
|
78
|
+
(function (GetVirtualCodeRequest) {
|
|
79
|
+
GetVirtualCodeRequest.type = new vscode.RequestType('volar/client/virtualFile');
|
|
80
|
+
})(GetVirtualCodeRequest || (exports.GetVirtualCodeRequest = GetVirtualCodeRequest = {}));
|
|
81
81
|
var LoadedTSFilesMetaRequest;
|
|
82
82
|
(function (LoadedTSFilesMetaRequest) {
|
|
83
83
|
LoadedTSFilesMetaRequest.type = new vscode.RequestType0('volar/client/loadedTsFiles');
|
package/lib/cancellationToken.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createGetCancellationToken = void 0;
|
|
4
|
-
const vscode = require("vscode-languageserver");
|
|
5
|
-
function createGetCancellationToken(fs, _cancellationPipeName) {
|
|
6
|
-
if (_cancellationPipeName === undefined) {
|
|
7
|
-
return (original) => {
|
|
8
|
-
return original ?? vscode.CancellationToken.None;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
const cancellationPipeName = _cancellationPipeName;
|
|
12
|
-
return getCancellationToken;
|
|
13
|
-
function getCancellationToken(original) {
|
|
14
|
-
const mtime = getMtime();
|
|
15
|
-
let currentMtime = mtime;
|
|
16
|
-
let updateAt = Date.now();
|
|
17
|
-
const token = {
|
|
18
|
-
get isCancellationRequested() {
|
|
19
|
-
if (original?.isCancellationRequested) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
// debounce 20ms
|
|
23
|
-
if (currentMtime === mtime && Date.now() - updateAt >= 20) {
|
|
24
|
-
currentMtime = getMtime();
|
|
25
|
-
updateAt = Date.now();
|
|
26
|
-
}
|
|
27
|
-
return currentMtime !== mtime;
|
|
28
|
-
},
|
|
29
|
-
onCancellationRequested: vscode.Event.None,
|
|
30
|
-
};
|
|
31
|
-
return token;
|
|
32
|
-
}
|
|
33
|
-
function getMtime() {
|
|
34
|
-
try {
|
|
35
|
-
const stat = fs.statSync(cancellationPipeName, { throwIfNoEntry: false });
|
|
36
|
-
return stat?.mtime.valueOf() ?? -1;
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
return -1;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.createGetCancellationToken = createGetCancellationToken;
|
|
44
|
-
//# sourceMappingURL=cancellationToken.js.map
|
package/lib/config.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadConfig = exports.getConfig = void 0;
|
|
4
|
-
async function getConfig(context, plugins, env, projectCtx) {
|
|
5
|
-
let config = (env.workspaceFolder.uri.scheme === 'file' ? loadConfig(context.server.runtimeEnv.console, context.server.runtimeEnv.uriToFileName(env.workspaceFolder.uri.toString()), context.workspaces.initOptions.configFilePath) : {}) ?? {};
|
|
6
|
-
for (const plugin of plugins) {
|
|
7
|
-
if (plugin.resolveConfig) {
|
|
8
|
-
config = await plugin.resolveConfig(config, env, projectCtx);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return config;
|
|
12
|
-
}
|
|
13
|
-
exports.getConfig = getConfig;
|
|
14
|
-
function loadConfig(console, dir, configFile) {
|
|
15
|
-
let configPath;
|
|
16
|
-
try {
|
|
17
|
-
configPath = require.resolve(configFile ?? './volar.config.js', { paths: [dir] });
|
|
18
|
-
}
|
|
19
|
-
catch { }
|
|
20
|
-
try {
|
|
21
|
-
if (configPath) {
|
|
22
|
-
const config = require(configPath);
|
|
23
|
-
delete require.cache[configPath];
|
|
24
|
-
return config;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
console.warn(String(err));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.loadConfig = loadConfig;
|
|
32
|
-
//# sourceMappingURL=config.js.map
|