@volar/language-server 1.0.22 → 1.1.0-1.2.0-alpha.1.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/out/browser/fileSystems.js +15 -20
- package/out/browser/index.js +8 -3
- package/out/common/documents.d.ts +1 -0
- package/out/common/documents.js +3 -0
- package/out/common/features/customFeatures.js +12 -13
- package/out/common/features/languageFeatures.d.ts +2 -1
- package/out/common/features/languageFeatures.js +97 -82
- package/out/common/project.d.ts +2 -2
- package/out/common/project.js +78 -63
- package/out/common/server.js +28 -22
- package/out/common/utils/isFileInDir.d.ts +2 -0
- package/out/common/utils/isFileInDir.js +9 -0
- package/out/common/utils/registerFeatures.js +24 -55
- package/out/common/utils/serverConfig.d.ts +2 -5
- package/out/common/utils/serverConfig.js +3 -3
- package/out/common/utils/uriMap.js +1 -1
- package/out/common/workspace.js +14 -13
- package/out/common/workspaces.js +8 -4
- package/out/index.d.ts +1 -0
- package/out/index.js +1 -0
- package/out/node/fileSystem.js +1 -1
- package/out/node/index.js +8 -2
- package/out/protocol.js +12 -12
- package/out/types.d.ts +24 -7
- package/package.json +7 -6
|
@@ -37,7 +37,7 @@ function createWebFileSystemHost() {
|
|
|
37
37
|
connection = _connection;
|
|
38
38
|
connection.onDidChangeWatchedFiles(params => {
|
|
39
39
|
for (const change of params.changes) {
|
|
40
|
-
const fsPath = shared.
|
|
40
|
+
const fsPath = shared.uriToFileName(change.uri);
|
|
41
41
|
const dir = getDir(path.dirname(fsPath));
|
|
42
42
|
const name = path.basename(fsPath);
|
|
43
43
|
if (change.type === vscode.FileChangeType.Created) {
|
|
@@ -78,11 +78,11 @@ function createWebFileSystemHost() {
|
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
80
|
function createWorkspaceFileSystem(rootUri) {
|
|
81
|
-
const rootPath = shared.
|
|
81
|
+
const rootPath = shared.uriToFileName(rootUri.toString());
|
|
82
82
|
return {
|
|
83
83
|
newLine: '\n',
|
|
84
84
|
useCaseSensitiveFileNames: false,
|
|
85
|
-
getCurrentDirectory: () => shared.
|
|
85
|
+
getCurrentDirectory: () => shared.uriToFileName(rootUri.toString()),
|
|
86
86
|
fileExists,
|
|
87
87
|
readFile,
|
|
88
88
|
readDirectory,
|
|
@@ -169,9 +169,9 @@ function createWebFileSystemHost() {
|
|
|
169
169
|
}
|
|
170
170
|
function statAsync(connection, fsPath, dir) {
|
|
171
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
const uri = shared.
|
|
173
|
-
if (uri.startsWith('https://
|
|
174
|
-
const text = yield
|
|
172
|
+
const uri = shared.fileNameToUri(fsPath);
|
|
173
|
+
if (uri.startsWith('https://unpkg.com/')) { // stat request always response file type for jsdelivr
|
|
174
|
+
const text = yield readWebFile(connection, uri);
|
|
175
175
|
if (text !== undefined) {
|
|
176
176
|
const name = path.basename(fsPath);
|
|
177
177
|
dir.fileTypes.set(name, vscode_html_languageservice_1.FileType.File);
|
|
@@ -197,9 +197,9 @@ function createWebFileSystemHost() {
|
|
|
197
197
|
}
|
|
198
198
|
function readFileAsync(connection, fsPath, dir) {
|
|
199
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
const uri = shared.
|
|
201
|
-
if (uri.startsWith('https://
|
|
202
|
-
const text = yield
|
|
200
|
+
const uri = shared.fileNameToUri(fsPath);
|
|
201
|
+
if (uri.startsWith('https://unpkg.com/')) {
|
|
202
|
+
const text = yield readWebFile(connection, uri);
|
|
203
203
|
if (text !== undefined) {
|
|
204
204
|
const name = path.basename(fsPath);
|
|
205
205
|
dir.fileTexts.set(name, text);
|
|
@@ -222,28 +222,23 @@ function createWebFileSystemHost() {
|
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function readWebFile(connection, uri) {
|
|
226
226
|
var _a;
|
|
227
227
|
return __awaiter(this, void 0, void 0, function* () {
|
|
228
228
|
// ignore .js because it's no help for intellisense
|
|
229
229
|
if (uri.endsWith('.d.ts') || uri.endsWith('.json')) {
|
|
230
|
-
|
|
231
|
-
if (text !== undefined
|
|
232
|
-
// ignore https://cdn.jsdelivr.net/npm/@vue/runtime-dom
|
|
233
|
-
&& text.indexOf('Minified by jsDelivr') === -1) {
|
|
234
|
-
return text;
|
|
235
|
-
}
|
|
230
|
+
return (_a = yield connection.sendRequest(protocol_1.FsReadFileRequest.type, uri)) !== null && _a !== void 0 ? _a : undefined;
|
|
236
231
|
}
|
|
237
232
|
});
|
|
238
233
|
}
|
|
239
234
|
function readDirectoryAsync(connection, fsPath, dir) {
|
|
240
235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
-
const uri = shared.
|
|
236
|
+
const uri = shared.fileNameToUri(fsPath);
|
|
242
237
|
const result = yield connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, uri);
|
|
243
238
|
for (const [name, fileType] of result) {
|
|
244
239
|
if (dir.fileTypes.get(name) !== fileType && (fileType === vscode_html_languageservice_1.FileType.File || fileType === vscode_html_languageservice_1.FileType.SymbolicLink)) {
|
|
245
240
|
changes.push({
|
|
246
|
-
uri: shared.
|
|
241
|
+
uri: shared.fileNameToUri(path.join(fsPath, name)),
|
|
247
242
|
type: vscode.FileChangeType.Created,
|
|
248
243
|
});
|
|
249
244
|
}
|
|
@@ -262,8 +257,8 @@ function createWebFileSystemHost() {
|
|
|
262
257
|
let i = 0;
|
|
263
258
|
while (pendings.length) {
|
|
264
259
|
const current = pendings.shift();
|
|
265
|
-
progress === null || progress === void 0 ? void 0 : progress.report(i / pendings.length, vscode_uri_1.URI.parse(shared.
|
|
266
|
-
yield current;
|
|
260
|
+
progress === null || progress === void 0 ? void 0 : progress.report(i / pendings.length, vscode_uri_1.URI.parse(shared.fileNameToUri(current[1])).fsPath);
|
|
261
|
+
yield current[2];
|
|
267
262
|
i++;
|
|
268
263
|
}
|
|
269
264
|
progress === null || progress === void 0 ? void 0 : progress.done();
|
package/out/browser/index.js
CHANGED
|
@@ -24,7 +24,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.startLanguageServer = exports.createConnection = void 0;
|
|
26
26
|
const request_light_1 = require("request-light");
|
|
27
|
-
const ts = require("typescript/lib/tsserverlibrary"); // bundle typescript lib in web
|
|
28
27
|
const vscode = require("vscode-languageserver/browser");
|
|
29
28
|
const server_1 = require("../common/server");
|
|
30
29
|
const http_1 = require("../common/schemaRequestHandlers/http");
|
|
@@ -43,13 +42,19 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
43
42
|
plugins,
|
|
44
43
|
connection,
|
|
45
44
|
runtimeEnv: {
|
|
45
|
+
timer: {
|
|
46
|
+
setImmediate(callback, ...args) {
|
|
47
|
+
const handle = setTimeout(callback, 0, ...args);
|
|
48
|
+
return { dispose: () => clearTimeout(handle) };
|
|
49
|
+
},
|
|
50
|
+
},
|
|
46
51
|
loadTypescript() {
|
|
47
|
-
return
|
|
52
|
+
return require('typescript'); // force bundle because not support load by user config in web
|
|
48
53
|
},
|
|
49
54
|
loadTypescriptLocalized(tsdk, locale) {
|
|
50
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
56
|
try {
|
|
52
|
-
const uri = shared.
|
|
57
|
+
const uri = shared.fileNameToUri(`${tsdk}/${locale}/diagnosticMessages.generated.json`);
|
|
53
58
|
const json = yield (0, http_1.default)(uri);
|
|
54
59
|
return JSON.parse(json);
|
|
55
60
|
}
|
|
@@ -17,6 +17,7 @@ declare class IncrementalScriptSnapshot {
|
|
|
17
17
|
changes: IncrementalScriptSnapshotChange[];
|
|
18
18
|
constructor(uri: string, languageId: string, version: number, text: string);
|
|
19
19
|
get version(): number;
|
|
20
|
+
get languageId(): string;
|
|
20
21
|
update(params: vscode.DidChangeTextDocumentParams): void;
|
|
21
22
|
getSnapshot(): ts.IScriptSnapshot;
|
|
22
23
|
getDocument(): TextDocument;
|
package/out/common/documents.js
CHANGED
|
@@ -20,6 +20,9 @@ class IncrementalScriptSnapshot {
|
|
|
20
20
|
get version() {
|
|
21
21
|
return this.changes[this.changes.length - 1].version;
|
|
22
22
|
}
|
|
23
|
+
get languageId() {
|
|
24
|
+
return this.document.languageId;
|
|
25
|
+
}
|
|
23
26
|
update(params) {
|
|
24
27
|
vscode_languageserver_textdocument_1.TextDocument.update(this.document, params.contentChanges, params.textDocument.version);
|
|
25
28
|
this.changes = [
|
|
@@ -67,7 +67,7 @@ function register(connection, projects) {
|
|
|
67
67
|
connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
68
68
|
const project = (yield projects.getProject(params.uri));
|
|
69
69
|
if (project === null || project === void 0 ? void 0 : project.tsconfig) {
|
|
70
|
-
return { uri: shared.
|
|
70
|
+
return { uri: shared.fileNameToUri(project.tsconfig) };
|
|
71
71
|
}
|
|
72
72
|
}));
|
|
73
73
|
connection.onRequest(protocol_1.GetVirtualFileNamesRequest.type, (document) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -75,10 +75,10 @@ function register(connection, projects) {
|
|
|
75
75
|
const project = yield projects.getProject(document.uri);
|
|
76
76
|
const fileNames = [];
|
|
77
77
|
if (project) {
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
(0, language_core_1.forEachEmbeddedFile)(
|
|
81
|
-
if (e.snapshot.getLength() && e.kind ===
|
|
78
|
+
const rootVirtualFile = (_q = (_p = project.project) === null || _p === void 0 ? void 0 : _p.getLanguageService().context.core.virtualFiles.getSource(shared.uriToFileName(document.uri))) === null || _q === void 0 ? void 0 : _q.root;
|
|
79
|
+
if (rootVirtualFile) {
|
|
80
|
+
(0, language_core_1.forEachEmbeddedFile)(rootVirtualFile, e => {
|
|
81
|
+
if (e.snapshot.getLength() && e.kind === language_core_1.FileKind.TypeScriptHostFile) {
|
|
82
82
|
fileNames.push(e.fileName);
|
|
83
83
|
}
|
|
84
84
|
});
|
|
@@ -87,16 +87,15 @@ function register(connection, projects) {
|
|
|
87
87
|
return fileNames;
|
|
88
88
|
}));
|
|
89
89
|
connection.onRequest(protocol_1.GetVirtualFileRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
var _r, _s, _t;
|
|
90
|
+
var _r, _s, _t, _u;
|
|
91
91
|
const project = yield projects.getProject(params.sourceFileUri);
|
|
92
92
|
if (project) {
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
const virtualFile = sourceAndVirtual[2];
|
|
93
|
+
const [virtualFile, source] = (_s = (_r = project.project) === null || _r === void 0 ? void 0 : _r.getLanguageService().context.core.virtualFiles.getVirtualFile(params.virtualFileName)) !== null && _s !== void 0 ? _s : [];
|
|
94
|
+
if (virtualFile && source) {
|
|
96
95
|
const mappings = {};
|
|
97
96
|
for (const mapping of virtualFile.mappings) {
|
|
98
|
-
const sourceUri = shared.
|
|
99
|
-
(
|
|
97
|
+
const sourceUri = shared.fileNameToUri((_t = mapping.source) !== null && _t !== void 0 ? _t : source.fileName);
|
|
98
|
+
(_u = mappings[sourceUri]) !== null && _u !== void 0 ? _u : (mappings[sourceUri] = []);
|
|
100
99
|
mappings[sourceUri].push(mapping);
|
|
101
100
|
}
|
|
102
101
|
return {
|
|
@@ -110,11 +109,11 @@ function register(connection, projects) {
|
|
|
110
109
|
projects.reloadProject();
|
|
111
110
|
});
|
|
112
111
|
connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
var
|
|
112
|
+
var _v;
|
|
114
113
|
const fs = yield Promise.resolve().then(() => require('fs'));
|
|
115
114
|
const project = yield projects.getProject(params.uri);
|
|
116
115
|
if (project) {
|
|
117
|
-
const ls = (
|
|
116
|
+
const ls = (_v = (yield project.project)) === null || _v === void 0 ? void 0 : _v.getLanguageServiceDontCreate();
|
|
118
117
|
if (ls) {
|
|
119
118
|
const sourceFiles = new Set(ls.context.host.getScriptFileNames());
|
|
120
119
|
for (const virtualFile of ls.context.core.typescript.languageServiceHost.getScriptFileNames()) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver';
|
|
2
2
|
import { CancellationTokenHost } from '../cancellationPipe';
|
|
3
3
|
import type { Workspaces } from '../workspaces';
|
|
4
|
-
|
|
4
|
+
import { RuntimeEnvironment } from '../../types';
|
|
5
|
+
export declare function register(connection: vscode.Connection, projects: Workspaces, initParams: vscode.InitializeParams, cancelHost: CancellationTokenHost, semanticTokensLegend: vscode.SemanticTokensLegend, runtime: RuntimeEnvironment): void;
|
|
@@ -13,59 +13,59 @@ const embedded = require("@volar/language-service");
|
|
|
13
13
|
const vscode = require("vscode-languageserver");
|
|
14
14
|
const protocol_1 = require("../../protocol");
|
|
15
15
|
const shared = require("@volar/shared");
|
|
16
|
-
function register(connection, projects, initParams, cancelHost, semanticTokensLegend) {
|
|
16
|
+
function register(connection, projects, initParams, cancelHost, semanticTokensLegend, runtime) {
|
|
17
17
|
let lastCompleteUri;
|
|
18
18
|
let lastCompleteLs;
|
|
19
19
|
let lastCodeLensLs;
|
|
20
20
|
let lastCodeActionLs;
|
|
21
21
|
let lastCallHierarchyLs;
|
|
22
|
-
connection.onDocumentFormatting((params) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
22
|
+
connection.onDocumentFormatting((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
24
24
|
return vueLs.format(params.textDocument.uri, params.options);
|
|
25
25
|
});
|
|
26
26
|
}));
|
|
27
|
-
connection.onDocumentRangeFormatting((params) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
27
|
+
connection.onDocumentRangeFormatting((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
29
29
|
return vueLs.format(params.textDocument.uri, params.options, params.range);
|
|
30
30
|
});
|
|
31
31
|
}));
|
|
32
|
-
connection.onDocumentOnTypeFormatting((params) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
32
|
+
connection.onDocumentOnTypeFormatting((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
34
34
|
return vueLs.format(params.textDocument.uri, params.options, undefined, params);
|
|
35
35
|
});
|
|
36
36
|
}));
|
|
37
|
-
connection.onSelectionRanges((params) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
37
|
+
connection.onSelectionRanges((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
39
39
|
return vueLs.getSelectionRanges(params.textDocument.uri, params.positions);
|
|
40
40
|
});
|
|
41
41
|
}));
|
|
42
|
-
connection.onFoldingRanges((params) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
42
|
+
connection.onFoldingRanges((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
44
44
|
return vueLs.getFoldingRanges(params.textDocument.uri);
|
|
45
45
|
});
|
|
46
46
|
}));
|
|
47
|
-
connection.languages.onLinkedEditingRange((params) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
47
|
+
connection.languages.onLinkedEditingRange((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
49
49
|
return vueLs.findLinkedEditingRanges(params.textDocument.uri, params.position);
|
|
50
50
|
});
|
|
51
51
|
}));
|
|
52
|
-
connection.onDocumentSymbol((params) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
52
|
+
connection.onDocumentSymbol((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
54
54
|
return vueLs.findDocumentSymbols(params.textDocument.uri);
|
|
55
55
|
});
|
|
56
56
|
}));
|
|
57
|
-
connection.onDocumentColor((params) => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
57
|
+
connection.onDocumentColor((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
59
59
|
return vueLs.findDocumentColors(params.textDocument.uri);
|
|
60
60
|
});
|
|
61
61
|
}));
|
|
62
|
-
connection.onColorPresentation((params) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
62
|
+
connection.onColorPresentation((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
64
64
|
return vueLs.getColorPresentations(params.textDocument.uri, params.color, params.range);
|
|
65
65
|
});
|
|
66
66
|
}));
|
|
67
|
-
connection.onCompletion((params) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
connection.onCompletion((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
return worker(params.textDocument.uri, token, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
69
69
|
lastCompleteUri = params.textDocument.uri;
|
|
70
70
|
lastCompleteLs = vueLs;
|
|
71
71
|
const list = yield vueLs.doComplete(params.textDocument.uri, params.position, params.context);
|
|
@@ -84,28 +84,28 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
84
84
|
}
|
|
85
85
|
return item;
|
|
86
86
|
}));
|
|
87
|
-
connection.onHover((params) => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
87
|
+
connection.onHover((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
89
89
|
return vueLs.doHover(params.textDocument.uri, params.position);
|
|
90
90
|
});
|
|
91
91
|
}));
|
|
92
|
-
connection.onSignatureHelp((params) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
92
|
+
connection.onSignatureHelp((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
94
94
|
return vueLs.getSignatureHelp(params.textDocument.uri, params.position, params.context);
|
|
95
95
|
});
|
|
96
96
|
}));
|
|
97
|
-
connection.onPrepareRename((params) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
97
|
+
connection.onPrepareRename((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
99
99
|
return vueLs.prepareRename(params.textDocument.uri, params.position);
|
|
100
100
|
});
|
|
101
101
|
}));
|
|
102
|
-
connection.onRenameRequest((params) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
102
|
+
connection.onRenameRequest((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
104
104
|
return vueLs.doRename(params.textDocument.uri, params.position, params.newName);
|
|
105
105
|
});
|
|
106
106
|
}));
|
|
107
|
-
connection.onCodeLens((params) => __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
return worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
connection.onCodeLens((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
return worker(params.textDocument.uri, token, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
109
109
|
lastCodeLensLs = vueLs;
|
|
110
110
|
return vueLs.doCodeLens(params.textDocument.uri);
|
|
111
111
|
}));
|
|
@@ -120,7 +120,7 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
120
120
|
if (!args) {
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
return worker(args[0], vueLs => {
|
|
123
|
+
return worker(args[0], token, vueLs => {
|
|
124
124
|
return vueLs.doExecuteCommand(params.command, args, {
|
|
125
125
|
token,
|
|
126
126
|
workDoneProgress,
|
|
@@ -130,8 +130,8 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
}));
|
|
133
|
-
connection.onCodeAction((params) => __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
return worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
connection.onCodeAction((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
return worker(params.textDocument.uri, token, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
135
135
|
var _b, _c, _d;
|
|
136
136
|
lastCodeActionLs = vueLs;
|
|
137
137
|
let codeActions = (_b = yield vueLs.doCodeActions(params.textDocument.uri, params.range, params.context)) !== null && _b !== void 0 ? _b : [];
|
|
@@ -153,38 +153,38 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
153
153
|
var _e;
|
|
154
154
|
return (_e = yield lastCodeActionLs.doCodeActionResolve(codeAction)) !== null && _e !== void 0 ? _e : codeAction;
|
|
155
155
|
}));
|
|
156
|
-
connection.onReferences((params) => __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
156
|
+
connection.onReferences((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
158
158
|
return vueLs.findReferences(params.textDocument.uri, params.position);
|
|
159
159
|
});
|
|
160
160
|
}));
|
|
161
|
-
connection.onRequest(protocol_1.FindFileReferenceRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
161
|
+
connection.onRequest(protocol_1.FindFileReferenceRequest.type, (params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
163
163
|
return vueLs.findFileReferences(params.textDocument.uri);
|
|
164
164
|
});
|
|
165
165
|
}));
|
|
166
|
-
connection.onImplementation((params) => __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
166
|
+
connection.onImplementation((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
168
168
|
return vueLs.findImplementations(params.textDocument.uri, params.position);
|
|
169
169
|
});
|
|
170
170
|
}));
|
|
171
|
-
connection.onDefinition((params) => __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
171
|
+
connection.onDefinition((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
173
173
|
return vueLs.findDefinition(params.textDocument.uri, params.position);
|
|
174
174
|
});
|
|
175
175
|
}));
|
|
176
|
-
connection.onTypeDefinition((params) => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
176
|
+
connection.onTypeDefinition((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
178
178
|
return vueLs.findTypeDefinition(params.textDocument.uri, params.position);
|
|
179
179
|
});
|
|
180
180
|
}));
|
|
181
|
-
connection.onDocumentHighlight((params) => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
181
|
+
connection.onDocumentHighlight((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
183
183
|
return vueLs.findDocumentHighlights(params.textDocument.uri, params.position);
|
|
184
184
|
});
|
|
185
185
|
}));
|
|
186
|
-
connection.onDocumentLinks((params) => __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
186
|
+
connection.onDocumentLinks((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
188
188
|
return vueLs.findDocumentLinks(params.textDocument.uri);
|
|
189
189
|
});
|
|
190
190
|
}));
|
|
@@ -203,9 +203,9 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
203
203
|
}
|
|
204
204
|
return results;
|
|
205
205
|
}));
|
|
206
|
-
connection.languages.callHierarchy.onPrepare((params) => __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
connection.languages.callHierarchy.onPrepare((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
207
207
|
var _f;
|
|
208
|
-
return (_f = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
return (_f = yield worker(params.textDocument.uri, token, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
209
209
|
lastCallHierarchyLs = vueLs;
|
|
210
210
|
return vueLs.callHierarchy.doPrepare(params.textDocument.uri, params.position);
|
|
211
211
|
}))) !== null && _f !== void 0 ? _f : [];
|
|
@@ -221,9 +221,7 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
221
221
|
connection.languages.semanticTokens.on((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
|
|
222
222
|
var _j;
|
|
223
223
|
yield shared.sleep(200);
|
|
224
|
-
|
|
225
|
-
return buildTokens([]);
|
|
226
|
-
return (_j = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
224
|
+
return (_j = yield worker(params.textDocument.uri, token, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
227
225
|
var _k;
|
|
228
226
|
const result = (_k = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, undefined, semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _k !== void 0 ? _k : [];
|
|
229
227
|
return buildTokens(result);
|
|
@@ -232,18 +230,16 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
232
230
|
connection.languages.semanticTokens.onRange((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
|
|
233
231
|
var _l;
|
|
234
232
|
yield shared.sleep(200);
|
|
235
|
-
|
|
236
|
-
return buildTokens([]);
|
|
237
|
-
return (_l = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
return (_l = yield worker(params.textDocument.uri, token, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
238
234
|
var _m;
|
|
239
235
|
const result = (_m = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, params.range, semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _m !== void 0 ? _m : [];
|
|
240
236
|
return buildTokens(result);
|
|
241
237
|
}))) !== null && _l !== void 0 ? _l : buildTokens([]);
|
|
242
238
|
}));
|
|
243
239
|
connection.languages.diagnostics.on((params, token, _workDoneProgressReporter, resultProgressReporter) => __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return vueLs.doValidation(params.textDocument.uri,
|
|
240
|
+
const result = yield worker(params.textDocument.uri, token, vueLs => {
|
|
241
|
+
const tsToken = cancelHost.createCancellationToken(token);
|
|
242
|
+
return vueLs.doValidation(params.textDocument.uri, tsToken, errors => {
|
|
247
243
|
// resultProgressReporter is undefined in vscode
|
|
248
244
|
resultProgressReporter === null || resultProgressReporter === void 0 ? void 0 : resultProgressReporter.report({
|
|
249
245
|
relatedDocuments: {
|
|
@@ -260,43 +256,62 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
260
256
|
items: result !== null && result !== void 0 ? result : [],
|
|
261
257
|
};
|
|
262
258
|
}));
|
|
263
|
-
connection.languages.inlayHint.on((params) => __awaiter(this, void 0, void 0, function* () {
|
|
264
|
-
return worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
259
|
+
connection.languages.inlayHint.on((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
260
|
+
return worker(params.textDocument.uri, token, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
265
261
|
return vueLs.getInlayHints(params.textDocument.uri, params.range);
|
|
266
262
|
}));
|
|
267
263
|
}));
|
|
268
264
|
// TODO: connection.languages.inlayHint.resolve
|
|
269
|
-
connection.workspace.onWillRenameFiles((params) => __awaiter(this, void 0, void 0, function* () {
|
|
270
|
-
var _o;
|
|
265
|
+
connection.workspace.onWillRenameFiles((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
271
266
|
const config = yield connection.workspace.getConfiguration('volar.updateImportsOnFileMove.enabled');
|
|
272
267
|
if (!config) {
|
|
273
268
|
return null;
|
|
274
269
|
}
|
|
275
|
-
|
|
276
|
-
|
|
270
|
+
const _edits = yield Promise.all(params.files.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
271
|
+
var _o;
|
|
272
|
+
return (_o = yield worker(file.oldUri, token, vueLs => {
|
|
273
|
+
var _a;
|
|
274
|
+
return (_a = vueLs.getEditsForFileRename(file.oldUri, file.newUri)) !== null && _a !== void 0 ? _a : null;
|
|
275
|
+
})) !== null && _o !== void 0 ? _o : null;
|
|
276
|
+
})));
|
|
277
|
+
const edits = _edits.filter(shared.notEmpty);
|
|
278
|
+
if (edits.length) {
|
|
279
|
+
embedded.mergeWorkspaceEdits(edits[0], ...edits.slice(1));
|
|
280
|
+
return edits[0];
|
|
277
281
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
})) !== null && _o !== void 0 ? _o : null;
|
|
283
|
-
}));
|
|
284
|
-
connection.onRequest(protocol_1.AutoInsertRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
285
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
282
|
+
return null;
|
|
283
|
+
}));
|
|
284
|
+
connection.onRequest(protocol_1.AutoInsertRequest.type, (params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
return worker(params.textDocument.uri, token, vueLs => {
|
|
286
286
|
return vueLs.doAutoInsert(params.textDocument.uri, params.position, params.options);
|
|
287
287
|
});
|
|
288
288
|
}));
|
|
289
|
-
function worker(uri, cb) {
|
|
290
|
-
return
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return
|
|
289
|
+
function worker(uri, token, cb) {
|
|
290
|
+
return new Promise(resolve => {
|
|
291
|
+
runtime.timer.setImmediate(() => __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
if (token.isCancellationRequested) {
|
|
293
|
+
resolve(undefined);
|
|
294
|
+
return;
|
|
295
295
|
}
|
|
296
|
-
|
|
297
|
-
|
|
296
|
+
const vueLs = yield getLanguageService(uri);
|
|
297
|
+
if (vueLs) {
|
|
298
|
+
try { // handle TS cancel throw
|
|
299
|
+
const result = yield cb(vueLs);
|
|
300
|
+
if (token.isCancellationRequested) {
|
|
301
|
+
resolve(undefined);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
resolve(result);
|
|
305
|
+
}
|
|
306
|
+
catch (_a) {
|
|
307
|
+
resolve(undefined);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
298
310
|
}
|
|
299
|
-
|
|
311
|
+
else {
|
|
312
|
+
resolve(undefined);
|
|
313
|
+
}
|
|
314
|
+
}));
|
|
300
315
|
});
|
|
301
316
|
}
|
|
302
317
|
function buildTokens(tokens) {
|
package/out/common/project.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as embedded from '@volar/language-core';
|
|
2
2
|
import * as embeddedLS from '@volar/language-service';
|
|
3
|
+
import { LanguageServiceConfig } from '@volar/language-service';
|
|
3
4
|
import * as path from 'typesafe-path';
|
|
4
5
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
5
6
|
import { URI } from 'vscode-uri';
|
|
6
7
|
import { WorkspaceContext } from './workspace';
|
|
7
|
-
import { ServerConfig } from './utils/serverConfig';
|
|
8
8
|
export interface ProjectContext {
|
|
9
9
|
workspace: WorkspaceContext;
|
|
10
10
|
rootUri: URI;
|
|
11
11
|
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
12
12
|
documentRegistry: ts.DocumentRegistry | undefined;
|
|
13
|
-
serverConfig:
|
|
13
|
+
serverConfig: LanguageServiceConfig | undefined;
|
|
14
14
|
}
|
|
15
15
|
export type Project = ReturnType<typeof createProject>;
|
|
16
16
|
export declare function createProject(context: ProjectContext): Promise<{
|