@volar/language-server 1.4.0-alpha.0 → 1.4.0-alpha.1
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 +126 -151
- package/out/common/project.d.ts +2 -2
- 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 +18 -18
- package/out/common/workspace.js +164 -193
- package/out/common/workspaces.d.ts +22 -22
- 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
|
@@ -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.createWebFileSystemHost = void 0;
|
|
12
3
|
const path = require("typesafe-path");
|
|
@@ -98,38 +89,36 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
|
|
|
98
89
|
return path.resolve(fsPath);
|
|
99
90
|
}
|
|
100
91
|
function fileExists(fsPath) {
|
|
101
|
-
var _a, _b, _c;
|
|
102
92
|
fsPath = resolvePath(fsPath);
|
|
103
93
|
const uri = env.fileNameToUri(fsPath);
|
|
104
94
|
const dirPath = path.dirname(fsPath);
|
|
105
|
-
if (
|
|
95
|
+
if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
|
|
106
96
|
if (!(uri.endsWith('.d.ts') || uri.endsWith('/package.json'))) {
|
|
107
97
|
return false;
|
|
108
98
|
}
|
|
109
99
|
readFile(fsPath);
|
|
110
100
|
const file = getDir(dirPath).files.get(path.basename(fsPath));
|
|
111
|
-
return
|
|
101
|
+
return file?.exists ?? false;
|
|
112
102
|
}
|
|
113
103
|
readDirectory(dirPath);
|
|
114
104
|
const file = getDir(path.dirname(fsPath)).files.get(path.basename(fsPath));
|
|
115
|
-
return
|
|
105
|
+
return file?.exists ?? false;
|
|
116
106
|
}
|
|
117
107
|
function readFile(fsPath) {
|
|
118
|
-
var _a, _b, _c, _d;
|
|
119
108
|
fsPath = resolvePath(fsPath);
|
|
120
109
|
const uri = env.fileNameToUri(fsPath);
|
|
121
110
|
const dirPath = path.dirname(fsPath);
|
|
122
111
|
const dir = getDir(dirPath);
|
|
123
112
|
const name = path.basename(fsPath);
|
|
124
|
-
if (
|
|
113
|
+
if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
|
|
125
114
|
if (!(uri.endsWith('.d.ts') || uri.endsWith('/package.json'))) {
|
|
126
|
-
return
|
|
115
|
+
return dir.files.get(name)?.text || '';
|
|
127
116
|
}
|
|
128
117
|
readFileWorker();
|
|
129
|
-
return
|
|
118
|
+
return dir.files.get(name)?.text || '';
|
|
130
119
|
}
|
|
131
120
|
readFileWorker();
|
|
132
|
-
return
|
|
121
|
+
return dir.files.get(name)?.text || '';
|
|
133
122
|
function readFileWorker() {
|
|
134
123
|
if (connection) {
|
|
135
124
|
fetch('load', fsPath, readFileAsync(connection, fsPath, dir));
|
|
@@ -138,26 +127,24 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
|
|
|
138
127
|
onReadyCb.push((connection) => fetch('load', fsPath, readFileAsync(connection, fsPath, dir)));
|
|
139
128
|
}
|
|
140
129
|
}
|
|
141
|
-
function readFileAsync(connection, fsPath, dir) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
});
|
|
130
|
+
async function readFileAsync(connection, fsPath, dir) {
|
|
131
|
+
const name = path.basename(fsPath);
|
|
132
|
+
if (!dir.files.has(name)) {
|
|
133
|
+
dir.files.set(name, {});
|
|
134
|
+
}
|
|
135
|
+
const file = dir.files.get(name);
|
|
136
|
+
if (file.requested) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
file.requested = true;
|
|
140
|
+
const uri = env.fileNameToUri(fsPath);
|
|
141
|
+
const data = await connection.sendRequest(protocol_1.FsReadFileRequest.type, resolveRequestUrl(uri));
|
|
142
|
+
const text = data ? new TextDecoder('utf8').decode(data) : undefined;
|
|
143
|
+
if (text?.length) {
|
|
144
|
+
file.exists = true;
|
|
145
|
+
file.text = text;
|
|
146
|
+
changes.push({ uri, type: vscode.FileChangeType.Changed });
|
|
147
|
+
}
|
|
161
148
|
}
|
|
162
149
|
}
|
|
163
150
|
function readDirectory(fsPath, extensions, exclude, include, depth) {
|
|
@@ -187,66 +174,61 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
|
|
|
187
174
|
onReadyCb.push((connection) => fetch('directory', fsPath, readDirectoryAsync(connection, fsPath)));
|
|
188
175
|
}
|
|
189
176
|
}
|
|
190
|
-
function readDirectoryAsync(connection, fsPath) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (
|
|
201
|
-
|
|
202
|
-
dir.files.set(name, {});
|
|
203
|
-
}
|
|
204
|
-
const file = dir.files.get(name);
|
|
205
|
-
if (!file.exists) {
|
|
206
|
-
file.exists = true;
|
|
207
|
-
changes.push({
|
|
208
|
-
uri: env.fileNameToUri(path.join(fsPath, name)),
|
|
209
|
-
type: vscode.FileChangeType.Created,
|
|
210
|
-
});
|
|
211
|
-
}
|
|
177
|
+
async function readDirectoryAsync(connection, fsPath) {
|
|
178
|
+
const dir = getDir(fsPath);
|
|
179
|
+
if (dir.requested) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
dir.requested = true;
|
|
183
|
+
const uri = env.fileNameToUri(fsPath);
|
|
184
|
+
const result = await connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, resolveRequestUrl(uri));
|
|
185
|
+
for (const [name, fileType] of result) {
|
|
186
|
+
if (fileType === vscode_html_languageservice_1.FileType.File || fileType === vscode_html_languageservice_1.FileType.SymbolicLink) {
|
|
187
|
+
if (!dir.files.has(name)) {
|
|
188
|
+
dir.files.set(name, {});
|
|
212
189
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
190
|
+
const file = dir.files.get(name);
|
|
191
|
+
if (!file.exists) {
|
|
192
|
+
file.exists = true;
|
|
193
|
+
changes.push({
|
|
194
|
+
uri: env.fileNameToUri(path.join(fsPath, name)),
|
|
195
|
+
type: vscode.FileChangeType.Created,
|
|
196
|
+
});
|
|
216
197
|
}
|
|
217
198
|
}
|
|
218
|
-
|
|
199
|
+
else if (fileType === vscode_html_languageservice_1.FileType.Directory && !dir.dirs.has(name)) {
|
|
200
|
+
const childDir = getDirFromDir(dir, name);
|
|
201
|
+
childDir.exists = true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
219
204
|
}
|
|
220
205
|
}
|
|
221
|
-
function fetch(action, fileName, p) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
yield current[2];
|
|
233
|
-
}
|
|
234
|
-
progress === null || progress === void 0 ? void 0 : progress.done();
|
|
235
|
-
runningRead = false;
|
|
236
|
-
fireChanges();
|
|
237
|
-
function updateProgress(text) {
|
|
238
|
-
clearTimeout(toUpdate);
|
|
239
|
-
toUpdate = setTimeout(() => {
|
|
240
|
-
progress === null || progress === void 0 ? void 0 : progress.report(text);
|
|
241
|
-
toUpdate = undefined;
|
|
242
|
-
}, 0);
|
|
243
|
-
}
|
|
206
|
+
async function fetch(action, fileName, p) {
|
|
207
|
+
fetchTasks.push([action, fileName, p]);
|
|
208
|
+
if (runningRead === false) {
|
|
209
|
+
let toUpdate;
|
|
210
|
+
runningRead = true;
|
|
211
|
+
const progress = await connection?.window.createWorkDoneProgress();
|
|
212
|
+
progress?.begin('');
|
|
213
|
+
while (fetchTasks.length) {
|
|
214
|
+
const current = fetchTasks.shift();
|
|
215
|
+
updateProgress(current[0] + ' ' + vscode_uri_1.URI.parse(env.fileNameToUri(current[1])).fsPath);
|
|
216
|
+
await current[2];
|
|
244
217
|
}
|
|
245
|
-
|
|
218
|
+
progress?.done();
|
|
219
|
+
runningRead = false;
|
|
220
|
+
fireChanges();
|
|
221
|
+
function updateProgress(text) {
|
|
222
|
+
clearTimeout(toUpdate);
|
|
223
|
+
toUpdate = setTimeout(() => {
|
|
224
|
+
progress?.report(text);
|
|
225
|
+
toUpdate = undefined;
|
|
226
|
+
}, 0);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
246
229
|
}
|
|
247
230
|
function resolveRequestUrl(uri) {
|
|
248
|
-
|
|
249
|
-
if (((_a = initOptions.typescript) === null || _a === void 0 ? void 0 : _a.cdn) && uri.startsWith(initOptions.typescript.cdn)) {
|
|
231
|
+
if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
|
|
250
232
|
let fileName = env.uriToFileName(uri);
|
|
251
233
|
for (const [key, version] of Object.entries(initOptions.typescript.versions || {})) {
|
|
252
234
|
if (fileName.startsWith(`/node_modules/${key}/`)) {
|
|
@@ -257,19 +239,17 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
|
|
|
257
239
|
}
|
|
258
240
|
return uri;
|
|
259
241
|
}
|
|
260
|
-
function fireChanges() {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
yield cb({ changes: _changes });
|
|
270
|
-
}
|
|
242
|
+
async function fireChanges() {
|
|
243
|
+
if (runningRead || runningStat) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const _changes = [...changes];
|
|
247
|
+
changes.length = 0;
|
|
248
|
+
for (const cb of [...onDidChangeWatchedFilesCb]) {
|
|
249
|
+
if (onDidChangeWatchedFilesCb.has(cb)) {
|
|
250
|
+
await cb({ changes: _changes });
|
|
271
251
|
}
|
|
272
|
-
}
|
|
252
|
+
}
|
|
273
253
|
}
|
|
274
254
|
function getDir(dirPath) {
|
|
275
255
|
const dirNames = [];
|
package/out/browser/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 request_light_1 = require("request-light");
|
|
@@ -54,17 +45,15 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
54
45
|
loadTypescript() {
|
|
55
46
|
return require('typescript'); // force bundle because not support load by user config in web
|
|
56
47
|
},
|
|
57
|
-
loadTypescriptLocalized(tsdk, locale) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return JSON.parse(json);
|
|
64
|
-
}
|
|
48
|
+
async loadTypescriptLocalized(tsdk, locale) {
|
|
49
|
+
try {
|
|
50
|
+
const uri = fileNameToUri(`${tsdk}/${locale}/diagnosticMessages.generated.json`);
|
|
51
|
+
const json = await (0, http_1.default)(uri);
|
|
52
|
+
if (json) {
|
|
53
|
+
return JSON.parse(json);
|
|
65
54
|
}
|
|
66
|
-
|
|
67
|
-
}
|
|
55
|
+
}
|
|
56
|
+
catch { }
|
|
68
57
|
},
|
|
69
58
|
schemaRequestHandlers: {
|
|
70
59
|
http: http_1.default,
|
|
@@ -78,17 +67,15 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
78
67
|
},
|
|
79
68
|
};
|
|
80
69
|
function uriToFileName(uri) {
|
|
81
|
-
var _a;
|
|
82
70
|
const parsed = vscode_uri_1.URI.parse(uri);
|
|
83
|
-
if (
|
|
71
|
+
if (options.typescript?.cdn && uri.startsWith(options.typescript.cdn)) {
|
|
84
72
|
return parsed.toString(true).replace(options.typescript.cdn, '/node_modules/');
|
|
85
73
|
}
|
|
86
74
|
return `/${parsed.scheme}${parsed.authority ? '@' + parsed.authority : ''}${parsed.path}`;
|
|
87
75
|
}
|
|
88
76
|
;
|
|
89
77
|
function fileNameToUri(fileName) {
|
|
90
|
-
|
|
91
|
-
if (fileName.startsWith('/node_modules/') && ((_a = options.typescript) === null || _a === void 0 ? void 0 : _a.cdn)) {
|
|
78
|
+
if (fileName.startsWith('/node_modules/') && options.typescript?.cdn) {
|
|
92
79
|
return vscode_uri_1.URI.parse(fileName.replace('/node_modules/', options.typescript.cdn)).toString();
|
|
93
80
|
}
|
|
94
81
|
const parts = fileName.split('/');
|
|
@@ -21,7 +21,7 @@ exports.every = every;
|
|
|
21
21
|
function findIndex(array, predicate, startIndex) {
|
|
22
22
|
if (array === undefined)
|
|
23
23
|
return -1;
|
|
24
|
-
for (let i = startIndex
|
|
24
|
+
for (let i = startIndex ?? 0; i < array.length; i++) {
|
|
25
25
|
if (predicate(array[i], i)) {
|
|
26
26
|
return i;
|
|
27
27
|
}
|
|
@@ -19,7 +19,7 @@ var NativeCollections;
|
|
|
19
19
|
*/
|
|
20
20
|
function tryGetNativeMap() {
|
|
21
21
|
// Internet Explorer's Map doesn't support iteration, so don't use it.
|
|
22
|
-
const gMap = globals
|
|
22
|
+
const gMap = globals?.Map;
|
|
23
23
|
// eslint-disable-next-line local/no-in-operator
|
|
24
24
|
const constructor = typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
|
|
25
25
|
if (!constructor) {
|
|
@@ -33,7 +33,7 @@ var NativeCollections;
|
|
|
33
33
|
*/
|
|
34
34
|
function tryGetNativeSet() {
|
|
35
35
|
// Internet Explorer's Set doesn't support iteration, so don't use it.
|
|
36
|
-
const gSet = globals
|
|
36
|
+
const gSet = globals?.Set;
|
|
37
37
|
// eslint-disable-next-line local/no-in-operator
|
|
38
38
|
const constructor = typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
|
|
39
39
|
if (!constructor) {
|
|
@@ -1,52 +1,36 @@
|
|
|
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.createConfigurationHost = void 0;
|
|
12
3
|
const vscode = require("vscode-languageserver");
|
|
13
4
|
function createConfigurationHost(params, connection) {
|
|
14
5
|
const callbacks = [];
|
|
15
6
|
const cache = new Map();
|
|
16
|
-
connection.onDidChangeConfiguration(() =>
|
|
7
|
+
connection.onDidChangeConfiguration(async () => {
|
|
17
8
|
cache.clear();
|
|
18
9
|
for (const cb of callbacks) {
|
|
19
10
|
cb();
|
|
20
11
|
}
|
|
21
|
-
})
|
|
12
|
+
});
|
|
22
13
|
return {
|
|
23
14
|
ready() {
|
|
24
|
-
|
|
25
|
-
if ((_b = (_a = params.capabilities.workspace) === null || _a === void 0 ? void 0 : _a.didChangeConfiguration) === null || _b === void 0 ? void 0 : _b.dynamicRegistration) {
|
|
15
|
+
if (params.capabilities.workspace?.didChangeConfiguration?.dynamicRegistration) {
|
|
26
16
|
connection.client.register(vscode.DidChangeConfigurationNotification.type);
|
|
27
17
|
}
|
|
28
18
|
},
|
|
29
|
-
getConfiguration(section, scopeUri) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!cache.has(section)) {
|
|
34
|
-
cache.set(section, yield getConfigurationWorker(section, scopeUri));
|
|
35
|
-
}
|
|
36
|
-
return cache.get(section);
|
|
19
|
+
async getConfiguration(section, scopeUri) {
|
|
20
|
+
if (!scopeUri && params.capabilities.workspace?.didChangeConfiguration) {
|
|
21
|
+
if (!cache.has(section)) {
|
|
22
|
+
cache.set(section, await getConfigurationWorker(section, scopeUri));
|
|
37
23
|
}
|
|
38
|
-
return
|
|
39
|
-
}
|
|
24
|
+
return cache.get(section);
|
|
25
|
+
}
|
|
26
|
+
return await getConfigurationWorker(section, scopeUri);
|
|
40
27
|
},
|
|
41
28
|
onDidChangeConfiguration(cb) {
|
|
42
29
|
callbacks.push(cb);
|
|
43
30
|
},
|
|
44
31
|
};
|
|
45
|
-
function getConfigurationWorker(section, scopeUri) {
|
|
46
|
-
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
return (_a = (yield connection.workspace.getConfiguration({ scopeUri, section }))) !== null && _a !== void 0 ? _a : undefined /* replace null to undefined */;
|
|
49
|
-
});
|
|
32
|
+
async function getConfigurationWorker(section, scopeUri) {
|
|
33
|
+
return (await connection.workspace.getConfiguration({ scopeUri, section })) ?? undefined /* replace null to undefined */;
|
|
50
34
|
}
|
|
51
35
|
}
|
|
52
36
|
exports.createConfigurationHost = createConfigurationHost;
|
package/out/common/documents.js
CHANGED
|
@@ -47,7 +47,7 @@ class IncrementalScriptSnapshot {
|
|
|
47
47
|
getLength: () => text.length,
|
|
48
48
|
getChangeRange: (oldSnapshot) => {
|
|
49
49
|
if (!cache.has(oldSnapshot)) {
|
|
50
|
-
const oldIndex = this.changes.findIndex(change =>
|
|
50
|
+
const oldIndex = this.changes.findIndex(change => change.snapshot?.deref() === oldSnapshot);
|
|
51
51
|
if (oldIndex >= 0) {
|
|
52
52
|
const start = oldIndex + 1;
|
|
53
53
|
const end = this.changes.indexOf(lastChange) + 1;
|
|
@@ -75,12 +75,11 @@ class IncrementalScriptSnapshot {
|
|
|
75
75
|
return this.document;
|
|
76
76
|
}
|
|
77
77
|
clearUnReferenceVersions() {
|
|
78
|
-
var _a;
|
|
79
78
|
let versionToApply;
|
|
80
79
|
for (let i = 0; i <= this.changes.length - 2; i++) {
|
|
81
80
|
const change = this.changes[i];
|
|
82
81
|
const nextChange = this.changes[i + 1];
|
|
83
|
-
if (!
|
|
82
|
+
if (!change.snapshot?.deref()) {
|
|
84
83
|
if (change.version !== nextChange.version) {
|
|
85
84
|
versionToApply = change.version;
|
|
86
85
|
}
|
|
@@ -1,41 +1,31 @@
|
|
|
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.register = void 0;
|
|
12
3
|
const protocol_1 = require("../../protocol");
|
|
13
4
|
const language_core_1 = require("@volar/language-core");
|
|
14
5
|
function register(connection, projects, env) {
|
|
15
|
-
connection.onNotification(protocol_1.ReportStats.type, () =>
|
|
16
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
6
|
+
connection.onNotification(protocol_1.ReportStats.type, async () => {
|
|
17
7
|
for (const [rootUri, _workspace] of projects.workspaces) {
|
|
18
8
|
connection.console.log('workspace: ' + rootUri);
|
|
19
|
-
const workspace =
|
|
20
|
-
connection.console.log('documentRegistry stats: ' +
|
|
9
|
+
const workspace = await _workspace;
|
|
10
|
+
connection.console.log('documentRegistry stats: ' + workspace.documentRegistry?.reportStats());
|
|
21
11
|
connection.console.log('');
|
|
22
12
|
connection.console.log('tsconfig: inferred');
|
|
23
13
|
const _inferredProject = workspace.getInferredProjectDontCreate();
|
|
24
14
|
if (_inferredProject) {
|
|
25
15
|
connection.console.log('loaded: true');
|
|
26
|
-
const inferredProject =
|
|
16
|
+
const inferredProject = await _inferredProject;
|
|
27
17
|
connection.console.log('largest 10 files:');
|
|
28
18
|
for (const script of [...inferredProject.scripts.values()]
|
|
29
|
-
.sort((a, b) =>
|
|
19
|
+
.sort((a, b) => (b.snapshot?.getLength() ?? 0) - (a.snapshot?.getLength() ?? 0))
|
|
30
20
|
.slice(0, 10)) {
|
|
31
21
|
connection.console.log(' - ' + script.fileName);
|
|
32
|
-
connection.console.log(` size: ${
|
|
22
|
+
connection.console.log(` size: ${script.snapshot?.getLength()}`);
|
|
33
23
|
}
|
|
34
24
|
connection.console.log('files:');
|
|
35
25
|
for (const script of inferredProject.scripts.values()) {
|
|
36
26
|
connection.console.log(' - ' + script.fileName);
|
|
37
|
-
connection.console.log(` size: ${
|
|
38
|
-
connection.console.log(` ref counts: "${
|
|
27
|
+
connection.console.log(` size: ${script.snapshot?.getLength()}`);
|
|
28
|
+
connection.console.log(` ref counts: "${workspace.documentRegistry.getLanguageServiceRefCounts?.(script.fileName, inferredProject.languageServiceHost.getScriptKind?.(script.fileName))})"`);
|
|
39
29
|
}
|
|
40
30
|
}
|
|
41
31
|
else {
|
|
@@ -43,40 +33,39 @@ function register(connection, projects, env) {
|
|
|
43
33
|
}
|
|
44
34
|
connection.console.log('');
|
|
45
35
|
for (const _project of workspace.projects.values()) {
|
|
46
|
-
const project =
|
|
36
|
+
const project = await _project;
|
|
47
37
|
connection.console.log('tsconfig: ' + project.tsConfig);
|
|
48
38
|
connection.console.log('loaded: ' + !!project.getLanguageServiceDontCreate());
|
|
49
39
|
connection.console.log('largest 10 files:');
|
|
50
40
|
for (const script of [...project.scripts.values()]
|
|
51
|
-
.sort((a, b) =>
|
|
41
|
+
.sort((a, b) => (b.snapshot?.getLength() ?? 0) - (a.snapshot?.getLength() ?? 0))
|
|
52
42
|
.slice(0, 10)) {
|
|
53
43
|
connection.console.log(' - ' + script.fileName);
|
|
54
|
-
connection.console.log(` size: ${
|
|
44
|
+
connection.console.log(` size: ${script.snapshot?.getLength()}`);
|
|
55
45
|
}
|
|
56
46
|
connection.console.log('files:');
|
|
57
47
|
for (const script of project.scripts.values()) {
|
|
58
48
|
connection.console.log(' - ' + script.fileName);
|
|
59
|
-
connection.console.log(` size: ${
|
|
60
|
-
connection.console.log(` ref counts: "${
|
|
49
|
+
connection.console.log(` size: ${script.snapshot?.getLength()}`);
|
|
50
|
+
connection.console.log(` ref counts: "${workspace.documentRegistry.getLanguageServiceRefCounts?.(script.fileName, project.languageServiceHost.getScriptKind?.(script.fileName))})"`);
|
|
61
51
|
}
|
|
62
52
|
}
|
|
63
53
|
connection.console.log('');
|
|
64
54
|
}
|
|
65
|
-
})
|
|
66
|
-
connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) =>
|
|
67
|
-
const project = (
|
|
68
|
-
if (project
|
|
55
|
+
});
|
|
56
|
+
connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, async (params) => {
|
|
57
|
+
const project = (await projects.getProject(params.uri));
|
|
58
|
+
if (project?.tsconfig) {
|
|
69
59
|
return { uri: env.fileNameToUri(project.tsconfig) };
|
|
70
60
|
}
|
|
71
|
-
})
|
|
72
|
-
connection.onRequest(protocol_1.GetVirtualFileNamesRequest.type, (document) =>
|
|
73
|
-
|
|
74
|
-
const project = yield projects.getProject(document.uri);
|
|
61
|
+
});
|
|
62
|
+
connection.onRequest(protocol_1.GetVirtualFileNamesRequest.type, async (document) => {
|
|
63
|
+
const project = await projects.getProject(document.uri);
|
|
75
64
|
const fileNames = [];
|
|
76
65
|
if (project) {
|
|
77
|
-
const rootVirtualFile =
|
|
66
|
+
const rootVirtualFile = project.project?.getLanguageService().context.core.virtualFiles.getSource(env.uriToFileName(document.uri))?.root;
|
|
78
67
|
if (rootVirtualFile) {
|
|
79
|
-
const kinds =
|
|
68
|
+
const kinds = document.fileKinds ?? [language_core_1.FileKind.TypeScriptHostFile];
|
|
80
69
|
(0, language_core_1.forEachEmbeddedFile)(rootVirtualFile, e => {
|
|
81
70
|
if (e.snapshot.getLength() && kinds.includes(e.kind)) {
|
|
82
71
|
fileNames.push(e.fileName);
|
|
@@ -85,17 +74,16 @@ function register(connection, projects, env) {
|
|
|
85
74
|
}
|
|
86
75
|
}
|
|
87
76
|
return fileNames;
|
|
88
|
-
})
|
|
89
|
-
connection.onRequest(protocol_1.GetVirtualFileRequest.type, (params) =>
|
|
90
|
-
|
|
91
|
-
const project = yield projects.getProject(params.sourceFileUri);
|
|
77
|
+
});
|
|
78
|
+
connection.onRequest(protocol_1.GetVirtualFileRequest.type, async (params) => {
|
|
79
|
+
const project = await projects.getProject(params.sourceFileUri);
|
|
92
80
|
if (project) {
|
|
93
|
-
const [virtualFile, source] =
|
|
81
|
+
const [virtualFile, source] = project.project?.getLanguageService().context.core.virtualFiles.getVirtualFile(params.virtualFileName) ?? [];
|
|
94
82
|
if (virtualFile && source) {
|
|
95
83
|
const mappings = {};
|
|
96
84
|
for (const mapping of virtualFile.mappings) {
|
|
97
|
-
const sourceUri = env.fileNameToUri(
|
|
98
|
-
|
|
85
|
+
const sourceUri = env.fileNameToUri(mapping.source ?? source.fileName);
|
|
86
|
+
mappings[sourceUri] ??= [];
|
|
99
87
|
mappings[sourceUri].push(mapping);
|
|
100
88
|
}
|
|
101
89
|
return {
|
|
@@ -104,16 +92,15 @@ function register(connection, projects, env) {
|
|
|
104
92
|
};
|
|
105
93
|
}
|
|
106
94
|
}
|
|
107
|
-
})
|
|
95
|
+
});
|
|
108
96
|
connection.onNotification(protocol_1.ReloadProjectNotification.type, () => {
|
|
109
97
|
projects.reloadProject();
|
|
110
98
|
});
|
|
111
|
-
connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, (params) =>
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const project = yield projects.getProject(params.uri);
|
|
99
|
+
connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, async (params) => {
|
|
100
|
+
const fs = await Promise.resolve().then(() => require('fs'));
|
|
101
|
+
const project = await projects.getProject(params.uri);
|
|
115
102
|
if (project) {
|
|
116
|
-
const ls = (
|
|
103
|
+
const ls = (await project.project)?.getLanguageServiceDontCreate();
|
|
117
104
|
if (ls) {
|
|
118
105
|
const sourceFiles = new Set(ls.context.host.getScriptFileNames());
|
|
119
106
|
for (const virtualFile of ls.context.core.typescript.languageServiceHost.getScriptFileNames()) {
|
|
@@ -126,7 +113,7 @@ function register(connection, projects, env) {
|
|
|
126
113
|
}
|
|
127
114
|
}
|
|
128
115
|
}
|
|
129
|
-
})
|
|
116
|
+
});
|
|
130
117
|
}
|
|
131
118
|
exports.register = register;
|
|
132
119
|
//# sourceMappingURL=customFeatures.js.map
|