@volar/language-server 1.4.0-alpha.0 → 1.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/browser/fileSystems.js +82 -102
- package/out/browser/index.js +10 -23
- package/out/browser/typescript/core.js +1 -1
- package/out/browser/typescript/corePublic.js +2 -2
- package/out/common/cancellationPipe.js +1 -1
- package/out/common/configurationHost.js +12 -28
- package/out/common/documents.js +2 -3
- package/out/common/features/customFeatures.js +34 -47
- package/out/common/features/languageFeatures.js +127 -152
- package/out/common/project.d.ts +62 -62
- package/out/common/project.js +211 -227
- package/out/common/server.js +51 -65
- package/out/common/utils/inferredCompilerOptions.js +57 -61
- package/out/common/utils/registerFeatures.js +8 -8
- package/out/common/utils/serverConfig.js +2 -2
- package/out/common/utils/uriMap.js +1 -1
- package/out/common/workspace.d.ts +558 -558
- package/out/common/workspace.js +164 -193
- package/out/common/workspaces.d.ts +682 -682
- package/out/common/workspaces.js +81 -107
- package/out/node/fileSystem.js +4 -14
- package/out/node/index.js +7 -18
- package/package.json +4 -4
package/out/common/workspaces.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.sleep = exports.createWorkspaces = void 0;
|
|
12
3
|
const vscode = require("vscode-languageserver");
|
|
@@ -14,7 +5,6 @@ const types_1 = require("../types");
|
|
|
14
5
|
const workspace_1 = require("./workspace");
|
|
15
6
|
const isFileInDir_1 = require("./utils/isFileInDir");
|
|
16
7
|
function createWorkspaces(context) {
|
|
17
|
-
var _a, _b, _c;
|
|
18
8
|
const uriToFileName = context.server.runtimeEnv.uriToFileName;
|
|
19
9
|
const workspaces = new Map();
|
|
20
10
|
let semanticTokensReq = 0;
|
|
@@ -25,7 +15,7 @@ function createWorkspaces(context) {
|
|
|
25
15
|
context.documents.onDidClose(({ textDocument }) => {
|
|
26
16
|
context.server.connection.sendDiagnostics({ uri: textDocument.uri, diagnostics: [] });
|
|
27
17
|
});
|
|
28
|
-
|
|
18
|
+
context.fileSystemHost?.onDidChangeWatchedFiles(({ changes }) => {
|
|
29
19
|
const tsConfigChanges = changes.filter(change => workspace_1.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1)));
|
|
30
20
|
if (tsConfigChanges.length) {
|
|
31
21
|
reloadDiagnostics();
|
|
@@ -34,9 +24,9 @@ function createWorkspaces(context) {
|
|
|
34
24
|
updateDiagnosticsAndSemanticTokens();
|
|
35
25
|
}
|
|
36
26
|
});
|
|
37
|
-
|
|
27
|
+
context.server.runtimeEnv.onDidChangeConfiguration?.(async () => {
|
|
38
28
|
updateDiagnosticsAndSemanticTokens();
|
|
39
|
-
})
|
|
29
|
+
});
|
|
40
30
|
return {
|
|
41
31
|
workspaces,
|
|
42
32
|
getProject: getProjectAndTsConfig,
|
|
@@ -52,21 +42,17 @@ function createWorkspaces(context) {
|
|
|
52
42
|
remove: (rootUri) => {
|
|
53
43
|
const _workspace = workspaces.get(rootUri.toString());
|
|
54
44
|
workspaces.delete(rootUri.toString());
|
|
55
|
-
(() =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}))();
|
|
45
|
+
(async () => {
|
|
46
|
+
(await _workspace)?.dispose();
|
|
47
|
+
})();
|
|
59
48
|
},
|
|
60
49
|
};
|
|
61
|
-
function reloadProject() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
reloadDiagnostics();
|
|
69
|
-
});
|
|
50
|
+
async function reloadProject() {
|
|
51
|
+
context.fileSystemHost?.reload();
|
|
52
|
+
for (const [_, workspace] of workspaces) {
|
|
53
|
+
(await workspace).reload();
|
|
54
|
+
}
|
|
55
|
+
reloadDiagnostics();
|
|
70
56
|
}
|
|
71
57
|
function reloadDiagnostics() {
|
|
72
58
|
for (const doc of context.documents.data.values()) {
|
|
@@ -74,97 +60,85 @@ function createWorkspaces(context) {
|
|
|
74
60
|
}
|
|
75
61
|
updateDiagnosticsAndSemanticTokens();
|
|
76
62
|
}
|
|
77
|
-
function updateDiagnosticsAndSemanticTokens() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if ((_c = context.initParams.capabilities.textDocument) === null || _c === void 0 ? void 0 : _c.semanticTokens) {
|
|
86
|
-
context.server.connection.languages.semanticTokens.refresh();
|
|
87
|
-
}
|
|
88
|
-
if ((_d = context.initParams.capabilities.textDocument) === null || _d === void 0 ? void 0 : _d.inlayHint) {
|
|
89
|
-
context.server.connection.languages.inlayHint.refresh();
|
|
90
|
-
}
|
|
63
|
+
async function updateDiagnosticsAndSemanticTokens() {
|
|
64
|
+
const req = ++semanticTokensReq;
|
|
65
|
+
await updateDiagnostics();
|
|
66
|
+
const delay = await context.configurationHost?.getConfiguration('volar.diagnostics.delay') ?? 200;
|
|
67
|
+
await sleep(delay);
|
|
68
|
+
if (req === semanticTokensReq) {
|
|
69
|
+
if (context.initParams.capabilities.textDocument?.semanticTokens) {
|
|
70
|
+
context.server.connection.languages.semanticTokens.refresh();
|
|
91
71
|
}
|
|
92
|
-
|
|
72
|
+
if (context.initParams.capabilities.textDocument?.inlayHint) {
|
|
73
|
+
context.server.connection.languages.inlayHint.refresh();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
93
76
|
}
|
|
94
|
-
function updateDiagnostics(docUri) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
77
|
+
async function updateDiagnostics(docUri) {
|
|
78
|
+
if ((context.initOptions.diagnosticModel ?? types_1.DiagnosticModel.Push) !== types_1.DiagnosticModel.Push)
|
|
79
|
+
return;
|
|
80
|
+
const req = ++documentUpdatedReq;
|
|
81
|
+
const delay = await context.configurationHost?.getConfiguration('volar.diagnostics.delay') ?? 200;
|
|
82
|
+
const cancel = context.cancelTokenHost.createCancellationToken({
|
|
83
|
+
get isCancellationRequested() {
|
|
84
|
+
return req !== documentUpdatedReq;
|
|
85
|
+
},
|
|
86
|
+
onCancellationRequested: vscode.Event.None,
|
|
87
|
+
});
|
|
88
|
+
const changeDoc = docUri ? context.documents.data.uriGet(docUri) : undefined;
|
|
89
|
+
const otherDocs = [...context.documents.data.values()].filter(doc => doc !== changeDoc);
|
|
90
|
+
if (changeDoc) {
|
|
91
|
+
await sleep(delay);
|
|
92
|
+
if (cancel.isCancellationRequested) {
|
|
98
93
|
return;
|
|
99
|
-
const req = ++documentUpdatedReq;
|
|
100
|
-
const delay = (_c = yield ((_b = context.configurationHost) === null || _b === void 0 ? void 0 : _b.getConfiguration('volar.diagnostics.delay'))) !== null && _c !== void 0 ? _c : 200;
|
|
101
|
-
const cancel = context.cancelTokenHost.createCancellationToken({
|
|
102
|
-
get isCancellationRequested() {
|
|
103
|
-
return req !== documentUpdatedReq;
|
|
104
|
-
},
|
|
105
|
-
onCancellationRequested: vscode.Event.None,
|
|
106
|
-
});
|
|
107
|
-
const changeDoc = docUri ? context.documents.data.uriGet(docUri) : undefined;
|
|
108
|
-
const otherDocs = [...context.documents.data.values()].filter(doc => doc !== changeDoc);
|
|
109
|
-
if (changeDoc) {
|
|
110
|
-
yield sleep(delay);
|
|
111
|
-
if (cancel.isCancellationRequested) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
yield sendDocumentDiagnostics(changeDoc.uri, changeDoc.version, cancel);
|
|
115
94
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
95
|
+
await sendDocumentDiagnostics(changeDoc.uri, changeDoc.version, cancel);
|
|
96
|
+
}
|
|
97
|
+
for (const doc of otherDocs) {
|
|
98
|
+
await sleep(delay);
|
|
99
|
+
if (cancel.isCancellationRequested) {
|
|
100
|
+
break;
|
|
122
101
|
}
|
|
123
|
-
|
|
102
|
+
await sendDocumentDiagnostics(doc.uri, doc.version, cancel);
|
|
103
|
+
}
|
|
124
104
|
}
|
|
125
|
-
function sendDocumentDiagnostics(uri, version, cancel) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const errors = yield languageService.doValidation(uri, cancel, mode, result => {
|
|
136
|
-
context.server.connection.sendDiagnostics({ uri: uri, diagnostics: result, version });
|
|
137
|
-
});
|
|
138
|
-
context.server.connection.sendDiagnostics({ uri: uri, diagnostics: errors, version });
|
|
105
|
+
async function sendDocumentDiagnostics(uri, version, cancel) {
|
|
106
|
+
const project = (await getProjectAndTsConfig(uri))?.project;
|
|
107
|
+
if (!project)
|
|
108
|
+
return;
|
|
109
|
+
const languageService = project.getLanguageService();
|
|
110
|
+
const mode = context.initOptions.serverMode === types_1.ServerMode.PartialSemantic ? 'semantic'
|
|
111
|
+
: context.initOptions.serverMode === types_1.ServerMode.Syntactic ? 'syntactic'
|
|
112
|
+
: 'all';
|
|
113
|
+
const errors = await languageService.doValidation(uri, mode, cancel, result => {
|
|
114
|
+
context.server.connection.sendDiagnostics({ uri: uri, diagnostics: result, version });
|
|
139
115
|
});
|
|
116
|
+
context.server.connection.sendDiagnostics({ uri: uri, diagnostics: errors, version });
|
|
140
117
|
}
|
|
141
|
-
function getProjectAndTsConfig(uri) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (projectAndTsConfig) {
|
|
152
|
-
return projectAndTsConfig;
|
|
153
|
-
}
|
|
118
|
+
async function getProjectAndTsConfig(uri) {
|
|
119
|
+
let rootUris = [...workspaces.keys()]
|
|
120
|
+
.filter(rootUri => (0, isFileInDir_1.isFileInDir)(uriToFileName(uri), uriToFileName(rootUri)))
|
|
121
|
+
.sort((a, b) => (0, workspace_1.sortTsConfigs)(uriToFileName(uri), uriToFileName(a), uriToFileName(b)));
|
|
122
|
+
if (context.initOptions.serverMode !== types_1.ServerMode.Syntactic) {
|
|
123
|
+
for (const rootUri of rootUris) {
|
|
124
|
+
const workspace = await workspaces.get(rootUri);
|
|
125
|
+
const projectAndTsConfig = await workspace?.getProjectAndTsConfig(uri);
|
|
126
|
+
if (projectAndTsConfig) {
|
|
127
|
+
return projectAndTsConfig;
|
|
154
128
|
}
|
|
155
129
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
}
|
|
130
|
+
}
|
|
131
|
+
if (!rootUris.length) {
|
|
132
|
+
rootUris = [...workspaces.keys()];
|
|
133
|
+
}
|
|
134
|
+
if (rootUris.length) {
|
|
135
|
+
const project = await (await workspaces.get(rootUris[0]))?.getInferredProject();
|
|
136
|
+
project?.tryAddFile(uriToFileName(uri));
|
|
137
|
+
return {
|
|
138
|
+
tsconfig: undefined,
|
|
139
|
+
project,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
168
142
|
}
|
|
169
143
|
}
|
|
170
144
|
exports.createWorkspaces = createWorkspaces;
|
package/out/node/fileSystem.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.createNodeFileSystemHost = void 0;
|
|
12
3
|
const vscode = require("vscode-languageserver");
|
|
@@ -17,7 +8,7 @@ function createNodeFileSystemHost(ts, capabilities, env, _initOptions) {
|
|
|
17
8
|
const onDidChangeWatchedFilesCb = new Set();
|
|
18
9
|
return {
|
|
19
10
|
ready(connection) {
|
|
20
|
-
connection.onDidChangeWatchedFiles((params) =>
|
|
11
|
+
connection.onDidChangeWatchedFiles(async (params) => {
|
|
21
12
|
if (params.changes.some(change => change.type === vscode.FileChangeType.Created || change.type === vscode.FileChangeType.Deleted)) {
|
|
22
13
|
for (const sys of instances.values()) {
|
|
23
14
|
sys[1].forEach(cache => cache.clear());
|
|
@@ -25,10 +16,10 @@ function createNodeFileSystemHost(ts, capabilities, env, _initOptions) {
|
|
|
25
16
|
}
|
|
26
17
|
for (const cb of [...onDidChangeWatchedFilesCb]) {
|
|
27
18
|
if (onDidChangeWatchedFilesCb.has(cb)) {
|
|
28
|
-
|
|
19
|
+
await cb(params);
|
|
29
20
|
}
|
|
30
21
|
}
|
|
31
|
-
})
|
|
22
|
+
});
|
|
32
23
|
},
|
|
33
24
|
reload() {
|
|
34
25
|
for (const sys of instances.values()) {
|
|
@@ -49,7 +40,6 @@ function createNodeFileSystemHost(ts, capabilities, env, _initOptions) {
|
|
|
49
40
|
},
|
|
50
41
|
};
|
|
51
42
|
function createWorkspaceFileSystem(ts, capabilities, rootUri) {
|
|
52
|
-
var _a;
|
|
53
43
|
const rootPath = env.uriToFileName(rootUri.toString());
|
|
54
44
|
const workspaceSys = new Proxy(ts.sys, {
|
|
55
45
|
get(target, prop) {
|
|
@@ -73,7 +63,7 @@ function createNodeFileSystemHost(ts, capabilities, env, _initOptions) {
|
|
|
73
63
|
const fileExistsCache = new Map();
|
|
74
64
|
const directoryExistsCache = new Map();
|
|
75
65
|
// don't cache fs result if client did not supports file watcher
|
|
76
|
-
const sys =
|
|
66
|
+
const sys = capabilities.workspace?.didChangeWatchedFiles
|
|
77
67
|
? new Proxy({
|
|
78
68
|
fileExists(path) {
|
|
79
69
|
if (!fileExistsCache.has(path)) {
|
package/out/node/index.js
CHANGED
|
@@ -12,15 +12,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
12
12
|
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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
16
|
exports.startLanguageServer = exports.createConnection = void 0;
|
|
26
17
|
const fs = require("fs");
|
|
@@ -59,17 +50,15 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
59
50
|
const path = require.resolve(name, { paths: [tsdk] });
|
|
60
51
|
return require(path);
|
|
61
52
|
}
|
|
62
|
-
catch
|
|
53
|
+
catch { }
|
|
63
54
|
}
|
|
64
55
|
},
|
|
65
|
-
loadTypescriptLocalized(tsdk, locale) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
catch (_a) { }
|
|
72
|
-
});
|
|
56
|
+
async loadTypescriptLocalized(tsdk, locale) {
|
|
57
|
+
try {
|
|
58
|
+
const path = require.resolve(`./${locale}/diagnosticMessages.generated.json`, { paths: [tsdk] });
|
|
59
|
+
return require(path);
|
|
60
|
+
}
|
|
61
|
+
catch { }
|
|
73
62
|
},
|
|
74
63
|
schemaRequestHandlers: {
|
|
75
64
|
file: file_1.default,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.2",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"directory": "packages/language-server"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@volar/language-core": "1.4.0-alpha.
|
|
21
|
-
"@volar/language-service": "1.4.0-alpha.
|
|
20
|
+
"@volar/language-core": "1.4.0-alpha.2",
|
|
21
|
+
"@volar/language-service": "1.4.0-alpha.2",
|
|
22
22
|
"@vscode/l10n": "^0.0.11",
|
|
23
23
|
"request-light": "^0.7.0",
|
|
24
24
|
"typesafe-path": "^0.2.2",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
29
29
|
"vscode-uri": "^3.0.7"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "034b230da17794a6fcf5a0b07668710f98ff84e3"
|
|
32
32
|
}
|