@volar/language-server 2.0.0-alpha.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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.d.ts +1 -1
- package/lib/register/registerEditorFeatures.js +84 -33
- 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 +61 -23
- package/protocol.js +28 -13
- package/lib/cancellationToken.d.ts +0 -3
- package/lib/cancellationToken.js +0 -44
- package/lib/config.js +0 -32
package/lib/server.d.ts
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
import { LanguagePlugin, ServiceEnvironment, ServicePlugin } from '@volar/language-service';
|
|
2
2
|
import * as vscode from 'vscode-languageserver';
|
|
3
|
-
import { InitializationOptions, ProjectContext, ServerProjectProvider, ServerRuntimeEnvironment } from './types.js';
|
|
3
|
+
import { InitializationOptions, ProjectContext, ServerProjectProvider, ServerProjectProviderFactory, ServerRuntimeEnvironment } from './types.js';
|
|
4
4
|
import { createConfigurationHost } from './configurationHost.js';
|
|
5
|
-
import
|
|
5
|
+
import { WorkspaceFolderManager } from './workspaceFolderManager.js';
|
|
6
|
+
import { SnapshotDocument } from '@volar/snapshot-document';
|
|
7
|
+
import type * as ts from 'typescript';
|
|
8
|
+
import type { TextDocuments } from 'vscode-languageserver';
|
|
6
9
|
export interface ServerContext {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
runtimeEnv: ServerRuntimeEnvironment;
|
|
11
|
-
onDidChangeWatchedFiles: vscode.Connection['onDidChangeWatchedFiles'];
|
|
12
|
-
configurationHost: ReturnType<typeof createConfigurationHost> | undefined;
|
|
10
|
+
connection: vscode.Connection;
|
|
11
|
+
initializeParams: Omit<vscode.InitializeParams, 'initializationOptions'> & {
|
|
12
|
+
initializationOptions?: InitializationOptions;
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
runtimeEnv: ServerRuntimeEnvironment;
|
|
15
|
+
onDidChangeWatchedFiles: vscode.Connection['onDidChangeWatchedFiles'];
|
|
16
|
+
configurationHost: ReturnType<typeof createConfigurationHost> | undefined;
|
|
17
|
+
ts: typeof import('typescript') | undefined;
|
|
18
|
+
tsLocalized: ts.MapLike<string> | undefined;
|
|
19
|
+
workspaceFolders: WorkspaceFolderManager;
|
|
20
|
+
documents: TextDocuments<SnapshotDocument>;
|
|
21
|
+
reloadDiagnostics(): void;
|
|
22
|
+
updateDiagnosticsAndSemanticTokens(): void;
|
|
21
23
|
}
|
|
22
24
|
export interface ServerOptions {
|
|
23
25
|
watchFileExtensions?: string[];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
getServicePlugins(): ServicePlugin[] | Promise<ServicePlugin[]>;
|
|
27
|
+
getLanguagePlugins(serviceEnv: ServiceEnvironment, projectContext: ProjectContext): LanguagePlugin[] | Promise<LanguagePlugin[]>;
|
|
26
28
|
}
|
|
27
|
-
export declare function
|
|
28
|
-
initialize: (
|
|
29
|
+
export declare function createServerBase(connection: vscode.Connection, getRuntimeEnv: (params: ServerContext['initializeParams']) => ServerRuntimeEnvironment): {
|
|
30
|
+
initialize: (params: ServerContext['initializeParams'], projectProviderFactory: ServerProjectProviderFactory, _serverOptions: ServerOptions) => Promise<vscode.InitializeResult<any>>;
|
|
29
31
|
initialized: () => void;
|
|
30
32
|
shutdown: () => void;
|
|
31
33
|
readonly projects: ServerProjectProvider;
|
|
32
34
|
readonly env: ServerRuntimeEnvironment;
|
|
33
35
|
readonly modules: {
|
|
34
|
-
typescript: typeof
|
|
36
|
+
typescript: typeof ts | undefined;
|
|
35
37
|
};
|
|
36
38
|
};
|
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.0
|
|
3
|
+
"version": "2.0.0",
|
|
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.0
|
|
16
|
-
"@volar/language-service": "2.0.0
|
|
17
|
-
"@volar/snapshot-document": "2.0.0
|
|
18
|
-
"@volar/typescript": "2.0.0
|
|
15
|
+
"@volar/language-core": "2.0.0",
|
|
16
|
+
"@volar/language-service": "2.0.0",
|
|
17
|
+
"@volar/snapshot-document": "2.0.0",
|
|
18
|
+
"@volar/typescript": "2.0.0",
|
|
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": "95217136d2727bb7304443d91cfde3dbe711369c"
|
|
31
31
|
}
|
package/protocol.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CodeMapping, Stack
|
|
1
|
+
import type { CodeMapping, Stack } from '@volar/language-core';
|
|
2
2
|
import type { FileStat, FileType, DocumentDropEdit } from '@volar/language-service';
|
|
3
3
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
4
4
|
/**
|
|
@@ -43,34 +43,12 @@ export declare namespace AutoInsertRequest {
|
|
|
43
43
|
type ErrorType = never;
|
|
44
44
|
const type: vscode.RequestType<ParamsType, ResponseType, never>;
|
|
45
45
|
}
|
|
46
|
-
export declare namespace LoadedTSFilesMetaRequest {
|
|
47
|
-
const type: vscode.RequestType0<unknown, unknown>;
|
|
48
|
-
}
|
|
49
46
|
export declare namespace WriteVirtualFilesNotification {
|
|
50
47
|
const type: vscode.NotificationType<vscode.TextDocumentIdentifier>;
|
|
51
48
|
}
|
|
52
49
|
export declare namespace ReloadProjectNotification {
|
|
53
50
|
const type: vscode.NotificationType<vscode.TextDocumentIdentifier>;
|
|
54
51
|
}
|
|
55
|
-
export declare namespace GetVirtualFilesRequest {
|
|
56
|
-
type ParamsType = vscode.TextDocumentIdentifier;
|
|
57
|
-
type ResponseType = VirtualFile | null | undefined;
|
|
58
|
-
type ErrorType = never;
|
|
59
|
-
const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
|
|
60
|
-
}
|
|
61
|
-
export declare namespace GetVirtualFileRequest {
|
|
62
|
-
type ParamsType = {
|
|
63
|
-
sourceFileUri: string;
|
|
64
|
-
virtualFileName: string;
|
|
65
|
-
};
|
|
66
|
-
type ResponseType = {
|
|
67
|
-
content: string;
|
|
68
|
-
mappings: Record<string, CodeMapping[]>;
|
|
69
|
-
codegenStacks: Stack[];
|
|
70
|
-
};
|
|
71
|
-
type ErrorType = never;
|
|
72
|
-
const type: vscode.RequestType<ParamsType, ResponseType, never>;
|
|
73
|
-
}
|
|
74
52
|
/**
|
|
75
53
|
* Document Drop
|
|
76
54
|
*/
|
|
@@ -105,3 +83,63 @@ export declare namespace DocumentDrop_DataTransferItemFileDataRequest {
|
|
|
105
83
|
type ErrorType = never;
|
|
106
84
|
const type: vscode.RequestType<ParamsType, Uint8Array, never>;
|
|
107
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Labs
|
|
88
|
+
*/
|
|
89
|
+
export declare namespace UpdateVirtualCodeStateNotification {
|
|
90
|
+
type ParamsType = {
|
|
91
|
+
fileUri: string;
|
|
92
|
+
virtualCodeId: string;
|
|
93
|
+
disabled: boolean;
|
|
94
|
+
};
|
|
95
|
+
const type: vscode.NotificationType<ParamsType>;
|
|
96
|
+
}
|
|
97
|
+
export declare namespace UpdateServicePluginStateNotification {
|
|
98
|
+
type ParamsType = {
|
|
99
|
+
uri: string;
|
|
100
|
+
serviceId: string;
|
|
101
|
+
disabled: boolean;
|
|
102
|
+
};
|
|
103
|
+
const type: vscode.NotificationType<ParamsType>;
|
|
104
|
+
}
|
|
105
|
+
export declare namespace GetServicePluginsRequest {
|
|
106
|
+
type ParamsType = vscode.TextDocumentIdentifier;
|
|
107
|
+
type ResponseType = {
|
|
108
|
+
id: string;
|
|
109
|
+
name?: string;
|
|
110
|
+
features: string[];
|
|
111
|
+
disabled: boolean;
|
|
112
|
+
}[] | null | undefined;
|
|
113
|
+
type ErrorType = never;
|
|
114
|
+
const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
|
|
115
|
+
}
|
|
116
|
+
export declare namespace GetVirtualFileRequest {
|
|
117
|
+
type VirtualCodeInfo = {
|
|
118
|
+
fileUri: string;
|
|
119
|
+
virtualCodeId: string;
|
|
120
|
+
languageId: string;
|
|
121
|
+
version: number;
|
|
122
|
+
disabled: boolean;
|
|
123
|
+
embeddedCodes: VirtualCodeInfo[];
|
|
124
|
+
};
|
|
125
|
+
type ParamsType = vscode.TextDocumentIdentifier;
|
|
126
|
+
type ResponseType = VirtualCodeInfo | null | undefined;
|
|
127
|
+
type ErrorType = never;
|
|
128
|
+
const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
|
|
129
|
+
}
|
|
130
|
+
export declare namespace GetVirtualCodeRequest {
|
|
131
|
+
type ParamsType = {
|
|
132
|
+
fileUri: string;
|
|
133
|
+
virtualCodeId: string;
|
|
134
|
+
};
|
|
135
|
+
type ResponseType = {
|
|
136
|
+
content: string;
|
|
137
|
+
mappings: Record<string, CodeMapping[]>;
|
|
138
|
+
codegenStacks: Stack[];
|
|
139
|
+
};
|
|
140
|
+
type ErrorType = never;
|
|
141
|
+
const type: vscode.RequestType<ParamsType, ResponseType, never>;
|
|
142
|
+
}
|
|
143
|
+
export declare namespace LoadedTSFilesMetaRequest {
|
|
144
|
+
const type: vscode.RequestType0<unknown, unknown>;
|
|
145
|
+
}
|