@volar/language-server 1.0.0-beta.2 → 1.0.0-beta.3
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/features/customFeatures.js +7 -7
- package/out/features/documentFeatures.js +2 -2
- package/out/features/languageFeatures.d.ts +2 -1
- package/out/features/languageFeatures.js +24 -11
- package/out/index.d.ts +3 -2
- package/out/index.js +4 -2
- package/out/{requests.d.ts → protocol.d.ts} +0 -0
- package/out/{requests.js → protocol.js} +1 -1
- package/out/registerFeatures.d.ts +2 -2
- package/out/registerFeatures.js +2 -2
- package/out/server.js +8 -2
- package/out/types.d.ts +9 -4
- package/out/utils/cancellationPipe.d.ts +6 -0
- package/out/utils/cancellationPipe.js +44 -0
- package/out/utils/project.d.ts +8 -6
- package/out/utils/project.js +21 -20
- package/out/utils/snapshots.d.ts +4 -4
- package/out/utils/webFileSystemHost.js +20 -19
- package/out/utils/workspaceProjects.d.ts +13 -11
- package/out/utils/workspaceProjects.js +9 -8
- package/out/utils/workspaces.d.ts +19 -18
- package/out/utils/workspaces.js +8 -8
- package/package.json +6 -6
- package/out/registers/registerDocumentFeatures.d.ts +0 -3
- package/out/registers/registerDocumentFeatures.js +0 -30
- package/out/registers/registerlanguageFeatures.d.ts +0 -3
- package/out/registers/registerlanguageFeatures.js +0 -144
|
@@ -10,18 +10,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.register = void 0;
|
|
12
12
|
const shared = require("@volar/shared");
|
|
13
|
-
const path = require("
|
|
13
|
+
const path = require("typesafe-path");
|
|
14
14
|
const vscode = require("vscode-languageserver");
|
|
15
|
-
const
|
|
15
|
+
const protocol_1 = require("../protocol");
|
|
16
16
|
function register(connection, projects) {
|
|
17
|
-
connection.onRequest(
|
|
17
|
+
connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
var _a;
|
|
19
19
|
return (_a = (yield projects.getProject(params.uri))) === null || _a === void 0 ? void 0 : _a.tsconfig;
|
|
20
20
|
}));
|
|
21
|
-
connection.onNotification(
|
|
21
|
+
connection.onNotification(protocol_1.ReloadProjectNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
projects.reloadProject();
|
|
23
23
|
}));
|
|
24
|
-
connection.onNotification(
|
|
24
|
+
connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
var _b;
|
|
26
26
|
const fs = yield Promise.resolve().then(() => require('fs'));
|
|
27
27
|
const project = yield projects.getProject(params.uri);
|
|
@@ -40,7 +40,7 @@ function register(connection, projects) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}));
|
|
43
|
-
connection.onNotification(
|
|
43
|
+
connection.onNotification(protocol_1.VerifyAllScriptsNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
44
44
|
var _c;
|
|
45
45
|
let errors = 0;
|
|
46
46
|
let warnings = 0;
|
|
@@ -57,7 +57,7 @@ function register(connection, projects) {
|
|
|
57
57
|
if (progress.token.isCancellationRequested) {
|
|
58
58
|
continue;
|
|
59
59
|
}
|
|
60
|
-
let _result = yield ls.doValidation(vueFile.uri);
|
|
60
|
+
let _result = yield ls.doValidation(vueFile.uri, progress.token);
|
|
61
61
|
connection.sendDiagnostics({ uri: vueFile.uri, diagnostics: _result });
|
|
62
62
|
errors += _result.filter(error => error.severity === vscode.DiagnosticSeverity.Error).length;
|
|
63
63
|
warnings += _result.filter(error => error.severity === vscode.DiagnosticSeverity.Warning).length;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.register = void 0;
|
|
12
|
-
const
|
|
12
|
+
const protocol_1 = require("../protocol");
|
|
13
13
|
function register(connection, documents, documentServiceHost) {
|
|
14
14
|
connection.onDocumentFormatting(params => {
|
|
15
15
|
return worker(params.textDocument.uri, document => {
|
|
@@ -56,7 +56,7 @@ function register(connection, documents, documentServiceHost) {
|
|
|
56
56
|
return documentServiceHost.get(document.uri).getColorPresentations(document, params.color, params.range);
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
|
-
connection.onRequest(
|
|
59
|
+
connection.onRequest(protocol_1.AutoInsertRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
60
60
|
return worker(params.textDocument.uri, document => {
|
|
61
61
|
return documentServiceHost.get(document.uri).doAutoInsert(document, params.position, params.options);
|
|
62
62
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver';
|
|
2
|
+
import { CancellactionTokenHost } from '../utils/cancellationPipe';
|
|
2
3
|
import type { Workspaces } from '../utils/workspaces';
|
|
3
|
-
export declare function register(connection: vscode.Connection, projects: Workspaces, initParams: vscode.InitializeParams): void;
|
|
4
|
+
export declare function register(connection: vscode.Connection, projects: Workspaces, initParams: vscode.InitializeParams, cancelHost: CancellactionTokenHost): void;
|
|
@@ -11,8 +11,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.register = void 0;
|
|
12
12
|
const embedded = require("@volar/language-service");
|
|
13
13
|
const vscode = require("vscode-languageserver");
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const protocol_1 = require("../protocol");
|
|
15
|
+
const shared = require("@volar/shared");
|
|
16
|
+
function register(connection, projects, initParams, cancelHost) {
|
|
16
17
|
let lastCompleteUri;
|
|
17
18
|
let lastCompleteLs;
|
|
18
19
|
let lastCodeLensLs;
|
|
@@ -79,7 +80,7 @@ function register(connection, projects, initParams) {
|
|
|
79
80
|
token,
|
|
80
81
|
workDoneProgress,
|
|
81
82
|
applyEdit: (paramOrEdit) => connection.workspace.applyEdit(paramOrEdit),
|
|
82
|
-
showReferences: (params) => connection.sendNotification(
|
|
83
|
+
showReferences: (params) => connection.sendNotification(protocol_1.ShowReferencesNotification.type, params),
|
|
83
84
|
});
|
|
84
85
|
});
|
|
85
86
|
}
|
|
@@ -112,7 +113,7 @@ function register(connection, projects, initParams) {
|
|
|
112
113
|
return vueLs.findReferences(params.textDocument.uri, params.position);
|
|
113
114
|
});
|
|
114
115
|
}));
|
|
115
|
-
connection.onRequest(
|
|
116
|
+
connection.onRequest(protocol_1.FindFileReferenceRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
116
117
|
return worker(params.textDocument.uri, vueLs => {
|
|
117
118
|
return vueLs.findFileReferences(params.textDocument.uri);
|
|
118
119
|
});
|
|
@@ -174,6 +175,9 @@ function register(connection, projects, initParams) {
|
|
|
174
175
|
}));
|
|
175
176
|
connection.languages.semanticTokens.on((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
|
|
176
177
|
var _j;
|
|
178
|
+
yield shared.sleep(200);
|
|
179
|
+
if (token.isCancellationRequested)
|
|
180
|
+
return buildTokens([]);
|
|
177
181
|
return (_j = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
178
182
|
var _k;
|
|
179
183
|
const result = (_k = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, undefined, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _k !== void 0 ? _k : [];
|
|
@@ -182,15 +186,19 @@ function register(connection, projects, initParams) {
|
|
|
182
186
|
}));
|
|
183
187
|
connection.languages.semanticTokens.onRange((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
|
|
184
188
|
var _l;
|
|
189
|
+
yield shared.sleep(200);
|
|
190
|
+
if (token.isCancellationRequested)
|
|
191
|
+
return buildTokens([]);
|
|
185
192
|
return (_l = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
186
193
|
var _m;
|
|
187
194
|
const result = (_m = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, params.range, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _m !== void 0 ? _m : [];
|
|
188
195
|
return buildTokens(result);
|
|
189
196
|
}))) !== null && _l !== void 0 ? _l : buildTokens([]);
|
|
190
197
|
}));
|
|
191
|
-
connection.languages.diagnostics.on((params,
|
|
198
|
+
connection.languages.diagnostics.on((params, token, workDoneProgressReporter, resultProgressReporter) => __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
token = cancelHost.createCancellactionToken(token);
|
|
192
200
|
const result = yield worker(params.textDocument.uri, vueLs => {
|
|
193
|
-
return vueLs.doValidation(params.textDocument.uri, errors => {
|
|
201
|
+
return vueLs.doValidation(params.textDocument.uri, token, errors => {
|
|
194
202
|
// resultProgressReporter is undefined in vscode
|
|
195
203
|
resultProgressReporter === null || resultProgressReporter === void 0 ? void 0 : resultProgressReporter.report({
|
|
196
204
|
relatedDocuments: {
|
|
@@ -200,7 +208,7 @@ function register(connection, projects, initParams) {
|
|
|
200
208
|
},
|
|
201
209
|
},
|
|
202
210
|
});
|
|
203
|
-
}
|
|
211
|
+
});
|
|
204
212
|
});
|
|
205
213
|
return {
|
|
206
214
|
kind: vscode.DocumentDiagnosticReportKind.Full,
|
|
@@ -208,9 +216,9 @@ function register(connection, projects, initParams) {
|
|
|
208
216
|
};
|
|
209
217
|
}));
|
|
210
218
|
connection.languages.inlayHint.on((params) => __awaiter(this, void 0, void 0, function* () {
|
|
211
|
-
return worker(params.textDocument.uri, vueLs => {
|
|
219
|
+
return worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
212
220
|
return vueLs.getInlayHints(params.textDocument.uri, params.range);
|
|
213
|
-
});
|
|
221
|
+
}));
|
|
214
222
|
}));
|
|
215
223
|
// TODO: connection.languages.inlayHint.resolve
|
|
216
224
|
connection.workspace.onWillRenameFiles((params) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -228,7 +236,7 @@ function register(connection, projects, initParams) {
|
|
|
228
236
|
return (_a = vueLs.getEditsForFileRename(file.oldUri, file.newUri)) !== null && _a !== void 0 ? _a : null;
|
|
229
237
|
})) !== null && _o !== void 0 ? _o : null;
|
|
230
238
|
}));
|
|
231
|
-
connection.onRequest(
|
|
239
|
+
connection.onRequest(protocol_1.AutoInsertRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
232
240
|
return worker(params.textDocument.uri, vueLs => {
|
|
233
241
|
return vueLs.doAutoInsert(params.textDocument.uri, params.position, params.options);
|
|
234
242
|
});
|
|
@@ -237,7 +245,12 @@ function register(connection, projects, initParams) {
|
|
|
237
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
238
246
|
const vueLs = yield getLanguageService(uri);
|
|
239
247
|
if (vueLs) {
|
|
240
|
-
|
|
248
|
+
try {
|
|
249
|
+
return cb(vueLs); // handle for TS cancel throw
|
|
250
|
+
}
|
|
251
|
+
catch (_a) {
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
241
254
|
}
|
|
242
255
|
});
|
|
243
256
|
}
|
package/out/index.d.ts
CHANGED
package/out/index.js
CHANGED
|
@@ -13,7 +13,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
13
13
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
__exportStar(require("
|
|
17
|
-
__exportStar(require("./requests"), exports);
|
|
16
|
+
__exportStar(require("./protocol"), exports);
|
|
18
17
|
__exportStar(require("./types"), exports);
|
|
18
|
+
// only export types of depend packages
|
|
19
|
+
__exportStar(require("@volar/language-core/out/types"), exports);
|
|
20
|
+
__exportStar(require("@volar/language-service/out/types"), exports);
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
|
File without changes
|
|
@@ -54,4 +54,4 @@ var FsReadDirectoryRequest;
|
|
|
54
54
|
(function (FsReadDirectoryRequest) {
|
|
55
55
|
FsReadDirectoryRequest.type = new vscode.RequestType('fs/readDirectory');
|
|
56
56
|
})(FsReadDirectoryRequest = exports.FsReadDirectoryRequest || (exports.FsReadDirectoryRequest = {}));
|
|
57
|
-
//# sourceMappingURL=
|
|
57
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LanguageServerPlugin,
|
|
1
|
+
import { LanguageServerPlugin, LanguageServerInitializationOptions } from './types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver';
|
|
3
3
|
import { ClientCapabilities } from 'vscode-languageserver';
|
|
4
4
|
export declare function setupSyntacticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities): void;
|
|
5
|
-
export declare function setupSemanticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities, options:
|
|
5
|
+
export declare function setupSemanticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities, options: LanguageServerInitializationOptions, plugins: ReturnType<LanguageServerPlugin>[]): void;
|
package/out/registerFeatures.js
CHANGED
|
@@ -65,7 +65,7 @@ function setupSemanticCapabilities(params, server, options, plugins) {
|
|
|
65
65
|
fileOperations: {
|
|
66
66
|
willRename: {
|
|
67
67
|
filters: [
|
|
68
|
-
...plugins.map(plugin => plugin.
|
|
68
|
+
...plugins.map(plugin => plugin.extraFileExtensions.map(ext => ({ pattern: { glob: `**/*.${ext.extension}` } }))).flat(),
|
|
69
69
|
{ pattern: { glob: '**/*.js' } },
|
|
70
70
|
{ pattern: { glob: '**/*.ts' } },
|
|
71
71
|
{ pattern: { glob: '**/*.jsx' } },
|
|
@@ -162,7 +162,7 @@ function setupSemanticCapabilities(params, server, options, plugins) {
|
|
|
162
162
|
if (((_x = params.textDocument) === null || _x === void 0 ? void 0 : _x.diagnostic) && ((_y = options.diagnosticModel) !== null && _y !== void 0 ? _y : types_1.DiagnosticModel.Push) === types_1.DiagnosticModel.Pull) {
|
|
163
163
|
server.diagnosticProvider = {
|
|
164
164
|
documentSelector: [
|
|
165
|
-
...plugins.map(plugin => plugin.
|
|
165
|
+
...plugins.map(plugin => plugin.extraFileExtensions.map(ext => ({ pattern: `**/*.${ext.extension}` }))).flat(),
|
|
166
166
|
{ pattern: '**/*.{ts,js,tsx,jsx}' },
|
|
167
167
|
],
|
|
168
168
|
interFileDependencies: true,
|
package/out/server.js
CHANGED
|
@@ -17,6 +17,7 @@ const documentServiceHost_1 = require("./utils/documentServiceHost");
|
|
|
17
17
|
const snapshots_1 = require("./utils/snapshots");
|
|
18
18
|
const workspaces_1 = require("./utils/workspaces");
|
|
19
19
|
const registerFeatures_1 = require("./registerFeatures");
|
|
20
|
+
const cancellationPipe_1 = require("./utils/cancellationPipe");
|
|
20
21
|
function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
|
|
21
22
|
let params;
|
|
22
23
|
let options;
|
|
@@ -84,6 +85,7 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
|
|
|
84
85
|
}));
|
|
85
86
|
connection.listen();
|
|
86
87
|
function createDocumenntServiceHost() {
|
|
88
|
+
var _a, _b;
|
|
87
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
90
|
const ts = runtimeEnv.loadTypescript(options.typescript.tsdk);
|
|
89
91
|
documentServiceHost = (0, documentServiceHost_1.createDocumentServiceHost)(runtimeEnv, plugins, ts, configHost);
|
|
@@ -91,6 +93,9 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
|
|
|
91
93
|
documentServiceHost.add(root);
|
|
92
94
|
}
|
|
93
95
|
(yield Promise.resolve().then(() => require('./features/documentFeatures'))).register(connection, documents, documentServiceHost);
|
|
96
|
+
for (const plugin of plugins) {
|
|
97
|
+
(_b = (_a = plugin.documentService) === null || _a === void 0 ? void 0 : _a.onInitialize) === null || _b === void 0 ? void 0 : _b.call(_a, connection);
|
|
98
|
+
}
|
|
94
99
|
});
|
|
95
100
|
}
|
|
96
101
|
function createLanguageServiceHost() {
|
|
@@ -99,13 +104,14 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
|
|
|
99
104
|
const ts = runtimeEnv.loadTypescript(options.typescript.tsdk);
|
|
100
105
|
fsHost = runtimeEnv.createFileSystemHost(ts, params.capabilities);
|
|
101
106
|
const tsLocalized = params.locale ? runtimeEnv.loadTypescriptLocalized(options.typescript.tsdk, params.locale) : undefined;
|
|
102
|
-
const
|
|
107
|
+
const cancelTokenHost = (0, cancellationPipe_1.createCancellactionTokenHost)(options.cancellationPipeName);
|
|
108
|
+
const _projects = (0, workspaces_1.createWorkspaces)(runtimeEnv, plugins, fsHost, configHost, ts, tsLocalized, params.capabilities, options, documents, connection, cancelTokenHost);
|
|
103
109
|
projects = _projects;
|
|
104
110
|
for (const root of roots) {
|
|
105
111
|
projects.add(root);
|
|
106
112
|
}
|
|
107
113
|
(yield Promise.resolve().then(() => require('./features/customFeatures'))).register(connection, projects);
|
|
108
|
-
(yield Promise.resolve().then(() => require('./features/languageFeatures'))).register(connection, projects, params);
|
|
114
|
+
(yield Promise.resolve().then(() => require('./features/languageFeatures'))).register(connection, projects, params, cancelTokenHost);
|
|
109
115
|
for (const plugin of plugins) {
|
|
110
116
|
(_b = (_a = plugin.languageService) === null || _a === void 0 ? void 0 : _a.onInitialize) === null || _b === void 0 ? void 0 : _b.call(_a, connection, getLanguageService);
|
|
111
117
|
}
|
package/out/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as embedded from '@volar/language-core';
|
|
|
4
4
|
import type { FileSystemProvider } from 'vscode-html-languageservice';
|
|
5
5
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
6
6
|
import * as vscode from 'vscode-languageserver';
|
|
7
|
-
import type * as Requests from './
|
|
7
|
+
import type * as Requests from './protocol';
|
|
8
8
|
import { URI } from 'vscode-uri';
|
|
9
9
|
export declare let __requests: typeof Requests;
|
|
10
10
|
export type FileSystemHost = {
|
|
@@ -24,8 +24,8 @@ export interface RuntimeEnvironment {
|
|
|
24
24
|
fileSystemProvide: FileSystemProvider | undefined;
|
|
25
25
|
createFileSystemHost: (ts: typeof import('typescript/lib/tsserverlibrary'), capabilities: vscode.ClientCapabilities) => FileSystemHost;
|
|
26
26
|
}
|
|
27
|
-
export type LanguageServerPlugin<A extends
|
|
28
|
-
|
|
27
|
+
export type LanguageServerPlugin<A extends LanguageServerInitializationOptions = LanguageServerInitializationOptions, B extends embedded.LanguageServiceHost = embedded.LanguageServiceHost, C = embeddedLS.LanguageService> = (initOptions: A) => {
|
|
28
|
+
extraFileExtensions: ts.FileExtensionInfo[];
|
|
29
29
|
languageService?: {
|
|
30
30
|
semanticTokenLegend?: vscode.SemanticTokensLegend;
|
|
31
31
|
resolveLanguageServiceHost?(ts: typeof import('typescript/lib/tsserverlibrary'), sys: FileSystem, tsConfig: string | ts.CompilerOptions, host: embedded.LanguageServiceHost): B;
|
|
@@ -36,6 +36,7 @@ export type LanguageServerPlugin<A extends InitializationOptions = Initializatio
|
|
|
36
36
|
documentService?: {
|
|
37
37
|
getLanguageModules?(ts: typeof import('typescript/lib/tsserverlibrary'), env: embeddedLS.LanguageServicePluginContext['env']): embedded.EmbeddedLanguageModule[];
|
|
38
38
|
getServicePlugins?(context: embeddedLS.DocumentServiceRuntimeContext): embeddedLS.LanguageServicePlugin[];
|
|
39
|
+
onInitialize?(connection: vscode.Connection): void;
|
|
39
40
|
};
|
|
40
41
|
};
|
|
41
42
|
export declare enum ServerMode {
|
|
@@ -47,7 +48,7 @@ export declare enum DiagnosticModel {
|
|
|
47
48
|
Push = 1,
|
|
48
49
|
Pull = 2
|
|
49
50
|
}
|
|
50
|
-
export interface
|
|
51
|
+
export interface LanguageServerInitializationOptions {
|
|
51
52
|
typescript: {
|
|
52
53
|
tsdk: string;
|
|
53
54
|
};
|
|
@@ -55,4 +56,8 @@ export interface InitializationOptions {
|
|
|
55
56
|
diagnosticModel?: DiagnosticModel;
|
|
56
57
|
textDocumentSync?: vscode.TextDocumentSyncKind | number;
|
|
57
58
|
ignoreTriggerCharacters?: string[];
|
|
59
|
+
/**
|
|
60
|
+
* https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29#cancellation
|
|
61
|
+
*/
|
|
62
|
+
cancellationPipeName?: string;
|
|
58
63
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver';
|
|
2
|
+
export type CancellactionTokenHost = ReturnType<typeof createCancellactionTokenHost>;
|
|
3
|
+
export declare function createCancellactionTokenHost(_cancellationPipeName: string | undefined): {
|
|
4
|
+
createCancellactionToken(original: vscode.CancellationToken): vscode.CancellationToken;
|
|
5
|
+
getMtime(): number;
|
|
6
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.createCancellactionTokenHost = void 0;
|
|
3
|
+
const vscode = require("vscode-languageserver");
|
|
4
|
+
function createCancellactionTokenHost(_cancellationPipeName) {
|
|
5
|
+
if (_cancellationPipeName === undefined) {
|
|
6
|
+
return {
|
|
7
|
+
createCancellactionToken(original) {
|
|
8
|
+
return original;
|
|
9
|
+
},
|
|
10
|
+
getMtime() {
|
|
11
|
+
return -1;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const cancellationPipeName = _cancellationPipeName;
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
return {
|
|
18
|
+
createCancellactionToken,
|
|
19
|
+
getMtime,
|
|
20
|
+
};
|
|
21
|
+
function createCancellactionToken(original) {
|
|
22
|
+
const mtime = getMtime();
|
|
23
|
+
const token = {
|
|
24
|
+
get isCancellationRequested() {
|
|
25
|
+
if (original.isCancellationRequested) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return getMtime() !== mtime;
|
|
29
|
+
},
|
|
30
|
+
onCancellationRequested: vscode.Event.None,
|
|
31
|
+
};
|
|
32
|
+
return token;
|
|
33
|
+
}
|
|
34
|
+
function getMtime() {
|
|
35
|
+
try {
|
|
36
|
+
return fs.statSync(cancellationPipeName).mtime.valueOf();
|
|
37
|
+
}
|
|
38
|
+
catch (_a) {
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.createCancellactionTokenHost = createCancellactionTokenHost;
|
|
44
|
+
//# sourceMappingURL=cancellationPipe.js.map
|
package/out/utils/project.d.ts
CHANGED
|
@@ -2,14 +2,16 @@ import * as embeddedLS from '@volar/language-service';
|
|
|
2
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
3
|
import * as vscode from 'vscode-languageserver';
|
|
4
4
|
import { URI } from 'vscode-uri';
|
|
5
|
-
import { FileSystemHost, LanguageServerPlugin, RuntimeEnvironment
|
|
5
|
+
import { FileSystemHost, LanguageServerPlugin, RuntimeEnvironment } from '../types';
|
|
6
6
|
import { createSnapshots } from './snapshots';
|
|
7
7
|
import { ConfigurationHost } from '@volar/vue-language-service';
|
|
8
|
+
import * as path from 'typesafe-path';
|
|
9
|
+
import { CancellactionTokenHost } from './cancellationPipe';
|
|
8
10
|
export interface Project extends ReturnType<typeof createProject> {
|
|
9
11
|
}
|
|
10
|
-
export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, ts: typeof import('typescript/lib/tsserverlibrary'),
|
|
12
|
+
export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, ts: typeof import('typescript/lib/tsserverlibrary'), rootUri: URI, tsConfig: path.PosixPath | ts.CompilerOptions, tsLocalized: ts.MapLike<string> | undefined, documents: ReturnType<typeof createSnapshots>, configHost: ConfigurationHost | undefined, documentRegistry: ts.DocumentRegistry | undefined, cancelTokenHost: CancellactionTokenHost): Promise<{
|
|
11
13
|
getLanguageService: () => {
|
|
12
|
-
doValidation: (uri: string, response?: ((result: vscode.Diagnostic[]) => void) | undefined
|
|
14
|
+
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
13
15
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
14
16
|
findFileReferences: (uri: string) => embeddedLS.NullableResult<vscode.Location[]>;
|
|
15
17
|
findDefinition: (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -18,7 +20,7 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
|
|
|
18
20
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
19
21
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
20
22
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
21
|
-
getSemanticTokens: (uri: string, range
|
|
23
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: embeddedLS.SemanticToken[]) => void) | undefined) => Promise<embeddedLS.SemanticToken[] | undefined> | undefined;
|
|
22
24
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
23
25
|
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
|
|
24
26
|
isIncomplete: boolean;
|
|
@@ -52,7 +54,7 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
|
|
|
52
54
|
context: embeddedLS.LanguageServiceRuntimeContext;
|
|
53
55
|
};
|
|
54
56
|
getLanguageServiceDontCreate: () => {
|
|
55
|
-
doValidation: (uri: string, response?: ((result: vscode.Diagnostic[]) => void) | undefined
|
|
57
|
+
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
56
58
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
57
59
|
findFileReferences: (uri: string) => embeddedLS.NullableResult<vscode.Location[]>;
|
|
58
60
|
findDefinition: (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -61,7 +63,7 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
|
|
|
61
63
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
62
64
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
63
65
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
64
|
-
getSemanticTokens: (uri: string, range
|
|
66
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: embeddedLS.SemanticToken[]) => void) | undefined) => Promise<embeddedLS.SemanticToken[] | undefined> | undefined;
|
|
65
67
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
66
68
|
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
|
|
67
69
|
isIncomplete: boolean;
|
package/out/utils/project.js
CHANGED
|
@@ -15,13 +15,13 @@ const embedded = require("@volar/language-core");
|
|
|
15
15
|
const vscode = require("vscode-languageserver");
|
|
16
16
|
const vscode_uri_1 = require("vscode-uri");
|
|
17
17
|
const config_1 = require("./config");
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
function createProject(runtimeEnv, plugins, fsHost, ts, options, rootUri, tsConfig, tsLocalized, documents, connection, configHost, documentRegistry) {
|
|
18
|
+
const path = require("typesafe-path");
|
|
19
|
+
function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLocalized, documents, configHost, documentRegistry, cancelTokenHost) {
|
|
21
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
21
|
const sys = fsHost.getWorkspaceFileSystem(rootUri);
|
|
23
22
|
let typeRootVersion = 0;
|
|
24
23
|
let projectVersion = 0;
|
|
24
|
+
let projectVersionUpdateTime = 0;
|
|
25
25
|
let vueLs;
|
|
26
26
|
let parsedCommandLine = createParsedCommandLine(ts, sys, shared.getPathOfUri(rootUri.toString()), tsConfig, plugins);
|
|
27
27
|
const scripts = shared.createUriMap();
|
|
@@ -31,6 +31,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, options, rootUri, tsConf
|
|
|
31
31
|
});
|
|
32
32
|
const disposeDocChange = documents.onDidChangeContent(params => {
|
|
33
33
|
projectVersion++;
|
|
34
|
+
projectVersionUpdateTime = cancelTokenHost.getMtime();
|
|
34
35
|
});
|
|
35
36
|
return {
|
|
36
37
|
getLanguageService,
|
|
@@ -100,6 +101,12 @@ function createProject(runtimeEnv, plugins, fsHost, ts, options, rootUri, tsConf
|
|
|
100
101
|
}
|
|
101
102
|
function createLanguageServiceHost() {
|
|
102
103
|
var _a;
|
|
104
|
+
const token = {
|
|
105
|
+
isCancellationRequested() {
|
|
106
|
+
return cancelTokenHost.getMtime() !== projectVersionUpdateTime;
|
|
107
|
+
},
|
|
108
|
+
throwIfCancellationRequested() { },
|
|
109
|
+
};
|
|
103
110
|
let host = {
|
|
104
111
|
// ts
|
|
105
112
|
getNewLine: () => sys.newLine,
|
|
@@ -113,6 +120,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, options, rootUri, tsConf
|
|
|
113
120
|
fileExists: sys.fileExists,
|
|
114
121
|
getCurrentDirectory: () => shared.getPathOfUri(rootUri.toString()),
|
|
115
122
|
getProjectReferences: () => parsedCommandLine.projectReferences,
|
|
123
|
+
getCancellationToken: () => token,
|
|
116
124
|
// custom
|
|
117
125
|
getDefaultLibFileName: options => {
|
|
118
126
|
try {
|
|
@@ -187,21 +195,15 @@ function createProject(runtimeEnv, plugins, fsHost, ts, options, rootUri, tsConf
|
|
|
187
195
|
}
|
|
188
196
|
exports.createProject = createProject;
|
|
189
197
|
function createParsedCommandLine(ts, sys, rootPath, tsConfig, plugins) {
|
|
190
|
-
const extraFileExtensions = plugins.map(plugin => plugin.
|
|
191
|
-
.flat()
|
|
192
|
-
.map(ext => ({
|
|
193
|
-
extension: ext.substring(1),
|
|
194
|
-
isMixedContent: true,
|
|
195
|
-
scriptKind: ts.ScriptKind.Deferred,
|
|
196
|
-
}));
|
|
198
|
+
const extraFileExtensions = plugins.map(plugin => plugin.extraFileExtensions).flat();
|
|
197
199
|
try {
|
|
198
200
|
let content;
|
|
199
201
|
if (typeof tsConfig === 'string') {
|
|
200
202
|
const config = ts.readJsonConfigFile(tsConfig, sys.readFile);
|
|
201
|
-
content = ts.parseJsonSourceFileConfigFileContent(config, sys,
|
|
203
|
+
content = ts.parseJsonSourceFileConfigFileContent(config, sys, path.dirname(tsConfig), {}, tsConfig, undefined, extraFileExtensions);
|
|
202
204
|
}
|
|
203
205
|
else {
|
|
204
|
-
content = ts.parseJsonConfigFileContent({}, sys, rootPath, tsConfig,
|
|
206
|
+
content = ts.parseJsonConfigFileContent({}, sys, rootPath, tsConfig, path.join(rootPath, 'jsconfig.json'), undefined, extraFileExtensions);
|
|
205
207
|
}
|
|
206
208
|
// fix https://github.com/johnsoncodehk/volar/issues/1786
|
|
207
209
|
// https://github.com/microsoft/TypeScript/issues/30457
|
|
@@ -227,20 +229,19 @@ function getHTMLDocumentContext(ts, host) {
|
|
|
227
229
|
const resolveResult = ts.resolveModuleName(ref, isUri ? shared.getPathOfUri(base) : base, host.getCompilationSettings(), host);
|
|
228
230
|
const failedLookupLocations = resolveResult.failedLookupLocations;
|
|
229
231
|
const dirs = new Set();
|
|
230
|
-
for (
|
|
231
|
-
|
|
232
|
-
const fileName = upath.basename(path);
|
|
232
|
+
for (let failed of failedLookupLocations) {
|
|
233
|
+
const fileName = path.basename(failed);
|
|
233
234
|
if (fileName === 'index.d.ts' || fileName === '*.d.ts') {
|
|
234
|
-
dirs.add(
|
|
235
|
+
dirs.add(path.dirname(failed));
|
|
235
236
|
}
|
|
236
|
-
if (
|
|
237
|
-
|
|
237
|
+
if (failed.endsWith('.d.ts')) {
|
|
238
|
+
failed = failed.substring(0, failed.length - '.d.ts'.length);
|
|
238
239
|
}
|
|
239
240
|
else {
|
|
240
241
|
continue;
|
|
241
242
|
}
|
|
242
|
-
if (host.fileExists(
|
|
243
|
-
return isUri ? shared.getUriByPath(vscode_uri_1.URI.parse(base),
|
|
243
|
+
if (host.fileExists(failed)) {
|
|
244
|
+
return isUri ? shared.getUriByPath(vscode_uri_1.URI.parse(base), failed) : failed;
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
for (const dir of dirs) {
|
package/out/utils/snapshots.d.ts
CHANGED
|
@@ -33,10 +33,10 @@ export declare function createSnapshots(connection: vscode.Connection): {
|
|
|
33
33
|
uriGet: (_uri: string) => IncrementalScriptSnapshot | undefined;
|
|
34
34
|
uriHas: (_uri: string) => boolean;
|
|
35
35
|
uriSet: (_uri: string, item: IncrementalScriptSnapshot) => void;
|
|
36
|
-
pathDelete: (rootUri: shared.
|
|
37
|
-
pathGet: (rootUri: shared.
|
|
38
|
-
pathHas: (rootUri: shared.
|
|
39
|
-
pathSet: (rootUri: shared.
|
|
36
|
+
pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
|
|
37
|
+
pathGet: (rootUri: shared._2.URI, path: string) => IncrementalScriptSnapshot | undefined;
|
|
38
|
+
pathHas: (rootUri: shared._2.URI, path: string) => IncrementalScriptSnapshot | undefined;
|
|
39
|
+
pathSet: (rootUri: shared._2.URI, path: string, item: IncrementalScriptSnapshot) => void;
|
|
40
40
|
};
|
|
41
41
|
onDidOpen: (cb: (params: vscode.DidOpenTextDocumentParams) => void) => () => boolean;
|
|
42
42
|
onDidChangeContent: (cb: (params: vscode.DidChangeTextDocumentParams) => void) => () => boolean;
|
|
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.createWebFileSystemHost = void 0;
|
|
12
12
|
const shared = require("@volar/shared");
|
|
13
|
-
const
|
|
13
|
+
const path = require("typesafe-path");
|
|
14
14
|
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
|
15
15
|
const vscode = require("vscode-languageserver");
|
|
16
16
|
const vscode_uri_1 = require("vscode-uri");
|
|
17
|
-
const
|
|
17
|
+
const protocol_1 = require("../protocol");
|
|
18
18
|
const utilities_1 = require("./ts/utilities");
|
|
19
19
|
let currentCwd = '/';
|
|
20
20
|
function createWebFileSystemHost() {
|
|
@@ -37,8 +37,8 @@ function createWebFileSystemHost() {
|
|
|
37
37
|
connection.onDidChangeWatchedFiles(params => {
|
|
38
38
|
for (const change of params.changes) {
|
|
39
39
|
const fsPath = vscode_uri_1.URI.parse(change.uri).fsPath;
|
|
40
|
-
const dir = getDir(
|
|
41
|
-
const name =
|
|
40
|
+
const dir = getDir(path.dirname(fsPath));
|
|
41
|
+
const name = path.basename(fsPath);
|
|
42
42
|
if (change.type === vscode.FileChangeType.Created) {
|
|
43
43
|
dir.fileTypes.set(name, vscode_html_languageservice_1.FileType.File);
|
|
44
44
|
}
|
|
@@ -93,12 +93,12 @@ function createWebFileSystemHost() {
|
|
|
93
93
|
process.chdir(rootUri.fsPath);
|
|
94
94
|
currentCwd = rootUri.fsPath;
|
|
95
95
|
}
|
|
96
|
-
return
|
|
96
|
+
return path.resolve(fsPath);
|
|
97
97
|
}
|
|
98
98
|
function fileExists(fsPath) {
|
|
99
99
|
fsPath = resolvePath(fsPath);
|
|
100
|
-
const dir = getDir(
|
|
101
|
-
const name =
|
|
100
|
+
const dir = getDir(path.dirname(fsPath));
|
|
101
|
+
const name = path.basename(fsPath);
|
|
102
102
|
if (dir.fileTypes.has(name)) {
|
|
103
103
|
return dir.fileTypes.get(name) === vscode_html_languageservice_1.FileType.File || dir.fileTypes.get(name) === vscode_html_languageservice_1.FileType.SymbolicLink;
|
|
104
104
|
}
|
|
@@ -113,8 +113,8 @@ function createWebFileSystemHost() {
|
|
|
113
113
|
}
|
|
114
114
|
function readFile(fsPath) {
|
|
115
115
|
fsPath = resolvePath(fsPath);
|
|
116
|
-
const dir = getDir(
|
|
117
|
-
const name =
|
|
116
|
+
const dir = getDir(path.dirname(fsPath));
|
|
117
|
+
const name = path.basename(fsPath);
|
|
118
118
|
if (dir.fileTexts.has(name)) {
|
|
119
119
|
return dir.fileTexts.get(name);
|
|
120
120
|
}
|
|
@@ -129,7 +129,8 @@ function createWebFileSystemHost() {
|
|
|
129
129
|
}
|
|
130
130
|
function readDirectory(fsPath, extensions, exclude, include, depth) {
|
|
131
131
|
fsPath = resolvePath(fsPath);
|
|
132
|
-
return (0, utilities_1.matchFiles)(fsPath, extensions, exclude, include, false, rootUri.fsPath, depth,
|
|
132
|
+
return (0, utilities_1.matchFiles)(fsPath, extensions, exclude, include, false, rootUri.fsPath, depth, _dirPath => {
|
|
133
|
+
let dirPath = _dirPath;
|
|
133
134
|
dirPath = resolvePath(dirPath);
|
|
134
135
|
const dir = getDir(dirPath);
|
|
135
136
|
const files = [...dir.fileTypes];
|
|
@@ -173,9 +174,9 @@ function createWebFileSystemHost() {
|
|
|
173
174
|
function statAsync(connection, fsPath, dir) {
|
|
174
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
176
|
const uri = getFsPathUri(fsPath);
|
|
176
|
-
const result = yield connection.sendRequest(
|
|
177
|
+
const result = yield connection.sendRequest(protocol_1.FsStatRequest.type, uri.toString());
|
|
177
178
|
if ((result === null || result === void 0 ? void 0 : result.type) === vscode_html_languageservice_1.FileType.File || (result === null || result === void 0 ? void 0 : result.type) === vscode_html_languageservice_1.FileType.SymbolicLink) {
|
|
178
|
-
const name =
|
|
179
|
+
const name = path.basename(fsPath);
|
|
179
180
|
dir.fileTypes.set(name, result.type);
|
|
180
181
|
changes.push({
|
|
181
182
|
uri: uri.toString(),
|
|
@@ -187,9 +188,9 @@ function createWebFileSystemHost() {
|
|
|
187
188
|
function readFileAsync(connection, fsPath, dir) {
|
|
188
189
|
return __awaiter(this, void 0, void 0, function* () {
|
|
189
190
|
const uri = getFsPathUri(fsPath);
|
|
190
|
-
const text = yield connection.sendRequest(
|
|
191
|
+
const text = yield connection.sendRequest(protocol_1.FsReadFileRequest.type, uri.toString());
|
|
191
192
|
if (text) {
|
|
192
|
-
const name =
|
|
193
|
+
const name = path.basename(fsPath);
|
|
193
194
|
dir.fileTexts.set(name, text);
|
|
194
195
|
changes.push({
|
|
195
196
|
uri: uri.toString(),
|
|
@@ -201,11 +202,11 @@ function createWebFileSystemHost() {
|
|
|
201
202
|
function readDirectoryAsync(connection, fsPath, dir) {
|
|
202
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
203
204
|
const uri = getFsPathUri(fsPath);
|
|
204
|
-
const result = yield connection.sendRequest(
|
|
205
|
+
const result = yield connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, uri.toString());
|
|
205
206
|
for (const [name, fileType] of result) {
|
|
206
207
|
if (dir.fileTypes.get(name) !== fileType && (fileType === vscode_html_languageservice_1.FileType.File || fileType === vscode_html_languageservice_1.FileType.SymbolicLink)) {
|
|
207
208
|
changes.push({
|
|
208
|
-
uri: getFsPathUri(
|
|
209
|
+
uri: getFsPathUri(path.join(fsPath, name)).toString(),
|
|
209
210
|
type: vscode.FileChangeType.Created,
|
|
210
211
|
});
|
|
211
212
|
}
|
|
@@ -244,11 +245,11 @@ function createWebFileSystemHost() {
|
|
|
244
245
|
function getDir(dirPath) {
|
|
245
246
|
const dirNames = [];
|
|
246
247
|
let currentDirPath = dirPath;
|
|
247
|
-
let currentDirName =
|
|
248
|
+
let currentDirName = path.basename(currentDirPath);
|
|
248
249
|
while (currentDirName !== '') {
|
|
249
250
|
dirNames.push(currentDirName);
|
|
250
|
-
currentDirPath =
|
|
251
|
-
currentDirName =
|
|
251
|
+
currentDirPath = path.dirname(currentDirPath);
|
|
252
|
+
currentDirName = path.basename(currentDirPath);
|
|
252
253
|
}
|
|
253
254
|
let currentDir = root;
|
|
254
255
|
for (let i = dirNames.length - 1; i >= 0; i--) {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as shared from '@volar/shared';
|
|
2
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
|
+
import * as path from 'typesafe-path';
|
|
3
4
|
import * as vscode from 'vscode-languageserver';
|
|
4
5
|
import { Project } from './project';
|
|
5
|
-
import { LanguageServerPlugin, RuntimeEnvironment, FileSystemHost
|
|
6
|
+
import { LanguageServerPlugin, RuntimeEnvironment, FileSystemHost } from '../types';
|
|
6
7
|
import { createSnapshots } from './snapshots';
|
|
7
8
|
import { URI } from 'vscode-uri';
|
|
8
9
|
import { ConfigurationHost } from '@volar/vue-language-service';
|
|
10
|
+
import { CancellactionTokenHost } from './cancellationPipe';
|
|
9
11
|
export declare const rootTsConfigNames: string[];
|
|
10
|
-
export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, rootUri: URI, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized: ts.MapLike<string> | undefined,
|
|
12
|
+
export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, rootUri: URI, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized: ts.MapLike<string> | undefined, documents: ReturnType<typeof createSnapshots>, configHost: ConfigurationHost | undefined, cancelTokenHost: CancellactionTokenHost): Promise<{
|
|
11
13
|
projects: {
|
|
12
14
|
clear: () => void;
|
|
13
15
|
values: () => IterableIterator<Project>;
|
|
@@ -15,16 +17,16 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
|
|
|
15
17
|
uriGet: (_uri: string) => Project | undefined;
|
|
16
18
|
uriHas: (_uri: string) => boolean;
|
|
17
19
|
uriSet: (_uri: string, item: Project) => void;
|
|
18
|
-
pathDelete: (rootUri: shared.
|
|
19
|
-
pathGet: (rootUri: shared.
|
|
20
|
-
pathHas: (rootUri: shared.
|
|
21
|
-
pathSet: (rootUri: shared.
|
|
20
|
+
pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
|
|
21
|
+
pathGet: (rootUri: shared._2.URI, path: string) => Project | undefined;
|
|
22
|
+
pathHas: (rootUri: shared._2.URI, path: string) => Project | undefined;
|
|
23
|
+
pathSet: (rootUri: shared._2.URI, path: string, item: Project) => void;
|
|
22
24
|
};
|
|
23
25
|
getProjectAndTsConfig: (uri: string) => Promise<{
|
|
24
26
|
tsconfig: string;
|
|
25
27
|
project: {
|
|
26
28
|
getLanguageService: () => {
|
|
27
|
-
doValidation: (uri: string, response?: ((result: vscode.Diagnostic[]) => void) | undefined
|
|
29
|
+
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
28
30
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
29
31
|
findFileReferences: (uri: string) => import("@volar/language-service").NullableResult<vscode.Location[]>;
|
|
30
32
|
findDefinition: (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -33,7 +35,7 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
|
|
|
33
35
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
34
36
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
35
37
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
36
|
-
getSemanticTokens: (uri: string, range
|
|
38
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/vue-language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/vue-language-service").SemanticToken[] | undefined> | undefined;
|
|
37
39
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
38
40
|
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
|
|
39
41
|
isIncomplete: boolean;
|
|
@@ -67,7 +69,7 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
|
|
|
67
69
|
context: import("@volar/language-service").LanguageServiceRuntimeContext;
|
|
68
70
|
};
|
|
69
71
|
getLanguageServiceDontCreate: () => {
|
|
70
|
-
doValidation: (uri: string, response?: ((result: vscode.Diagnostic[]) => void) | undefined
|
|
72
|
+
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
71
73
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
72
74
|
findFileReferences: (uri: string) => import("@volar/language-service").NullableResult<vscode.Location[]>;
|
|
73
75
|
findDefinition: (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -76,7 +78,7 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
|
|
|
76
78
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
77
79
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
78
80
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
79
|
-
getSemanticTokens: (uri: string, range
|
|
81
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/vue-language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/vue-language-service").SemanticToken[] | undefined> | undefined;
|
|
80
82
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
81
83
|
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
|
|
82
84
|
isIncomplete: boolean;
|
|
@@ -117,4 +119,4 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
|
|
|
117
119
|
reload: () => void;
|
|
118
120
|
dispose(): void;
|
|
119
121
|
}>;
|
|
120
|
-
export declare function sortTsConfigs(fsPath:
|
|
122
|
+
export declare function sortTsConfigs(fsPath: path.OsPath, a: path.OsPath, b: path.OsPath): number;
|
|
@@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.sortTsConfigs = exports.createWorkspaceProjects = exports.rootTsConfigNames = void 0;
|
|
12
12
|
const shared = require("@volar/shared");
|
|
13
|
-
const path = require("
|
|
13
|
+
const path = require("typesafe-path");
|
|
14
14
|
const vscode = require("vscode-languageserver");
|
|
15
15
|
const project_1 = require("./project");
|
|
16
16
|
const inferredCompilerOptions_1 = require("./inferredCompilerOptions");
|
|
17
17
|
const vscode_uri_1 = require("vscode-uri");
|
|
18
18
|
exports.rootTsConfigNames = ['tsconfig.json', 'jsconfig.json'];
|
|
19
|
-
function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLocalized,
|
|
19
|
+
function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLocalized, documents, configHost, cancelTokenHost) {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
let inferredProject;
|
|
22
22
|
const sys = fsHost.getWorkspaceFileSystem(rootUri);
|
|
@@ -26,7 +26,7 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
|
|
|
26
26
|
const disposeWatch = fsHost.onDidChangeWatchedFiles((params, reason) => __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const disposes = [];
|
|
28
28
|
for (const change of params.changes) {
|
|
29
|
-
if (exports.rootTsConfigNames.includes(
|
|
29
|
+
if (exports.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1))) {
|
|
30
30
|
if (change.type === vscode.FileChangeType.Created) {
|
|
31
31
|
if (shared.isFileInDir(vscode_uri_1.URI.parse(change.uri).fsPath, rootUri.fsPath)) {
|
|
32
32
|
rootTsConfigs.add(vscode_uri_1.URI.parse(change.uri).fsPath);
|
|
@@ -88,7 +88,7 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
|
|
|
88
88
|
if (!inferredProject) {
|
|
89
89
|
inferredProject = (() => __awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
const inferOptions = yield (0, inferredCompilerOptions_1.getInferredCompilerOptions)(ts, configHost);
|
|
91
|
-
return (0, project_1.createProject)(runtimeEnv, plugins, fsHost, ts,
|
|
91
|
+
return (0, project_1.createProject)(runtimeEnv, plugins, fsHost, ts, rootUri, inferOptions, tsLocalized, documents, configHost, documentRegistry, cancelTokenHost);
|
|
92
92
|
}))();
|
|
93
93
|
}
|
|
94
94
|
return inferredProject;
|
|
@@ -195,10 +195,11 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
|
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
|
-
function getProjectByCreate(
|
|
198
|
+
function getProjectByCreate(_tsConfig) {
|
|
199
|
+
const tsConfig = shared.normalizeFileName(_tsConfig);
|
|
199
200
|
let project = projects.pathGet(rootUri, tsConfig);
|
|
200
201
|
if (!project) {
|
|
201
|
-
project = (0, project_1.createProject)(runtimeEnv, plugins, fsHost, ts,
|
|
202
|
+
project = (0, project_1.createProject)(runtimeEnv, plugins, fsHost, ts, vscode_uri_1.URI.parse(shared.getUriByPath(rootUri, path.dirname(tsConfig))), tsConfig, tsLocalized, documents, configHost, documentRegistry, cancelTokenHost);
|
|
202
203
|
projects.pathSet(rootUri, tsConfig, project);
|
|
203
204
|
}
|
|
204
205
|
return project;
|
|
@@ -214,8 +215,8 @@ function sortTsConfigs(fsPath, a, b) {
|
|
|
214
215
|
const bWeight = inB ? 1 : 0;
|
|
215
216
|
return bWeight - aWeight;
|
|
216
217
|
}
|
|
217
|
-
const aLength = a.split('/').length;
|
|
218
|
-
const bLength =
|
|
218
|
+
const aLength = shared.normalizeFileName(a).split('/').length;
|
|
219
|
+
const bLength = shared.normalizeFileName(a).split('/').length;
|
|
219
220
|
if (aLength === bLength) {
|
|
220
221
|
const aWeight = path.basename(a) === 'tsconfig.json' ? 1 : 0;
|
|
221
222
|
const bWeight = path.basename(b) === 'tsconfig.json' ? 1 : 0;
|
|
@@ -3,11 +3,12 @@ import { ConfigurationHost } from '@volar/vue-language-service';
|
|
|
3
3
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
4
4
|
import * as vscode from 'vscode-languageserver';
|
|
5
5
|
import { URI } from 'vscode-uri';
|
|
6
|
-
import { FileSystemHost, LanguageServerPlugin, RuntimeEnvironment,
|
|
6
|
+
import { FileSystemHost, LanguageServerPlugin, RuntimeEnvironment, LanguageServerInitializationOptions } from '../types';
|
|
7
7
|
import { createSnapshots } from './snapshots';
|
|
8
|
+
import { CancellactionTokenHost } from './cancellationPipe';
|
|
8
9
|
export interface Workspaces extends ReturnType<typeof createWorkspaces> {
|
|
9
10
|
}
|
|
10
|
-
export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, configurationHost: ConfigurationHost | undefined, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized: ts.MapLike<string> | undefined, client: vscode.ClientCapabilities, options:
|
|
11
|
+
export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, configurationHost: ConfigurationHost | undefined, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized: ts.MapLike<string> | undefined, client: vscode.ClientCapabilities, options: LanguageServerInitializationOptions, documents: ReturnType<typeof createSnapshots>, connection: vscode.Connection, cancelTokenHost: CancellactionTokenHost): {
|
|
11
12
|
workspaces: Map<string, Promise<{
|
|
12
13
|
projects: {
|
|
13
14
|
clear: () => void;
|
|
@@ -16,16 +17,16 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
16
17
|
uriGet: (_uri: string) => import("./project").Project | undefined;
|
|
17
18
|
uriHas: (_uri: string) => boolean;
|
|
18
19
|
uriSet: (_uri: string, item: import("./project").Project) => void;
|
|
19
|
-
pathDelete: (rootUri: shared.
|
|
20
|
-
pathGet: (rootUri: shared.
|
|
21
|
-
pathHas: (rootUri: shared.
|
|
22
|
-
pathSet: (rootUri: shared.
|
|
20
|
+
pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
|
|
21
|
+
pathGet: (rootUri: shared._2.URI, path: string) => import("./project").Project | undefined;
|
|
22
|
+
pathHas: (rootUri: shared._2.URI, path: string) => import("./project").Project | undefined;
|
|
23
|
+
pathSet: (rootUri: shared._2.URI, path: string, item: import("./project").Project) => void;
|
|
23
24
|
};
|
|
24
25
|
getProjectAndTsConfig: (uri: string) => Promise<{
|
|
25
26
|
tsconfig: string;
|
|
26
27
|
project: {
|
|
27
28
|
getLanguageService: () => {
|
|
28
|
-
doValidation: (uri: string, response?: ((result: vscode.Diagnostic[]) => void) | undefined
|
|
29
|
+
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
29
30
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
30
31
|
findFileReferences: (uri: string) => import("@volar/language-service").NullableResult<vscode.Location[]>;
|
|
31
32
|
findDefinition: (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -34,7 +35,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
34
35
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
35
36
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
36
37
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
37
|
-
getSemanticTokens: (uri: string, range
|
|
38
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/vue-language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/vue-language-service").SemanticToken[] | undefined> | undefined;
|
|
38
39
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
39
40
|
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
|
|
40
41
|
isIncomplete: boolean;
|
|
@@ -68,7 +69,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
68
69
|
context: import("@volar/language-service").LanguageServiceRuntimeContext;
|
|
69
70
|
};
|
|
70
71
|
getLanguageServiceDontCreate: () => {
|
|
71
|
-
doValidation: (uri: string, response?: ((result: vscode.Diagnostic[]) => void) | undefined
|
|
72
|
+
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
72
73
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
73
74
|
findFileReferences: (uri: string) => import("@volar/language-service").NullableResult<vscode.Location[]>;
|
|
74
75
|
findDefinition: (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -77,7 +78,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
77
78
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
78
79
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
79
80
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
80
|
-
getSemanticTokens: (uri: string, range
|
|
81
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/vue-language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/vue-language-service").SemanticToken[] | undefined> | undefined;
|
|
81
82
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
82
83
|
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
|
|
83
84
|
isIncomplete: boolean;
|
|
@@ -122,7 +123,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
122
123
|
tsconfig: string;
|
|
123
124
|
project: {
|
|
124
125
|
getLanguageService: () => {
|
|
125
|
-
doValidation: (uri: string, response?: ((result: vscode.Diagnostic[]) => void) | undefined
|
|
126
|
+
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
126
127
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
127
128
|
findFileReferences: (uri: string) => import("@volar/language-service").NullableResult<vscode.Location[]>;
|
|
128
129
|
findDefinition: (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -131,7 +132,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
131
132
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
132
133
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
133
134
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
134
|
-
getSemanticTokens: (uri: string, range
|
|
135
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/vue-language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/vue-language-service").SemanticToken[] | undefined> | undefined;
|
|
135
136
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
136
137
|
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
|
|
137
138
|
isIncomplete: boolean;
|
|
@@ -165,7 +166,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
165
166
|
context: import("@volar/language-service").LanguageServiceRuntimeContext;
|
|
166
167
|
};
|
|
167
168
|
getLanguageServiceDontCreate: () => {
|
|
168
|
-
doValidation: (uri: string, response?: ((result: vscode.Diagnostic[]) => void) | undefined
|
|
169
|
+
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
169
170
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
170
171
|
findFileReferences: (uri: string) => import("@volar/language-service").NullableResult<vscode.Location[]>;
|
|
171
172
|
findDefinition: (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -174,7 +175,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
174
175
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
175
176
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
176
177
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
177
|
-
getSemanticTokens: (uri: string, range
|
|
178
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/vue-language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/vue-language-service").SemanticToken[] | undefined> | undefined;
|
|
178
179
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
179
180
|
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
|
|
180
181
|
isIncomplete: boolean;
|
|
@@ -214,7 +215,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
214
215
|
tsconfig: undefined;
|
|
215
216
|
project: {
|
|
216
217
|
getLanguageService: () => {
|
|
217
|
-
doValidation: (uri: string, response?: ((result: vscode.Diagnostic[]) => void) | undefined
|
|
218
|
+
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
218
219
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
219
220
|
findFileReferences: (uri: string) => import("@volar/language-service").NullableResult<vscode.Location[]>;
|
|
220
221
|
findDefinition: (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -223,7 +224,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
223
224
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
224
225
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
225
226
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
226
|
-
getSemanticTokens: (uri: string, range
|
|
227
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/vue-language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/vue-language-service").SemanticToken[] | undefined> | undefined;
|
|
227
228
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
228
229
|
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
|
|
229
230
|
isIncomplete: boolean;
|
|
@@ -257,7 +258,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
257
258
|
context: import("@volar/language-service").LanguageServiceRuntimeContext;
|
|
258
259
|
};
|
|
259
260
|
getLanguageServiceDontCreate: () => {
|
|
260
|
-
doValidation: (uri: string, response?: ((result: vscode.Diagnostic[]) => void) | undefined
|
|
261
|
+
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
261
262
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
262
263
|
findFileReferences: (uri: string) => import("@volar/language-service").NullableResult<vscode.Location[]>;
|
|
263
264
|
findDefinition: (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -266,7 +267,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
|
|
|
266
267
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
267
268
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
268
269
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
269
|
-
getSemanticTokens: (uri: string, range
|
|
270
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/vue-language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/vue-language-service").SemanticToken[] | undefined> | undefined;
|
|
270
271
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
271
272
|
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
|
|
272
273
|
isIncomplete: boolean;
|
package/out/utils/workspaces.js
CHANGED
|
@@ -10,10 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.createWorkspaces = void 0;
|
|
12
12
|
const shared = require("@volar/shared");
|
|
13
|
+
const vscode = require("vscode-languageserver");
|
|
13
14
|
const vscode_uri_1 = require("vscode-uri");
|
|
14
15
|
const types_1 = require("../types");
|
|
15
16
|
const workspaceProjects_1 = require("./workspaceProjects");
|
|
16
|
-
function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, tsLocalized, client, options, documents, connection) {
|
|
17
|
+
function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, tsLocalized, client, options, documents, connection, cancelTokenHost) {
|
|
17
18
|
var _a;
|
|
18
19
|
let semanticTokensReq = 0;
|
|
19
20
|
let documentUpdatedReq = 0;
|
|
@@ -44,7 +45,7 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
|
|
|
44
45
|
getProject,
|
|
45
46
|
reloadProject,
|
|
46
47
|
add: (rootUri) => {
|
|
47
|
-
workspaces.set(rootUri.toString(), (0, workspaceProjects_1.createWorkspaceProjects)(runtimeEnv, plugins, fsHost, rootUri, ts, tsLocalized,
|
|
48
|
+
workspaces.set(rootUri.toString(), (0, workspaceProjects_1.createWorkspaceProjects)(runtimeEnv, plugins, fsHost, rootUri, ts, tsLocalized, documents, configurationHost, cancelTokenHost));
|
|
48
49
|
},
|
|
49
50
|
remove: (rootUri) => {
|
|
50
51
|
const _workspace = workspaces.get(rootUri.toString());
|
|
@@ -85,13 +86,12 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
|
|
|
85
86
|
return;
|
|
86
87
|
const req = ++documentUpdatedReq;
|
|
87
88
|
const delay = yield (configurationHost === null || configurationHost === void 0 ? void 0 : configurationHost.getConfiguration('volar.diagnostics.delay'));
|
|
88
|
-
const cancel = {
|
|
89
|
+
const cancel = cancelTokenHost.createCancellactionToken({
|
|
89
90
|
get isCancellationRequested() {
|
|
90
91
|
return req !== documentUpdatedReq;
|
|
91
92
|
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
93
|
+
onCancellationRequested: vscode.Event.None,
|
|
94
|
+
});
|
|
95
95
|
const changeDoc = docUri ? documents.data.uriGet(docUri) : undefined;
|
|
96
96
|
const otherDocs = [...documents.data.values()].filter(doc => doc !== changeDoc);
|
|
97
97
|
if (changeDoc) {
|
|
@@ -112,9 +112,9 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
|
|
|
112
112
|
if (!project)
|
|
113
113
|
return;
|
|
114
114
|
const languageService = project.getLanguageService();
|
|
115
|
-
const errors = yield languageService.doValidation(uri, result => {
|
|
115
|
+
const errors = yield languageService.doValidation(uri, cancel, result => {
|
|
116
116
|
connection.sendDiagnostics({ uri: uri, diagnostics: result.map(addVersion), version });
|
|
117
|
-
}
|
|
117
|
+
});
|
|
118
118
|
connection.sendDiagnostics({ uri: uri, diagnostics: errors.map(addVersion), version });
|
|
119
119
|
function addVersion(error) {
|
|
120
120
|
if (error.data === undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"directory": "packages/language-server"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@volar/language-core": "1.0.0-beta.
|
|
21
|
-
"@volar/language-service": "1.0.0-beta.
|
|
22
|
-
"@volar/shared": "1.0.0-beta.
|
|
20
|
+
"@volar/language-core": "1.0.0-beta.3",
|
|
21
|
+
"@volar/language-service": "1.0.0-beta.3",
|
|
22
|
+
"@volar/shared": "1.0.0-beta.3",
|
|
23
23
|
"request-light": "^0.5.8",
|
|
24
|
-
"
|
|
24
|
+
"typesafe-path": "^0.2.0",
|
|
25
25
|
"vscode-html-languageservice": "^5.0.1",
|
|
26
26
|
"vscode-languageserver": "^8.0.2",
|
|
27
27
|
"vscode-languageserver-protocol": "^3.17.2",
|
|
28
28
|
"vscode-languageserver-textdocument": "^1.0.7",
|
|
29
29
|
"vscode-uri": "^3.0.3"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "b7242f995970b4eedfcf068619497eb845e9ac73"
|
|
32
32
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.register = void 0;
|
|
3
|
-
function register(features, server) {
|
|
4
|
-
if (features.selectionRange) {
|
|
5
|
-
server.selectionRangeProvider = true;
|
|
6
|
-
}
|
|
7
|
-
if (features.foldingRange) {
|
|
8
|
-
server.foldingRangeProvider = true;
|
|
9
|
-
}
|
|
10
|
-
if (features.linkedEditingRange) {
|
|
11
|
-
server.linkedEditingRangeProvider = true;
|
|
12
|
-
}
|
|
13
|
-
if (features.documentColor) {
|
|
14
|
-
server.colorProvider = true;
|
|
15
|
-
}
|
|
16
|
-
if (features.documentSymbol) {
|
|
17
|
-
server.documentSymbolProvider = true;
|
|
18
|
-
}
|
|
19
|
-
if (features.documentFormatting) {
|
|
20
|
-
server.documentFormattingProvider = true;
|
|
21
|
-
server.documentRangeFormattingProvider = true;
|
|
22
|
-
// https://github.com/microsoft/vscode/blob/ce119308e8fd4cd3f992d42b297588e7abe33a0c/extensions/typescript-language-features/src/languageFeatures/formatting.ts#L99
|
|
23
|
-
server.documentOnTypeFormattingProvider = {
|
|
24
|
-
firstTriggerCharacter: ';',
|
|
25
|
-
moreTriggerCharacter: ['}', '\n'],
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.register = register;
|
|
30
|
-
//# sourceMappingURL=registerDocumentFeatures.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { LanguageServerPlugin, ServerInitializationOptions } from '../types';
|
|
2
|
-
import * as vscode from 'vscode-languageserver';
|
|
3
|
-
export declare function register(features: NonNullable<ServerInitializationOptions['languageFeatures']>, server: vscode.ServerCapabilities, plugins: ReturnType<LanguageServerPlugin>[]): void;
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.register = void 0;
|
|
3
|
-
const embedded = require("@volar/language-service");
|
|
4
|
-
const vscode = require("vscode-languageserver");
|
|
5
|
-
function register(features, server, plugins) {
|
|
6
|
-
var _a, _b, _c, _d;
|
|
7
|
-
if (features.references) {
|
|
8
|
-
server.referencesProvider = true;
|
|
9
|
-
}
|
|
10
|
-
if (features.implementation) {
|
|
11
|
-
server.implementationProvider = true;
|
|
12
|
-
}
|
|
13
|
-
if (features.definition) {
|
|
14
|
-
server.definitionProvider = true;
|
|
15
|
-
}
|
|
16
|
-
if (features.typeDefinition) {
|
|
17
|
-
server.typeDefinitionProvider = true;
|
|
18
|
-
}
|
|
19
|
-
if (features.callHierarchy) {
|
|
20
|
-
server.callHierarchyProvider = true;
|
|
21
|
-
}
|
|
22
|
-
if (features.hover) {
|
|
23
|
-
server.hoverProvider = true;
|
|
24
|
-
}
|
|
25
|
-
if (features.rename) {
|
|
26
|
-
server.renameProvider = {
|
|
27
|
-
prepareProvider: true,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
if (features.renameFileRefactoring) {
|
|
31
|
-
server.workspace = {
|
|
32
|
-
fileOperations: {
|
|
33
|
-
willRename: {
|
|
34
|
-
filters: [
|
|
35
|
-
...plugins.map(plugin => plugin.extensions.map(ext => ({ pattern: { glob: `**/*${ext}` } }))).flat(),
|
|
36
|
-
{ pattern: { glob: '**/*.js' } },
|
|
37
|
-
{ pattern: { glob: '**/*.ts' } },
|
|
38
|
-
{ pattern: { glob: '**/*.jsx' } },
|
|
39
|
-
{ pattern: { glob: '**/*.tsx' } },
|
|
40
|
-
{ pattern: { glob: '**/*.json' } },
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if (features.signatureHelp) {
|
|
47
|
-
server.signatureHelpProvider = {
|
|
48
|
-
triggerCharacters: ['(', ',', '<'],
|
|
49
|
-
retriggerCharacters: [')'],
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (features.completion) {
|
|
53
|
-
server.completionProvider = {
|
|
54
|
-
// triggerCharacters: '!@#$%^&*()_+-=`~{}|[]\:";\'<>?,./ '.split(''), // all symbols on keyboard
|
|
55
|
-
// hardcode to fix https://github.com/sublimelsp/LSP-volar/issues/114
|
|
56
|
-
triggerCharacters: [...new Set([
|
|
57
|
-
'/', '-', ':',
|
|
58
|
-
...'>+^*()#.[]$@-{}'.split(''),
|
|
59
|
-
'.', ':', '<', '"', '=', '/',
|
|
60
|
-
'@',
|
|
61
|
-
'"', ':',
|
|
62
|
-
'.', '"', '\'', '`', '/', '<', '@', '#', ' ',
|
|
63
|
-
'*',
|
|
64
|
-
'@', // typescript-comment
|
|
65
|
-
])],
|
|
66
|
-
resolveProvider: true,
|
|
67
|
-
};
|
|
68
|
-
if (typeof features.completion === 'object' && features.completion.ignoreTriggerCharacters) {
|
|
69
|
-
const ignores = features.completion.ignoreTriggerCharacters;
|
|
70
|
-
server.completionProvider.triggerCharacters = (_a = server.completionProvider.triggerCharacters) === null || _a === void 0 ? void 0 : _a.filter(c => !ignores.includes(c));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (features.documentHighlight) {
|
|
74
|
-
server.documentHighlightProvider = true;
|
|
75
|
-
}
|
|
76
|
-
if (features.documentLink) {
|
|
77
|
-
server.documentLinkProvider = {
|
|
78
|
-
resolveProvider: false, // TODO
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
if (features.workspaceSymbol) {
|
|
82
|
-
server.workspaceSymbolProvider = true;
|
|
83
|
-
}
|
|
84
|
-
if (features.codeLens) {
|
|
85
|
-
server.codeLensProvider = {
|
|
86
|
-
resolveProvider: true,
|
|
87
|
-
};
|
|
88
|
-
server.executeCommandProvider = {
|
|
89
|
-
commands: [
|
|
90
|
-
...((_c = (_b = server.executeCommandProvider) === null || _b === void 0 ? void 0 : _b.commands) !== null && _c !== void 0 ? _c : []),
|
|
91
|
-
embedded.executePluginCommand,
|
|
92
|
-
]
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
if (features.semanticTokens) {
|
|
96
|
-
server.semanticTokensProvider = {
|
|
97
|
-
range: true,
|
|
98
|
-
full: false,
|
|
99
|
-
legend: {
|
|
100
|
-
tokenModifiers: [],
|
|
101
|
-
tokenTypes: [],
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
for (const plugin of plugins) {
|
|
105
|
-
if ((_d = plugin.languageService) === null || _d === void 0 ? void 0 : _d.semanticTokenLegend) {
|
|
106
|
-
server.semanticTokensProvider.legend.tokenModifiers = server.semanticTokensProvider.legend.tokenModifiers.concat(plugin.languageService.semanticTokenLegend.tokenModifiers);
|
|
107
|
-
server.semanticTokensProvider.legend.tokenTypes = server.semanticTokensProvider.legend.tokenTypes.concat(plugin.languageService.semanticTokenLegend.tokenTypes);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (features.codeAction) {
|
|
112
|
-
server.codeActionProvider = {
|
|
113
|
-
codeActionKinds: [
|
|
114
|
-
vscode.CodeActionKind.Empty,
|
|
115
|
-
vscode.CodeActionKind.QuickFix,
|
|
116
|
-
vscode.CodeActionKind.Refactor,
|
|
117
|
-
vscode.CodeActionKind.RefactorExtract,
|
|
118
|
-
vscode.CodeActionKind.RefactorInline,
|
|
119
|
-
vscode.CodeActionKind.RefactorRewrite,
|
|
120
|
-
vscode.CodeActionKind.Source,
|
|
121
|
-
vscode.CodeActionKind.SourceFixAll,
|
|
122
|
-
vscode.CodeActionKind.SourceOrganizeImports,
|
|
123
|
-
],
|
|
124
|
-
resolveProvider: true,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
if (features.inlayHints) {
|
|
128
|
-
server.inlayHintProvider = true;
|
|
129
|
-
}
|
|
130
|
-
// buggy
|
|
131
|
-
// if (features.diagnostics) {
|
|
132
|
-
// server.diagnosticProvider = {
|
|
133
|
-
// documentSelector: [
|
|
134
|
-
// ...languageConfigs.definitelyExts.map(ext => ({ pattern: `**/*${ext}` })),
|
|
135
|
-
// ...languageConfigs.indeterminateExts.map(ext => ({ pattern: `**/*${ext}` })),
|
|
136
|
-
// { pattern: '**/*.{ts,js,tsx,jsx}' },
|
|
137
|
-
// ],
|
|
138
|
-
// interFileDependencies: true,
|
|
139
|
-
// workspaceDiagnostics: false,
|
|
140
|
-
// };
|
|
141
|
-
// }
|
|
142
|
-
}
|
|
143
|
-
exports.register = register;
|
|
144
|
-
//# sourceMappingURL=registerlanguageFeatures.js.map
|