@volar/language-server 2.0.0-alpha.8 → 2.0.0-alpha.9
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/lib/register/registerEditorFeatures.d.ts +1 -1
- package/lib/register/registerEditorFeatures.js +52 -10
- package/package.json +6 -6
- package/protocol.d.ts +61 -23
- package/protocol.js +28 -13
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver';
|
|
2
2
|
import type { ServerProjectProvider, ServerRuntimeEnvironment } from '../types';
|
|
3
|
-
export declare function registerEditorFeatures(connection: vscode.Connection,
|
|
3
|
+
export declare function registerEditorFeatures(connection: vscode.Connection, projects: ServerProjectProvider, env: ServerRuntimeEnvironment): void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerEditorFeatures = void 0;
|
|
4
4
|
const protocol_1 = require("../../protocol");
|
|
5
|
-
function registerEditorFeatures(connection,
|
|
5
|
+
function registerEditorFeatures(connection, projects, env) {
|
|
6
6
|
const scriptVersions = new Map();
|
|
7
7
|
const scriptVersionSnapshots = new WeakSet();
|
|
8
8
|
connection.onRequest(protocol_1.DocumentDropRequest.type, async ({ textDocument, position, dataTransfer }, token) => {
|
|
@@ -26,18 +26,18 @@ function registerEditorFeatures(connection, projectProvider, env) {
|
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
const languageService = (await
|
|
29
|
+
const languageService = (await projects.getProject(textDocument.uri)).getLanguageService();
|
|
30
30
|
return languageService.doDocumentDrop(textDocument.uri, position, dataTransferMap, token);
|
|
31
31
|
});
|
|
32
32
|
connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, async (params) => {
|
|
33
|
-
const languageService = (await
|
|
33
|
+
const languageService = (await projects.getProject(params.uri)).getLanguageService();
|
|
34
34
|
const configFileName = languageService.context.language.typescript?.configFileName;
|
|
35
35
|
if (configFileName) {
|
|
36
36
|
return { uri: env.fileNameToUri(configFileName) };
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
connection.onRequest(protocol_1.GetVirtualFilesRequest.type, async (document) => {
|
|
40
|
-
const languageService = (await
|
|
40
|
+
const languageService = (await projects.getProject(document.uri)).getLanguageService();
|
|
41
41
|
const virtualFile = languageService.context.language.files.getSourceFile(env.uriToFileName(document.uri))?.virtualFile;
|
|
42
42
|
return virtualFile ? prune(virtualFile[0]) : undefined;
|
|
43
43
|
function prune(file) {
|
|
@@ -50,15 +50,15 @@ function registerEditorFeatures(connection, projectProvider, env) {
|
|
|
50
50
|
return {
|
|
51
51
|
fileName: file.fileName,
|
|
52
52
|
languageId: file.languageId,
|
|
53
|
-
|
|
53
|
+
tsScriptKind: file.typescript?.scriptKind,
|
|
54
54
|
embeddedFiles: file.embeddedFiles.map(prune),
|
|
55
|
-
// @ts-expect-error
|
|
56
55
|
version,
|
|
56
|
+
disabled: languageService.context.disabledVirtualFiles.has(file.fileName),
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
connection.onRequest(protocol_1.GetVirtualFileRequest.type, async (params) => {
|
|
61
|
-
const languageService = (await
|
|
61
|
+
const languageService = (await projects.getProject(params.sourceFileUri)).getLanguageService();
|
|
62
62
|
let content = '';
|
|
63
63
|
let codegenStacks = [];
|
|
64
64
|
const mappings = {};
|
|
@@ -77,12 +77,12 @@ function registerEditorFeatures(connection, projectProvider, env) {
|
|
|
77
77
|
};
|
|
78
78
|
});
|
|
79
79
|
connection.onNotification(protocol_1.ReloadProjectNotification.type, () => {
|
|
80
|
-
|
|
80
|
+
projects.reloadProjects();
|
|
81
81
|
});
|
|
82
82
|
connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, async (params) => {
|
|
83
83
|
const fsModeName = 'fs'; // avoid bundle
|
|
84
84
|
const fs = await import(fsModeName);
|
|
85
|
-
const languageService = (await
|
|
85
|
+
const languageService = (await projects.getProject(params.uri)).getLanguageService();
|
|
86
86
|
if (languageService.context.language.typescript?.languageServiceHost) {
|
|
87
87
|
const rootUri = languageService.context.env.workspaceFolder.uri.toString();
|
|
88
88
|
const rootPath = languageService.context.env.uriToFileName(rootUri);
|
|
@@ -107,7 +107,7 @@ function registerEditorFeatures(connection, projectProvider, env) {
|
|
|
107
107
|
});
|
|
108
108
|
connection.onRequest(protocol_1.LoadedTSFilesMetaRequest.type, async () => {
|
|
109
109
|
const sourceFilesData = new Map();
|
|
110
|
-
for (const project of await
|
|
110
|
+
for (const project of await projects.getProjects()) {
|
|
111
111
|
const languageService = project.getLanguageService();
|
|
112
112
|
const tsLanguageService = languageService.context.inject('typescript/languageService');
|
|
113
113
|
const program = tsLanguageService?.getProgram();
|
|
@@ -152,6 +152,48 @@ function registerEditorFeatures(connection, projectProvider, env) {
|
|
|
152
152
|
}
|
|
153
153
|
return result;
|
|
154
154
|
});
|
|
155
|
+
connection.onNotification(protocol_1.UpdateVirtualFileStateNotification.type, async (params) => {
|
|
156
|
+
const project = await projects.getProject(params.uri);
|
|
157
|
+
const context = project.getLanguageServiceDontCreate()?.context;
|
|
158
|
+
if (context) {
|
|
159
|
+
if (params.disabled) {
|
|
160
|
+
context.disabledVirtualFiles.add(params.virtualFileName);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
context.disabledVirtualFiles.delete(params.virtualFileName);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
connection.onNotification(protocol_1.UpdateServicePluginStateNotification.type, async (params) => {
|
|
168
|
+
const project = await projects.getProject(params.uri);
|
|
169
|
+
const context = project.getLanguageServiceDontCreate()?.context;
|
|
170
|
+
if (context) {
|
|
171
|
+
const service = context.services[params.serviceId][1];
|
|
172
|
+
if (params.disabled) {
|
|
173
|
+
context.disabledServicePlugins.add(service);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
context.disabledServicePlugins.delete(service);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
connection.onRequest(protocol_1.GetServicePluginsRequest.type, async (params) => {
|
|
181
|
+
const project = await projects.getProject(params.uri);
|
|
182
|
+
const context = project.getLanguageServiceDontCreate()?.context;
|
|
183
|
+
if (context) {
|
|
184
|
+
const result = [];
|
|
185
|
+
for (let id in context.services) {
|
|
186
|
+
const service = context.services[id];
|
|
187
|
+
result.push({
|
|
188
|
+
id,
|
|
189
|
+
name: service[0].name,
|
|
190
|
+
disabled: context.disabledServicePlugins.has(service[1]),
|
|
191
|
+
features: Object.keys(service[1]),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
155
197
|
}
|
|
156
198
|
exports.registerEditorFeatures = registerEditorFeatures;
|
|
157
199
|
//# sourceMappingURL=registerEditorFeatures.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.9",
|
|
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-alpha.
|
|
16
|
-
"@volar/language-service": "2.0.0-alpha.
|
|
17
|
-
"@volar/snapshot-document": "2.0.0-alpha.
|
|
18
|
-
"@volar/typescript": "2.0.0-alpha.
|
|
15
|
+
"@volar/language-core": "2.0.0-alpha.9",
|
|
16
|
+
"@volar/language-service": "2.0.0-alpha.9",
|
|
17
|
+
"@volar/snapshot-document": "2.0.0-alpha.9",
|
|
18
|
+
"@volar/typescript": "2.0.0-alpha.9",
|
|
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": "dcd70c78b0b6901901dc0e68223e34dd922f5fdc"
|
|
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 UpdateVirtualFileStateNotification {
|
|
90
|
+
type ParamsType = {
|
|
91
|
+
uri: string;
|
|
92
|
+
virtualFileName: 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 GetVirtualFilesRequest {
|
|
117
|
+
type VirtualFileWithState = {
|
|
118
|
+
fileName: string;
|
|
119
|
+
languageId: string;
|
|
120
|
+
tsScriptKind?: number;
|
|
121
|
+
version: number;
|
|
122
|
+
disabled: boolean;
|
|
123
|
+
embeddedFiles: VirtualFileWithState[];
|
|
124
|
+
};
|
|
125
|
+
type ParamsType = vscode.TextDocumentIdentifier;
|
|
126
|
+
type ResponseType = VirtualFileWithState | null | undefined;
|
|
127
|
+
type ErrorType = never;
|
|
128
|
+
const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
|
|
129
|
+
}
|
|
130
|
+
export declare namespace GetVirtualFileRequest {
|
|
131
|
+
type ParamsType = {
|
|
132
|
+
sourceFileUri: string;
|
|
133
|
+
virtualFileName: 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
|
+
}
|
package/protocol.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LoadedTSFilesMetaRequest = exports.GetVirtualFileRequest = exports.GetVirtualFilesRequest = exports.GetServicePluginsRequest = exports.UpdateServicePluginStateNotification = exports.UpdateVirtualFileStateNotification = 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
|
|
@@ -32,10 +32,6 @@ var AutoInsertRequest;
|
|
|
32
32
|
(function (AutoInsertRequest) {
|
|
33
33
|
AutoInsertRequest.type = new vscode.RequestType('volar/client/autoInsert');
|
|
34
34
|
})(AutoInsertRequest || (exports.AutoInsertRequest = AutoInsertRequest = {}));
|
|
35
|
-
var LoadedTSFilesMetaRequest;
|
|
36
|
-
(function (LoadedTSFilesMetaRequest) {
|
|
37
|
-
LoadedTSFilesMetaRequest.type = new vscode.RequestType0('volar/client/loadedTsFiles');
|
|
38
|
-
})(LoadedTSFilesMetaRequest || (exports.LoadedTSFilesMetaRequest = LoadedTSFilesMetaRequest = {}));
|
|
39
35
|
var WriteVirtualFilesNotification;
|
|
40
36
|
(function (WriteVirtualFilesNotification) {
|
|
41
37
|
WriteVirtualFilesNotification.type = new vscode.NotificationType('volar/client/writeVirtualFiles');
|
|
@@ -44,14 +40,6 @@ var ReloadProjectNotification;
|
|
|
44
40
|
(function (ReloadProjectNotification) {
|
|
45
41
|
ReloadProjectNotification.type = new vscode.NotificationType('volar/client/reloadProject');
|
|
46
42
|
})(ReloadProjectNotification || (exports.ReloadProjectNotification = ReloadProjectNotification = {}));
|
|
47
|
-
var GetVirtualFilesRequest;
|
|
48
|
-
(function (GetVirtualFilesRequest) {
|
|
49
|
-
GetVirtualFilesRequest.type = new vscode.RequestType('volar/client/virtualFiles');
|
|
50
|
-
})(GetVirtualFilesRequest || (exports.GetVirtualFilesRequest = GetVirtualFilesRequest = {}));
|
|
51
|
-
var GetVirtualFileRequest;
|
|
52
|
-
(function (GetVirtualFileRequest) {
|
|
53
|
-
GetVirtualFileRequest.type = new vscode.RequestType('volar/client/virtualFile');
|
|
54
|
-
})(GetVirtualFileRequest || (exports.GetVirtualFileRequest = GetVirtualFileRequest = {}));
|
|
55
43
|
/**
|
|
56
44
|
* Document Drop
|
|
57
45
|
*/
|
|
@@ -67,4 +55,31 @@ var DocumentDrop_DataTransferItemFileDataRequest;
|
|
|
67
55
|
(function (DocumentDrop_DataTransferItemFileDataRequest) {
|
|
68
56
|
DocumentDrop_DataTransferItemFileDataRequest.type = new vscode.RequestType('volar/client/documentDrop/fileData');
|
|
69
57
|
})(DocumentDrop_DataTransferItemFileDataRequest || (exports.DocumentDrop_DataTransferItemFileDataRequest = DocumentDrop_DataTransferItemFileDataRequest = {}));
|
|
58
|
+
/**
|
|
59
|
+
* Labs
|
|
60
|
+
*/
|
|
61
|
+
var UpdateVirtualFileStateNotification;
|
|
62
|
+
(function (UpdateVirtualFileStateNotification) {
|
|
63
|
+
UpdateVirtualFileStateNotification.type = new vscode.NotificationType('volar/client/labs/updateVirtualFileState');
|
|
64
|
+
})(UpdateVirtualFileStateNotification || (exports.UpdateVirtualFileStateNotification = UpdateVirtualFileStateNotification = {}));
|
|
65
|
+
var UpdateServicePluginStateNotification;
|
|
66
|
+
(function (UpdateServicePluginStateNotification) {
|
|
67
|
+
UpdateServicePluginStateNotification.type = new vscode.NotificationType('volar/client/labs/updateServicePluginState');
|
|
68
|
+
})(UpdateServicePluginStateNotification || (exports.UpdateServicePluginStateNotification = UpdateServicePluginStateNotification = {}));
|
|
69
|
+
var GetServicePluginsRequest;
|
|
70
|
+
(function (GetServicePluginsRequest) {
|
|
71
|
+
GetServicePluginsRequest.type = new vscode.RequestType('volar/client/servicePlugins');
|
|
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
|
+
var GetVirtualFileRequest;
|
|
78
|
+
(function (GetVirtualFileRequest) {
|
|
79
|
+
GetVirtualFileRequest.type = new vscode.RequestType('volar/client/virtualFile');
|
|
80
|
+
})(GetVirtualFileRequest || (exports.GetVirtualFileRequest = GetVirtualFileRequest = {}));
|
|
81
|
+
var LoadedTSFilesMetaRequest;
|
|
82
|
+
(function (LoadedTSFilesMetaRequest) {
|
|
83
|
+
LoadedTSFilesMetaRequest.type = new vscode.RequestType0('volar/client/loadedTsFiles');
|
|
84
|
+
})(LoadedTSFilesMetaRequest || (exports.LoadedTSFilesMetaRequest = LoadedTSFilesMetaRequest = {}));
|
|
70
85
|
//# sourceMappingURL=protocol.js.map
|