@volar/language-server 1.10.9 → 1.10.10-alpha.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/index.js +3 -0
- package/out/common/features/customFeatures.js +2 -1
- package/out/common/features/languageFeatures.d.ts +1 -2
- package/out/common/features/languageFeatures.js +2 -2
- package/out/common/project.d.ts +2 -3
- package/out/common/project.js +5 -5
- package/out/common/server.js +1 -5
- package/out/common/utils/isFileInDir.d.ts +1 -2
- package/out/common/utils/isFileInDir.js +1 -1
- package/out/common/workspaces.d.ts +15 -18
- package/out/common/workspaces.js +2 -2
- package/out/node/cancellationPipe.d.ts +3 -0
- package/out/node/cancellationPipe.js +45 -0
- package/out/node/index.js +2 -0
- package/out/types.d.ts +1 -0
- package/package.json +8 -7
package/out/browser/index.js
CHANGED
|
@@ -71,6 +71,9 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
71
71
|
catch { }
|
|
72
72
|
},
|
|
73
73
|
fs: createFs(connection),
|
|
74
|
+
getCancellationToken(original) {
|
|
75
|
+
return original ?? vscode.CancellationToken.None;
|
|
76
|
+
},
|
|
74
77
|
}));
|
|
75
78
|
}
|
|
76
79
|
exports.startLanguageServer = startLanguageServer;
|
|
@@ -57,7 +57,8 @@ function register(connection, workspaces, env) {
|
|
|
57
57
|
workspaces.reloadProjects();
|
|
58
58
|
});
|
|
59
59
|
connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, async (params) => {
|
|
60
|
-
const
|
|
60
|
+
const fsModeName = 'fs'; // avoid bundle
|
|
61
|
+
const fs = await import(fsModeName);
|
|
61
62
|
const project = await workspaces.getProject(params.uri);
|
|
62
63
|
if (project) {
|
|
63
64
|
const ls = (await project.project)?.getLanguageServiceDontCreate();
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver';
|
|
2
|
-
import { CancellationTokenHost } from '../cancellationPipe';
|
|
3
2
|
import type { Workspaces } from '../workspaces';
|
|
4
3
|
import { RuntimeEnvironment, InitializationOptions } from '../../types';
|
|
5
4
|
import { createDocuments } from '../documents';
|
|
6
|
-
export declare function register(connection: vscode.Connection, workspaces: Workspaces, initParams: vscode.InitializeParams, initOptions: InitializationOptions,
|
|
5
|
+
export declare function register(connection: vscode.Connection, workspaces: Workspaces, initParams: vscode.InitializeParams, initOptions: InitializationOptions, semanticTokensLegend: vscode.SemanticTokensLegend, runtime: RuntimeEnvironment, documents: ReturnType<typeof createDocuments>): void;
|
|
7
6
|
export declare function sleep(ms: number): Promise<unknown>;
|
|
8
7
|
//# sourceMappingURL=languageFeatures.d.ts.map
|
|
@@ -5,7 +5,7 @@ const embedded = require("@volar/language-service");
|
|
|
5
5
|
const vscode = require("vscode-languageserver");
|
|
6
6
|
const protocol_1 = require("../../protocol");
|
|
7
7
|
const types_1 = require("../../types");
|
|
8
|
-
function register(connection, workspaces, initParams, initOptions,
|
|
8
|
+
function register(connection, workspaces, initParams, initOptions, semanticTokensLegend, runtime, documents) {
|
|
9
9
|
let lastCompleteUri;
|
|
10
10
|
let lastCompleteLs;
|
|
11
11
|
let lastCodeLensLs;
|
|
@@ -233,7 +233,7 @@ function register(connection, workspaces, initParams, initOptions, cancelHost, s
|
|
|
233
233
|
});
|
|
234
234
|
connection.languages.diagnostics.on(async (params, token, _workDoneProgressReporter, resultProgressReporter) => {
|
|
235
235
|
const result = await worker(params.textDocument.uri, token, service => {
|
|
236
|
-
const tsToken =
|
|
236
|
+
const tsToken = runtime.getCancellationToken(token);
|
|
237
237
|
const mode = initOptions.serverMode === types_1.ServerMode.PartialSemantic ? 'semantic'
|
|
238
238
|
: initOptions.serverMode === types_1.ServerMode.Syntactic ? 'syntactic'
|
|
239
239
|
: 'all';
|
package/out/common/project.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TypeScriptLanguageHost } from '@volar/language-service';
|
|
2
|
-
import * as path from 'typesafe-path/posix';
|
|
3
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
4
3
|
import * as vscode from 'vscode-languageserver';
|
|
5
4
|
import { URI } from 'vscode-uri';
|
|
@@ -8,13 +7,13 @@ export interface ProjectContext extends WorkspacesContext {
|
|
|
8
7
|
project: {
|
|
9
8
|
workspaceUri: URI;
|
|
10
9
|
rootUri: URI;
|
|
11
|
-
tsConfig:
|
|
10
|
+
tsConfig: string | ts.CompilerOptions;
|
|
12
11
|
};
|
|
13
12
|
}
|
|
14
13
|
export type Project = ReturnType<typeof createProject>;
|
|
15
14
|
export declare function createProject(context: ProjectContext): Promise<{
|
|
16
15
|
context: ProjectContext;
|
|
17
|
-
tsConfig:
|
|
16
|
+
tsConfig: string | ts.CompilerOptions;
|
|
18
17
|
languageHost: TypeScriptLanguageHost;
|
|
19
18
|
getLanguageService: () => {
|
|
20
19
|
getTriggerCharacters: () => string[];
|
package/out/common/project.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createProject = void 0;
|
|
4
4
|
const language_service_1 = require("@volar/language-service");
|
|
5
|
-
const path = require("
|
|
5
|
+
const path = require("path-browserify");
|
|
6
6
|
const vscode = require("vscode-languageserver");
|
|
7
7
|
const serverConfig_1 = require("./utils/serverConfig");
|
|
8
8
|
const uriMap_1 = require("./utils/uriMap");
|
|
@@ -10,7 +10,7 @@ const typescript_1 = require("@volar/typescript");
|
|
|
10
10
|
const globalSnapshots = new WeakMap();
|
|
11
11
|
async function createProject(context) {
|
|
12
12
|
let projectVersion = 0;
|
|
13
|
-
let token = context.
|
|
13
|
+
let token = context.server.runtimeEnv.getCancellationToken();
|
|
14
14
|
let languageService;
|
|
15
15
|
const tsToken = {
|
|
16
16
|
isCancellationRequested() {
|
|
@@ -60,7 +60,7 @@ async function createProject(context) {
|
|
|
60
60
|
};
|
|
61
61
|
const docChangeWatcher = context.workspaces.documents.onDidChangeContent(() => {
|
|
62
62
|
projectVersion++;
|
|
63
|
-
token = context.
|
|
63
|
+
token = context.server.runtimeEnv.getCancellationToken();
|
|
64
64
|
});
|
|
65
65
|
const fileWatch = env.onDidChangeWatchedFiles?.(params => {
|
|
66
66
|
onWorkspaceFilesChanged(params.changes);
|
|
@@ -94,7 +94,7 @@ async function createProject(context) {
|
|
|
94
94
|
if (!parsedCommandLine.fileNames.includes(fileName)) {
|
|
95
95
|
parsedCommandLine.fileNames.push(fileName);
|
|
96
96
|
projectVersion++;
|
|
97
|
-
token = context.
|
|
97
|
+
token = context.server.runtimeEnv.getCancellationToken();
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
100
|
askedFiles,
|
|
@@ -148,7 +148,7 @@ async function createProject(context) {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
if (oldProjectVersion !== projectVersion) {
|
|
151
|
-
token = context.
|
|
151
|
+
token = context.server.runtimeEnv.getCancellationToken();
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
function dispose() {
|
package/out/common/server.js
CHANGED
|
@@ -6,7 +6,6 @@ const l10n = require("@vscode/l10n");
|
|
|
6
6
|
const vscode = require("vscode-languageserver");
|
|
7
7
|
const vscode_uri_1 = require("vscode-uri");
|
|
8
8
|
const types_1 = require("../types");
|
|
9
|
-
const cancellationPipe_1 = require("./cancellationPipe");
|
|
10
9
|
const configurationHost_1 = require("./configurationHost");
|
|
11
10
|
const documents_1 = require("./documents");
|
|
12
11
|
const registerFeatures_1 = require("./utils/registerFeatures");
|
|
@@ -23,7 +22,6 @@ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
|
|
|
23
22
|
let context;
|
|
24
23
|
let ts;
|
|
25
24
|
let tsLocalized;
|
|
26
|
-
let cancelTokenHost;
|
|
27
25
|
const didChangeWatchedFilesCallbacks = new Set();
|
|
28
26
|
connection.onInitialize(async (_params) => {
|
|
29
27
|
initParams = _params;
|
|
@@ -53,7 +51,6 @@ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
|
|
|
53
51
|
tsLocalized = initParams.locale
|
|
54
52
|
? await context.server.runtimeEnv.loadTypeScriptLocalized(options, initParams.locale)
|
|
55
53
|
: undefined;
|
|
56
|
-
cancelTokenHost = (0, cancellationPipe_1.createCancellationTokenHost)(options.cancellationPipeName);
|
|
57
54
|
plugins = context.server.plugins.map(plugin => plugin(options, { typescript: ts }));
|
|
58
55
|
documents = (0, documents_1.createDocuments)(context.server.runtimeEnv, connection);
|
|
59
56
|
if (options.l10n) {
|
|
@@ -203,12 +200,11 @@ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
|
|
|
203
200
|
initParams,
|
|
204
201
|
initOptions: options,
|
|
205
202
|
documents,
|
|
206
|
-
cancelTokenHost,
|
|
207
203
|
plugins,
|
|
208
204
|
},
|
|
209
205
|
}, roots);
|
|
210
206
|
(await import('./features/customFeatures.js')).register(connection, workspaces, context.server.runtimeEnv);
|
|
211
|
-
(await import('./features/languageFeatures.js')).register(connection, workspaces, initParams, options,
|
|
207
|
+
(await import('./features/languageFeatures.js')).register(connection, workspaces, initParams, options, getSemanticTokensLegend(), context.server.runtimeEnv, documents);
|
|
212
208
|
for (const plugin of plugins) {
|
|
213
209
|
plugin.onInitialized?.(getLanguageService, context.server.runtimeEnv);
|
|
214
210
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function isFileInDir(fileName: path.OsPath | path.PosixPath, dir: path.OsPath | path.PosixPath): boolean;
|
|
1
|
+
export declare function isFileInDir(fileName: string, dir: string): boolean;
|
|
3
2
|
//# sourceMappingURL=isFileInDir.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isFileInDir = void 0;
|
|
4
|
-
const path = require("
|
|
4
|
+
const path = require("path-browserify");
|
|
5
5
|
function isFileInDir(fileName, dir) {
|
|
6
6
|
const relative = path.relative(dir, fileName);
|
|
7
7
|
return !!relative && !relative.startsWith('..') && !path.isAbsolute(relative);
|
|
@@ -2,10 +2,8 @@ import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
|
2
2
|
import * as vscode from 'vscode-languageserver';
|
|
3
3
|
import { URI } from 'vscode-uri';
|
|
4
4
|
import { InitializationOptions, LanguageServerPlugin } from '../types';
|
|
5
|
-
import { CancellationTokenHost } from './cancellationPipe';
|
|
6
5
|
import { createDocuments } from './documents';
|
|
7
6
|
import { ServerContext } from './server';
|
|
8
|
-
import * as path from 'typesafe-path/posix';
|
|
9
7
|
export declare const rootTsConfigNames: string[];
|
|
10
8
|
export interface WorkspacesContext extends ServerContext {
|
|
11
9
|
workspaces: {
|
|
@@ -15,7 +13,6 @@ export interface WorkspacesContext extends ServerContext {
|
|
|
15
13
|
ts: typeof import('typescript/lib/tsserverlibrary') | undefined;
|
|
16
14
|
tsLocalized: ts.MapLike<string> | undefined;
|
|
17
15
|
documents: ReturnType<typeof createDocuments>;
|
|
18
|
-
cancelTokenHost: CancellationTokenHost;
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
18
|
export interface Workspaces extends ReturnType<typeof createWorkspaces> {
|
|
@@ -25,7 +22,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
25
22
|
clear: () => void;
|
|
26
23
|
values: () => IterableIterator<Promise<{
|
|
27
24
|
context: import("./project").ProjectContext;
|
|
28
|
-
tsConfig:
|
|
25
|
+
tsConfig: string | ts.CompilerOptions;
|
|
29
26
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
30
27
|
getLanguageService: () => {
|
|
31
28
|
getTriggerCharacters: () => string[];
|
|
@@ -154,7 +151,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
154
151
|
uriDelete: (_uri: string) => boolean;
|
|
155
152
|
uriGet: (_uri: string) => Promise<{
|
|
156
153
|
context: import("./project").ProjectContext;
|
|
157
|
-
tsConfig:
|
|
154
|
+
tsConfig: string | ts.CompilerOptions;
|
|
158
155
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
159
156
|
getLanguageService: () => {
|
|
160
157
|
getTriggerCharacters: () => string[];
|
|
@@ -282,7 +279,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
282
279
|
uriHas: (_uri: string) => boolean;
|
|
283
280
|
uriSet: (_uri: string, item: Promise<{
|
|
284
281
|
context: import("./project").ProjectContext;
|
|
285
|
-
tsConfig:
|
|
282
|
+
tsConfig: string | ts.CompilerOptions;
|
|
286
283
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
287
284
|
getLanguageService: () => {
|
|
288
285
|
getTriggerCharacters: () => string[];
|
|
@@ -410,7 +407,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
410
407
|
pathDelete: (path: string) => boolean;
|
|
411
408
|
pathGet: (path: string) => Promise<{
|
|
412
409
|
context: import("./project").ProjectContext;
|
|
413
|
-
tsConfig:
|
|
410
|
+
tsConfig: string | ts.CompilerOptions;
|
|
414
411
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
415
412
|
getLanguageService: () => {
|
|
416
413
|
getTriggerCharacters: () => string[];
|
|
@@ -537,7 +534,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
537
534
|
}> | undefined;
|
|
538
535
|
pathHas: (path: string) => Promise<{
|
|
539
536
|
context: import("./project").ProjectContext;
|
|
540
|
-
tsConfig:
|
|
537
|
+
tsConfig: string | ts.CompilerOptions;
|
|
541
538
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
542
539
|
getLanguageService: () => {
|
|
543
540
|
getTriggerCharacters: () => string[];
|
|
@@ -664,7 +661,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
664
661
|
}> | undefined;
|
|
665
662
|
pathSet: (path: string, item: Promise<{
|
|
666
663
|
context: import("./project").ProjectContext;
|
|
667
|
-
tsConfig:
|
|
664
|
+
tsConfig: string | ts.CompilerOptions;
|
|
668
665
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
669
666
|
getLanguageService: () => {
|
|
670
667
|
getTriggerCharacters: () => string[];
|
|
@@ -794,7 +791,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
794
791
|
clear: () => void;
|
|
795
792
|
values: () => IterableIterator<Promise<{
|
|
796
793
|
context: import("./project").ProjectContext;
|
|
797
|
-
tsConfig:
|
|
794
|
+
tsConfig: string | ts.CompilerOptions;
|
|
798
795
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
799
796
|
getLanguageService: () => {
|
|
800
797
|
getTriggerCharacters: () => string[];
|
|
@@ -923,7 +920,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
923
920
|
uriDelete: (_uri: string) => boolean;
|
|
924
921
|
uriGet: (_uri: string) => Promise<{
|
|
925
922
|
context: import("./project").ProjectContext;
|
|
926
|
-
tsConfig:
|
|
923
|
+
tsConfig: string | ts.CompilerOptions;
|
|
927
924
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
928
925
|
getLanguageService: () => {
|
|
929
926
|
getTriggerCharacters: () => string[];
|
|
@@ -1051,7 +1048,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
1051
1048
|
uriHas: (_uri: string) => boolean;
|
|
1052
1049
|
uriSet: (_uri: string, item: Promise<{
|
|
1053
1050
|
context: import("./project").ProjectContext;
|
|
1054
|
-
tsConfig:
|
|
1051
|
+
tsConfig: string | ts.CompilerOptions;
|
|
1055
1052
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
1056
1053
|
getLanguageService: () => {
|
|
1057
1054
|
getTriggerCharacters: () => string[];
|
|
@@ -1179,7 +1176,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
1179
1176
|
pathDelete: (path: string) => boolean;
|
|
1180
1177
|
pathGet: (path: string) => Promise<{
|
|
1181
1178
|
context: import("./project").ProjectContext;
|
|
1182
|
-
tsConfig:
|
|
1179
|
+
tsConfig: string | ts.CompilerOptions;
|
|
1183
1180
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
1184
1181
|
getLanguageService: () => {
|
|
1185
1182
|
getTriggerCharacters: () => string[];
|
|
@@ -1306,7 +1303,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
1306
1303
|
}> | undefined;
|
|
1307
1304
|
pathHas: (path: string) => Promise<{
|
|
1308
1305
|
context: import("./project").ProjectContext;
|
|
1309
|
-
tsConfig:
|
|
1306
|
+
tsConfig: string | ts.CompilerOptions;
|
|
1310
1307
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
1311
1308
|
getLanguageService: () => {
|
|
1312
1309
|
getTriggerCharacters: () => string[];
|
|
@@ -1433,7 +1430,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
1433
1430
|
}> | undefined;
|
|
1434
1431
|
pathSet: (path: string, item: Promise<{
|
|
1435
1432
|
context: import("./project").ProjectContext;
|
|
1436
|
-
tsConfig:
|
|
1433
|
+
tsConfig: string | ts.CompilerOptions;
|
|
1437
1434
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
1438
1435
|
getLanguageService: () => {
|
|
1439
1436
|
getTriggerCharacters: () => string[];
|
|
@@ -1563,7 +1560,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
1563
1560
|
tsconfig: string;
|
|
1564
1561
|
project: {
|
|
1565
1562
|
context: import("./project").ProjectContext;
|
|
1566
|
-
tsConfig:
|
|
1563
|
+
tsConfig: string | ts.CompilerOptions;
|
|
1567
1564
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
1568
1565
|
getLanguageService: () => {
|
|
1569
1566
|
getTriggerCharacters: () => string[];
|
|
@@ -1692,7 +1689,7 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
1692
1689
|
tsconfig: undefined;
|
|
1693
1690
|
project: {
|
|
1694
1691
|
context: import("./project").ProjectContext;
|
|
1695
|
-
tsConfig:
|
|
1692
|
+
tsConfig: string | ts.CompilerOptions;
|
|
1696
1693
|
languageHost: import("@volar/language-service").TypeScriptLanguageHost;
|
|
1697
1694
|
getLanguageService: () => {
|
|
1698
1695
|
getTriggerCharacters: () => string[];
|
|
@@ -1823,5 +1820,5 @@ export declare function createWorkspaces(context: WorkspacesContext, rootUris: U
|
|
|
1823
1820
|
remove: (rootUri: URI) => void;
|
|
1824
1821
|
};
|
|
1825
1822
|
export declare function sleep(ms: number): Promise<unknown>;
|
|
1826
|
-
export declare function sortTsConfigs(file:
|
|
1823
|
+
export declare function sortTsConfigs(file: string, a: string, b: string): number;
|
|
1827
1824
|
//# sourceMappingURL=workspaces.d.ts.map
|
package/out/common/workspaces.js
CHANGED
|
@@ -5,7 +5,7 @@ const vscode = require("vscode-languageserver");
|
|
|
5
5
|
const vscode_uri_1 = require("vscode-uri");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
7
|
const isFileInDir_1 = require("./utils/isFileInDir");
|
|
8
|
-
const path = require("
|
|
8
|
+
const path = require("path-browserify");
|
|
9
9
|
const project_1 = require("./project");
|
|
10
10
|
const inferredCompilerOptions_1 = require("./utils/inferredCompilerOptions");
|
|
11
11
|
const uriMap_1 = require("./utils/uriMap");
|
|
@@ -109,7 +109,7 @@ function createWorkspaces(context, rootUris) {
|
|
|
109
109
|
return;
|
|
110
110
|
const req = ++documentUpdatedReq;
|
|
111
111
|
const delay = 250;
|
|
112
|
-
const cancel = context.
|
|
112
|
+
const cancel = context.server.runtimeEnv.getCancellationToken({
|
|
113
113
|
get isCancellationRequested() {
|
|
114
114
|
return req !== documentUpdatedReq;
|
|
115
115
|
},
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGetCancellationToken = void 0;
|
|
4
|
+
const vscode = require("vscode-languageserver");
|
|
5
|
+
function createGetCancellationToken(_cancellationPipeName) {
|
|
6
|
+
if (_cancellationPipeName === undefined) {
|
|
7
|
+
return (original) => {
|
|
8
|
+
return original ?? vscode.CancellationToken.None;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const cancellationPipeName = _cancellationPipeName;
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
return getCancellationToken;
|
|
14
|
+
function getCancellationToken(original) {
|
|
15
|
+
const mtime = getMtime();
|
|
16
|
+
let currentMtime = mtime;
|
|
17
|
+
let updateAt = Date.now();
|
|
18
|
+
const token = {
|
|
19
|
+
get isCancellationRequested() {
|
|
20
|
+
if (original?.isCancellationRequested) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
// debounce 20ms
|
|
24
|
+
if (currentMtime === mtime && Date.now() - updateAt >= 20) {
|
|
25
|
+
currentMtime = getMtime();
|
|
26
|
+
updateAt = Date.now();
|
|
27
|
+
}
|
|
28
|
+
return currentMtime !== mtime;
|
|
29
|
+
},
|
|
30
|
+
onCancellationRequested: vscode.Event.None,
|
|
31
|
+
};
|
|
32
|
+
return token;
|
|
33
|
+
}
|
|
34
|
+
function getMtime() {
|
|
35
|
+
try {
|
|
36
|
+
const stat = fs.statSync(cancellationPipeName, { throwIfNoEntry: false });
|
|
37
|
+
return stat?.mtime.valueOf() ?? -1;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.createGetCancellationToken = createGetCancellationToken;
|
|
45
|
+
//# sourceMappingURL=cancellationPipe.js.map
|
package/out/node/index.js
CHANGED
|
@@ -21,6 +21,7 @@ const vscode_uri_1 = require("vscode-uri");
|
|
|
21
21
|
const http_1 = require("../common/schemaRequestHandlers/http");
|
|
22
22
|
const server_1 = require("../common/server");
|
|
23
23
|
const language_service_1 = require("@volar/language-service");
|
|
24
|
+
const cancellationPipe_1 = require("./cancellationPipe");
|
|
24
25
|
__exportStar(require("../index"), exports);
|
|
25
26
|
const uriToFileName = (uri) => vscode_uri_1.URI.parse(uri).fsPath.replace(/\\/g, '/');
|
|
26
27
|
exports.uriToFileName = uriToFileName;
|
|
@@ -141,6 +142,7 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
141
142
|
catch { }
|
|
142
143
|
},
|
|
143
144
|
fs: createFs(options),
|
|
145
|
+
getCancellationToken: (0, cancellationPipe_1.createGetCancellationToken)(options.cancellationPipeName),
|
|
144
146
|
}));
|
|
145
147
|
}
|
|
146
148
|
exports.startLanguageServer = startLanguageServer;
|
package/out/types.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface RuntimeEnvironment {
|
|
|
12
12
|
fileNameToUri(fileName: string): string;
|
|
13
13
|
loadTypeScript(options: InitializationOptions): Promise<typeof import('typescript/lib/tsserverlibrary') | undefined>;
|
|
14
14
|
loadTypeScriptLocalized(options: InitializationOptions, locale: string): Promise<{} | undefined>;
|
|
15
|
+
getCancellationToken(original?: vscode.CancellationToken): vscode.CancellationToken;
|
|
15
16
|
fs: FileSystem;
|
|
16
17
|
timer: Timer;
|
|
17
18
|
console: Console;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.10-alpha.0",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -15,19 +15,20 @@
|
|
|
15
15
|
"directory": "packages/language-server"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@volar/language-core": "1.10.
|
|
19
|
-
"@volar/language-service": "1.10.
|
|
20
|
-
"@volar/typescript": "1.10.
|
|
18
|
+
"@volar/language-core": "1.10.10-alpha.0",
|
|
19
|
+
"@volar/language-service": "1.10.10-alpha.0",
|
|
20
|
+
"@volar/typescript": "1.10.10-alpha.0",
|
|
21
21
|
"@vscode/l10n": "^0.0.16",
|
|
22
|
+
"path-browserify": "^1.0.1",
|
|
22
23
|
"request-light": "^0.7.0",
|
|
23
|
-
"typesafe-path": "^0.2.2",
|
|
24
24
|
"vscode-languageserver": "^9.0.1",
|
|
25
25
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
26
26
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
27
27
|
"vscode-uri": "^3.0.8"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@
|
|
30
|
+
"@types/path-browserify": "latest",
|
|
31
|
+
"@volar/source-map": "1.10.10-alpha.0"
|
|
31
32
|
},
|
|
32
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "82c2a3fbd190fad9b9d8293b34587b5d17bed545"
|
|
33
34
|
}
|