@volar/language-server 1.7.7 → 1.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/common/cancellationPipe.d.ts +1 -2
- package/out/common/cancellationPipe.js +10 -7
- package/out/common/project.js +12 -12
- package/out/common/server.js +11 -13
- package/out/node/fs.d.ts +0 -0
- package/out/node/fs.js +1 -0
- package/out/node/index.d.ts +5 -1
- package/out/node/index.js +72 -66
- package/package.json +6 -6
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver';
|
|
2
2
|
export type CancellationTokenHost = ReturnType<typeof createCancellationTokenHost>;
|
|
3
3
|
export declare function createCancellationTokenHost(_cancellationPipeName: string | undefined): {
|
|
4
|
-
createCancellationToken(original
|
|
5
|
-
getMtime(): number;
|
|
4
|
+
createCancellationToken(original?: vscode.CancellationToken): vscode.CancellationToken;
|
|
6
5
|
};
|
|
@@ -6,27 +6,30 @@ function createCancellationTokenHost(_cancellationPipeName) {
|
|
|
6
6
|
if (_cancellationPipeName === undefined) {
|
|
7
7
|
return {
|
|
8
8
|
createCancellationToken(original) {
|
|
9
|
-
return original;
|
|
9
|
+
return original ?? vscode.CancellationToken.None;
|
|
10
10
|
},
|
|
11
|
-
getMtime() {
|
|
12
|
-
return -1;
|
|
13
|
-
}
|
|
14
11
|
};
|
|
15
12
|
}
|
|
16
13
|
const cancellationPipeName = _cancellationPipeName;
|
|
17
14
|
const fs = require('fs');
|
|
18
15
|
return {
|
|
19
16
|
createCancellationToken,
|
|
20
|
-
getMtime,
|
|
21
17
|
};
|
|
22
18
|
function createCancellationToken(original) {
|
|
23
19
|
const mtime = getMtime();
|
|
20
|
+
let currentMtime = mtime;
|
|
21
|
+
let updateAt = Date.now();
|
|
24
22
|
const token = {
|
|
25
23
|
get isCancellationRequested() {
|
|
26
|
-
if (original
|
|
24
|
+
if (original?.isCancellationRequested) {
|
|
27
25
|
return true;
|
|
28
26
|
}
|
|
29
|
-
|
|
27
|
+
// debounce 20ms
|
|
28
|
+
if (currentMtime === mtime && Date.now() - updateAt >= 20) {
|
|
29
|
+
currentMtime = getMtime();
|
|
30
|
+
updateAt = Date.now();
|
|
31
|
+
}
|
|
32
|
+
return currentMtime !== mtime;
|
|
30
33
|
},
|
|
31
34
|
onCancellationRequested: vscode.Event.None,
|
|
32
35
|
};
|
package/out/common/project.js
CHANGED
|
@@ -9,8 +9,14 @@ const uriMap_1 = require("./utils/uriMap");
|
|
|
9
9
|
const typescript_1 = require("@volar/typescript");
|
|
10
10
|
async function createProject(context) {
|
|
11
11
|
let projectVersion = 0;
|
|
12
|
-
let
|
|
12
|
+
let token = context.workspaces.cancelTokenHost.createCancellationToken();
|
|
13
13
|
let languageService;
|
|
14
|
+
const tsToken = {
|
|
15
|
+
isCancellationRequested() {
|
|
16
|
+
return token.isCancellationRequested;
|
|
17
|
+
},
|
|
18
|
+
throwIfCancellationRequested() { },
|
|
19
|
+
};
|
|
14
20
|
const { uriToFileName, fileNameToUri, fs } = context.server.runtimeEnv;
|
|
15
21
|
const env = {
|
|
16
22
|
uriToFileName,
|
|
@@ -25,12 +31,6 @@ async function createProject(context) {
|
|
|
25
31
|
};
|
|
26
32
|
const fsScriptsCache = (0, uriMap_1.createUriMap)(fileNameToUri);
|
|
27
33
|
const askedFiles = (0, uriMap_1.createUriMap)(fileNameToUri);
|
|
28
|
-
const token = {
|
|
29
|
-
isCancellationRequested() {
|
|
30
|
-
return context.workspaces.cancelTokenHost.getMtime() !== projectVersionUpdateTime;
|
|
31
|
-
},
|
|
32
|
-
throwIfCancellationRequested() { },
|
|
33
|
-
};
|
|
34
34
|
const languageHost = {
|
|
35
35
|
getProjectVersion: () => projectVersion,
|
|
36
36
|
getScriptFileNames: () => parsedCommandLine.fileNames,
|
|
@@ -46,7 +46,7 @@ async function createProject(context) {
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
getLanguageId: (fileName) => context.workspaces.documents.data.pathGet(fileName)?.languageId,
|
|
49
|
-
getCancellationToken: () =>
|
|
49
|
+
getCancellationToken: () => tsToken,
|
|
50
50
|
getCompilationSettings: () => parsedCommandLine.options,
|
|
51
51
|
getLocalizedDiagnosticMessages: context.workspaces.tsLocalized ? () => context.workspaces.tsLocalized : undefined,
|
|
52
52
|
getCurrentDirectory: () => uriToFileName(context.project.rootUri.toString()),
|
|
@@ -54,7 +54,7 @@ async function createProject(context) {
|
|
|
54
54
|
};
|
|
55
55
|
const docChangeWatcher = context.workspaces.documents.onDidChangeContent(() => {
|
|
56
56
|
projectVersion++;
|
|
57
|
-
|
|
57
|
+
token = context.workspaces.cancelTokenHost.createCancellationToken();
|
|
58
58
|
});
|
|
59
59
|
const fileWatch = env.onDidChangeWatchedFiles?.(params => {
|
|
60
60
|
onWorkspaceFilesChanged(params.changes);
|
|
@@ -89,7 +89,7 @@ async function createProject(context) {
|
|
|
89
89
|
if (!parsedCommandLine.fileNames.includes(fileName)) {
|
|
90
90
|
parsedCommandLine.fileNames.push(fileName);
|
|
91
91
|
projectVersion++;
|
|
92
|
-
|
|
92
|
+
token = context.workspaces.cancelTokenHost.createCancellationToken();
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
askedFiles,
|
|
@@ -106,7 +106,7 @@ async function createProject(context) {
|
|
|
106
106
|
let dirty = false;
|
|
107
107
|
for (const fileName of parsedCommandLine.fileNames) {
|
|
108
108
|
const uri = fileNameToUri(fileName);
|
|
109
|
-
if (!fsScriptsCache.
|
|
109
|
+
if (!fsScriptsCache.uriGet(uri)) {
|
|
110
110
|
dirty = true;
|
|
111
111
|
promises.push(updateRootScriptSnapshot(uri));
|
|
112
112
|
}
|
|
@@ -144,7 +144,7 @@ async function createProject(context) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
if (oldProjectVersion !== projectVersion) {
|
|
147
|
-
|
|
147
|
+
token = context.workspaces.cancelTokenHost.createCancellationToken();
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
function dispose() {
|
package/out/common/server.js
CHANGED
|
@@ -74,24 +74,22 @@ async function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
|
|
|
74
74
|
},
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
|
-
let
|
|
77
|
+
let config = {};
|
|
78
78
|
for (const root of roots) {
|
|
79
79
|
if (root.scheme === 'file') {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (config.services) {
|
|
87
|
-
services = {
|
|
88
|
-
...services,
|
|
89
|
-
...config.services,
|
|
90
|
-
};
|
|
80
|
+
const workspaceConfig = (0, serverConfig_1.loadConfig)(root.path, options.configFilePath);
|
|
81
|
+
if (workspaceConfig) {
|
|
82
|
+
config = workspaceConfig;
|
|
83
|
+
break;
|
|
91
84
|
}
|
|
92
85
|
}
|
|
93
86
|
}
|
|
94
|
-
|
|
87
|
+
for (const plugin of plugins) {
|
|
88
|
+
if (plugin.resolveConfig) {
|
|
89
|
+
config = await plugin.resolveConfig(config, undefined);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
(0, registerFeatures_1.setupCapabilities)(result.capabilities, options, plugins, getSemanticTokensLegend(), config.services ?? {});
|
|
95
93
|
await createLanguageServiceHost();
|
|
96
94
|
try {
|
|
97
95
|
// show version on LSP logs
|
package/out/node/fs.d.ts
ADDED
|
File without changes
|
package/out/node/fs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=fs.js.map
|
package/out/node/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver/node';
|
|
2
|
-
import { LanguageServerPlugin } from '../types';
|
|
2
|
+
import { InitializationOptions, LanguageServerPlugin } from '../types';
|
|
3
|
+
import { FileSystem } from '@volar/language-service';
|
|
3
4
|
export * from '../index';
|
|
5
|
+
export declare const uriToFileName: (uri: string) => string;
|
|
6
|
+
export declare const fileNameToUri: (fileName: string) => string;
|
|
7
|
+
export declare function createFs(options: InitializationOptions): FileSystem;
|
|
4
8
|
export declare function createConnection(): vscode._Connection<vscode._, vscode._, vscode._, vscode._, vscode._, vscode._, vscode._, vscode._>;
|
|
5
9
|
export declare function startLanguageServer(connection: vscode.Connection, ...plugins: LanguageServerPlugin[]): void;
|
package/out/node/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.startLanguageServer = exports.createConnection = void 0;
|
|
17
|
+
exports.startLanguageServer = exports.createConnection = exports.createFs = exports.fileNameToUri = exports.uriToFileName = void 0;
|
|
18
18
|
const fs = require("fs");
|
|
19
19
|
const vscode = require("vscode-languageserver/node");
|
|
20
20
|
const vscode_uri_1 = require("vscode-uri");
|
|
@@ -22,16 +22,82 @@ 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
24
|
__exportStar(require("../index"), exports);
|
|
25
|
+
const uriToFileName = (uri) => vscode_uri_1.URI.parse(uri).fsPath.replace(/\\/g, '/');
|
|
26
|
+
exports.uriToFileName = uriToFileName;
|
|
27
|
+
const fileNameToUri = (fileName) => vscode_uri_1.URI.file(fileName).toString();
|
|
28
|
+
exports.fileNameToUri = fileNameToUri;
|
|
29
|
+
function createFs(options) {
|
|
30
|
+
return {
|
|
31
|
+
stat(uri) {
|
|
32
|
+
if (uri.startsWith('file://')) {
|
|
33
|
+
try {
|
|
34
|
+
const stats = fs.statSync((0, exports.uriToFileName)(uri), { throwIfNoEntry: false });
|
|
35
|
+
if (stats) {
|
|
36
|
+
return {
|
|
37
|
+
type: stats.isFile() ? language_service_1.FileType.File
|
|
38
|
+
: stats.isDirectory() ? language_service_1.FileType.Directory
|
|
39
|
+
: stats.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
|
|
40
|
+
: language_service_1.FileType.Unknown,
|
|
41
|
+
ctime: stats.ctimeMs,
|
|
42
|
+
mtime: stats.mtimeMs,
|
|
43
|
+
size: stats.size,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
readFile(uri, encoding) {
|
|
53
|
+
if (uri.startsWith('file://')) {
|
|
54
|
+
try {
|
|
55
|
+
if (options.maxFileSize) {
|
|
56
|
+
const stats = fs.statSync((0, exports.uriToFileName)(uri), { throwIfNoEntry: false });
|
|
57
|
+
if (stats && stats.size > options.maxFileSize) {
|
|
58
|
+
console.warn(`[volar] file size exceeded limit: ${uri} (${stats.size} > ${options.maxFileSize})`);
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return fs.readFileSync((0, exports.uriToFileName)(uri), { encoding: encoding ?? 'utf-8' });
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (uri.startsWith('http://') || uri.startsWith('https://')) {
|
|
69
|
+
return (0, http_1.default)(uri);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
readDirectory(uri) {
|
|
73
|
+
if (uri.startsWith('file://')) {
|
|
74
|
+
try {
|
|
75
|
+
const dirName = (0, exports.uriToFileName)(uri);
|
|
76
|
+
const files = fs.readdirSync(dirName, { withFileTypes: true });
|
|
77
|
+
return files.map(file => {
|
|
78
|
+
return [file.name, file.isFile() ? language_service_1.FileType.File
|
|
79
|
+
: file.isDirectory() ? language_service_1.FileType.Directory
|
|
80
|
+
: file.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
|
|
81
|
+
: language_service_1.FileType.Unknown];
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return [];
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
exports.createFs = createFs;
|
|
25
93
|
function createConnection() {
|
|
26
94
|
return vscode.createConnection(vscode.ProposedFeatures.all);
|
|
27
95
|
}
|
|
28
96
|
exports.createConnection = createConnection;
|
|
29
97
|
function startLanguageServer(connection, ...plugins) {
|
|
30
|
-
const uriToFileName = (uri) => vscode_uri_1.URI.parse(uri).fsPath.replace(/\\/g, '/');
|
|
31
|
-
const fileNameToUri = (fileName) => vscode_uri_1.URI.file(fileName).toString();
|
|
32
98
|
(0, server_1.startCommonLanguageServer)(connection, plugins, (_, options) => ({
|
|
33
|
-
uriToFileName,
|
|
34
|
-
fileNameToUri,
|
|
99
|
+
uriToFileName: exports.uriToFileName,
|
|
100
|
+
fileNameToUri: exports.fileNameToUri,
|
|
35
101
|
timer: {
|
|
36
102
|
setImmediate(callback, ...args) {
|
|
37
103
|
const handle = setImmediate(callback, ...args);
|
|
@@ -61,67 +127,7 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
61
127
|
}
|
|
62
128
|
catch { }
|
|
63
129
|
},
|
|
64
|
-
fs:
|
|
65
|
-
stat(uri) {
|
|
66
|
-
if (uri.startsWith('file://')) {
|
|
67
|
-
try {
|
|
68
|
-
const stats = fs.statSync(uriToFileName(uri), { throwIfNoEntry: false });
|
|
69
|
-
if (stats) {
|
|
70
|
-
return {
|
|
71
|
-
type: stats.isFile() ? language_service_1.FileType.File
|
|
72
|
-
: stats.isDirectory() ? language_service_1.FileType.Directory
|
|
73
|
-
: stats.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
|
|
74
|
-
: language_service_1.FileType.Unknown,
|
|
75
|
-
ctime: stats.ctimeMs,
|
|
76
|
-
mtime: stats.mtimeMs,
|
|
77
|
-
size: stats.size,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
readFile(uri, encoding) {
|
|
87
|
-
if (uri.startsWith('file://')) {
|
|
88
|
-
try {
|
|
89
|
-
if (options.maxFileSize) {
|
|
90
|
-
const stats = fs.statSync(uriToFileName(uri), { throwIfNoEntry: false });
|
|
91
|
-
if (stats && stats.size > options.maxFileSize) {
|
|
92
|
-
console.warn(`[volar] file size exceeded limit: ${uri} (${stats.size} > ${options.maxFileSize})`);
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return fs.readFileSync(uriToFileName(uri), { encoding: encoding ?? 'utf-8' });
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (uri.startsWith('http://') || uri.startsWith('https://')) {
|
|
103
|
-
return (0, http_1.default)(uri);
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
readDirectory(uri) {
|
|
107
|
-
if (uri.startsWith('file://')) {
|
|
108
|
-
try {
|
|
109
|
-
const dirName = uriToFileName(uri);
|
|
110
|
-
const files = fs.readdirSync(dirName, { withFileTypes: true });
|
|
111
|
-
return files.map(file => {
|
|
112
|
-
return [file.name, file.isFile() ? language_service_1.FileType.File
|
|
113
|
-
: file.isDirectory() ? language_service_1.FileType.Directory
|
|
114
|
-
: file.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
|
|
115
|
-
: language_service_1.FileType.Unknown];
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
catch {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return [];
|
|
123
|
-
},
|
|
124
|
-
},
|
|
130
|
+
fs: createFs(options),
|
|
125
131
|
}));
|
|
126
132
|
}
|
|
127
133
|
exports.startLanguageServer = startLanguageServer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"directory": "packages/language-server"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@volar/language-core": "1.7.
|
|
19
|
-
"@volar/language-service": "1.7.
|
|
20
|
-
"@volar/typescript": "1.7.
|
|
18
|
+
"@volar/language-core": "1.7.9",
|
|
19
|
+
"@volar/language-service": "1.7.9",
|
|
20
|
+
"@volar/typescript": "1.7.9",
|
|
21
21
|
"@vscode/l10n": "^0.0.11",
|
|
22
22
|
"request-light": "^0.7.0",
|
|
23
23
|
"typesafe-path": "^0.2.2",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"vscode-uri": "^3.0.7"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@volar/source-map": "1.7.
|
|
30
|
+
"@volar/source-map": "1.7.9"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "c28b1b3fc725f38d335f4341179678c78828528f"
|
|
33
33
|
}
|