@volar/language-server 1.4.0-alpha.0 → 1.4.0-alpha.10
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 +83 -107
- package/out/browser/index.js +11 -23
- package/out/browser/typescript/core.js +2 -1
- package/out/browser/typescript/corePublic.js +3 -2
- package/out/browser/typescript/path.js +1 -0
- package/out/browser/typescript/types.js +1 -0
- package/out/browser/typescript/utilities.js +1 -0
- package/out/common/cancellationPipe.js +2 -1
- package/out/common/configurationHost.js +13 -28
- package/out/common/documents.js +3 -3
- package/out/common/features/customFeatures.js +35 -47
- package/out/common/features/languageFeatures.js +135 -163
- package/out/common/project.d.ts +66 -62
- package/out/common/project.js +205 -228
- package/out/common/schemaRequestHandlers/file.js +1 -0
- package/out/common/schemaRequestHandlers/http.js +1 -0
- package/out/common/server.js +63 -68
- package/out/common/utils/inferredCompilerOptions.js +58 -61
- package/out/common/utils/isFileInDir.js +1 -0
- package/out/common/utils/registerFeatures.js +11 -12
- package/out/common/utils/serverConfig.js +3 -2
- package/out/common/utils/uriMap.js +2 -1
- package/out/common/workspace.d.ts +605 -568
- package/out/common/workspace.js +182 -194
- package/out/common/workspaces.d.ts +726 -682
- package/out/common/workspaces.js +82 -107
- package/out/index.js +1 -0
- package/out/node/fileSystem.js +13 -16
- package/out/node/index.js +16 -19
- package/out/protocol.d.ts +0 -6
- package/out/protocol.js +2 -5
- package/out/types.d.ts +4 -6
- package/out/types.js +1 -0
- package/package.json +4 -4
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
1
|
+
"use strict";
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
3
|
exports.createWebFileSystemHost = void 0;
|
|
12
4
|
const path = require("typesafe-path");
|
|
@@ -16,7 +8,6 @@ const vscode_uri_1 = require("vscode-uri");
|
|
|
16
8
|
const protocol_1 = require("../protocol");
|
|
17
9
|
const utilities_1 = require("./typescript/utilities");
|
|
18
10
|
const uriMap_1 = require("../common/utils/uriMap");
|
|
19
|
-
let currentCwd = '/';
|
|
20
11
|
function createWebFileSystemHost(_0, _1, env, initOptions) {
|
|
21
12
|
const instances = (0, uriMap_1.createUriMap)(env.fileNameToUri);
|
|
22
13
|
const onDidChangeWatchedFilesCb = new Set();
|
|
@@ -91,45 +82,39 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
|
|
|
91
82
|
realpath: path => path, // TODO: cannot implement with vscode
|
|
92
83
|
};
|
|
93
84
|
function resolvePath(fsPath) {
|
|
94
|
-
if (currentCwd !== rootPath) {
|
|
95
|
-
process.chdir(rootPath);
|
|
96
|
-
currentCwd = rootPath;
|
|
97
|
-
}
|
|
98
85
|
return path.resolve(fsPath);
|
|
99
86
|
}
|
|
100
87
|
function fileExists(fsPath) {
|
|
101
|
-
var _a, _b, _c;
|
|
102
88
|
fsPath = resolvePath(fsPath);
|
|
103
89
|
const uri = env.fileNameToUri(fsPath);
|
|
104
90
|
const dirPath = path.dirname(fsPath);
|
|
105
|
-
if (
|
|
91
|
+
if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
|
|
106
92
|
if (!(uri.endsWith('.d.ts') || uri.endsWith('/package.json'))) {
|
|
107
93
|
return false;
|
|
108
94
|
}
|
|
109
95
|
readFile(fsPath);
|
|
110
96
|
const file = getDir(dirPath).files.get(path.basename(fsPath));
|
|
111
|
-
return
|
|
97
|
+
return file?.exists ?? false;
|
|
112
98
|
}
|
|
113
99
|
readDirectory(dirPath);
|
|
114
100
|
const file = getDir(path.dirname(fsPath)).files.get(path.basename(fsPath));
|
|
115
|
-
return
|
|
101
|
+
return file?.exists ?? false;
|
|
116
102
|
}
|
|
117
103
|
function readFile(fsPath) {
|
|
118
|
-
var _a, _b, _c, _d;
|
|
119
104
|
fsPath = resolvePath(fsPath);
|
|
120
105
|
const uri = env.fileNameToUri(fsPath);
|
|
121
106
|
const dirPath = path.dirname(fsPath);
|
|
122
107
|
const dir = getDir(dirPath);
|
|
123
108
|
const name = path.basename(fsPath);
|
|
124
|
-
if (
|
|
109
|
+
if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
|
|
125
110
|
if (!(uri.endsWith('.d.ts') || uri.endsWith('/package.json'))) {
|
|
126
|
-
return
|
|
111
|
+
return dir.files.get(name)?.text || '';
|
|
127
112
|
}
|
|
128
113
|
readFileWorker();
|
|
129
|
-
return
|
|
114
|
+
return dir.files.get(name)?.text || '';
|
|
130
115
|
}
|
|
131
116
|
readFileWorker();
|
|
132
|
-
return
|
|
117
|
+
return dir.files.get(name)?.text || '';
|
|
133
118
|
function readFileWorker() {
|
|
134
119
|
if (connection) {
|
|
135
120
|
fetch('load', fsPath, readFileAsync(connection, fsPath, dir));
|
|
@@ -138,26 +123,24 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
|
|
|
138
123
|
onReadyCb.push((connection) => fetch('load', fsPath, readFileAsync(connection, fsPath, dir)));
|
|
139
124
|
}
|
|
140
125
|
}
|
|
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
|
-
});
|
|
126
|
+
async function readFileAsync(connection, fsPath, dir) {
|
|
127
|
+
const name = path.basename(fsPath);
|
|
128
|
+
if (!dir.files.has(name)) {
|
|
129
|
+
dir.files.set(name, {});
|
|
130
|
+
}
|
|
131
|
+
const file = dir.files.get(name);
|
|
132
|
+
if (file.requested) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
file.requested = true;
|
|
136
|
+
const uri = env.fileNameToUri(fsPath);
|
|
137
|
+
const data = await connection.sendRequest(protocol_1.FsReadFileRequest.type, resolveRequestUrl(uri));
|
|
138
|
+
const text = data ? new TextDecoder('utf8').decode(data) : undefined;
|
|
139
|
+
if (text?.length) {
|
|
140
|
+
file.exists = true;
|
|
141
|
+
file.text = text;
|
|
142
|
+
changes.push({ uri, type: vscode.FileChangeType.Changed });
|
|
143
|
+
}
|
|
161
144
|
}
|
|
162
145
|
}
|
|
163
146
|
function readDirectory(fsPath, extensions, exclude, include, depth) {
|
|
@@ -187,66 +170,61 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
|
|
|
187
170
|
onReadyCb.push((connection) => fetch('directory', fsPath, readDirectoryAsync(connection, fsPath)));
|
|
188
171
|
}
|
|
189
172
|
}
|
|
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
|
-
}
|
|
173
|
+
async function readDirectoryAsync(connection, fsPath) {
|
|
174
|
+
const dir = getDir(fsPath);
|
|
175
|
+
if (dir.requested) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
dir.requested = true;
|
|
179
|
+
const uri = env.fileNameToUri(fsPath);
|
|
180
|
+
const result = await connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, resolveRequestUrl(uri));
|
|
181
|
+
for (const [name, fileType] of result) {
|
|
182
|
+
if (fileType === vscode_html_languageservice_1.FileType.File || fileType === vscode_html_languageservice_1.FileType.SymbolicLink) {
|
|
183
|
+
if (!dir.files.has(name)) {
|
|
184
|
+
dir.files.set(name, {});
|
|
212
185
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
186
|
+
const file = dir.files.get(name);
|
|
187
|
+
if (!file.exists) {
|
|
188
|
+
file.exists = true;
|
|
189
|
+
changes.push({
|
|
190
|
+
uri: env.fileNameToUri(path.join(fsPath, name)),
|
|
191
|
+
type: vscode.FileChangeType.Created,
|
|
192
|
+
});
|
|
216
193
|
}
|
|
217
194
|
}
|
|
218
|
-
|
|
195
|
+
else if (fileType === vscode_html_languageservice_1.FileType.Directory && !dir.dirs.has(name)) {
|
|
196
|
+
const childDir = getDirFromDir(dir, name);
|
|
197
|
+
childDir.exists = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
219
200
|
}
|
|
220
201
|
}
|
|
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
|
-
}
|
|
202
|
+
async function fetch(action, fileName, p) {
|
|
203
|
+
fetchTasks.push([action, fileName, p]);
|
|
204
|
+
if (runningRead === false) {
|
|
205
|
+
let toUpdate;
|
|
206
|
+
runningRead = true;
|
|
207
|
+
const progress = await connection?.window.createWorkDoneProgress();
|
|
208
|
+
progress?.begin('');
|
|
209
|
+
while (fetchTasks.length) {
|
|
210
|
+
const current = fetchTasks.shift();
|
|
211
|
+
updateProgress(current[0] + ' ' + vscode_uri_1.URI.parse(env.fileNameToUri(current[1])).fsPath);
|
|
212
|
+
await current[2];
|
|
244
213
|
}
|
|
245
|
-
|
|
214
|
+
progress?.done();
|
|
215
|
+
runningRead = false;
|
|
216
|
+
fireChanges();
|
|
217
|
+
function updateProgress(text) {
|
|
218
|
+
clearTimeout(toUpdate);
|
|
219
|
+
toUpdate = setTimeout(() => {
|
|
220
|
+
progress?.report(text);
|
|
221
|
+
toUpdate = undefined;
|
|
222
|
+
}, 0);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
246
225
|
}
|
|
247
226
|
function resolveRequestUrl(uri) {
|
|
248
|
-
|
|
249
|
-
if (((_a = initOptions.typescript) === null || _a === void 0 ? void 0 : _a.cdn) && uri.startsWith(initOptions.typescript.cdn)) {
|
|
227
|
+
if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
|
|
250
228
|
let fileName = env.uriToFileName(uri);
|
|
251
229
|
for (const [key, version] of Object.entries(initOptions.typescript.versions || {})) {
|
|
252
230
|
if (fileName.startsWith(`/node_modules/${key}/`)) {
|
|
@@ -257,19 +235,17 @@ function createWebFileSystemHost(_0, _1, env, initOptions) {
|
|
|
257
235
|
}
|
|
258
236
|
return uri;
|
|
259
237
|
}
|
|
260
|
-
function fireChanges() {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
yield cb({ changes: _changes });
|
|
270
|
-
}
|
|
238
|
+
async function fireChanges() {
|
|
239
|
+
if (runningRead || runningStat) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const _changes = [...changes];
|
|
243
|
+
changes.length = 0;
|
|
244
|
+
for (const cb of [...onDidChangeWatchedFilesCb]) {
|
|
245
|
+
if (onDidChangeWatchedFilesCb.has(cb)) {
|
|
246
|
+
await cb({ changes: _changes });
|
|
271
247
|
}
|
|
272
|
-
}
|
|
248
|
+
}
|
|
273
249
|
}
|
|
274
250
|
function getDir(dirPath) {
|
|
275
251
|
const dirNames = [];
|
package/out/browser/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
3
|
if (k2 === undefined) k2 = k;
|
|
3
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -12,15 +13,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
12
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
15
|
};
|
|
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
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
17
|
exports.startLanguageServer = exports.createConnection = void 0;
|
|
26
18
|
const request_light_1 = require("request-light");
|
|
@@ -54,17 +46,15 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
54
46
|
loadTypescript() {
|
|
55
47
|
return require('typescript'); // force bundle because not support load by user config in web
|
|
56
48
|
},
|
|
57
|
-
loadTypescriptLocalized(tsdk, locale) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return JSON.parse(json);
|
|
64
|
-
}
|
|
49
|
+
async loadTypescriptLocalized(tsdk, locale) {
|
|
50
|
+
try {
|
|
51
|
+
const uri = fileNameToUri(`${tsdk}/${locale}/diagnosticMessages.generated.json`);
|
|
52
|
+
const json = await (0, http_1.default)(uri);
|
|
53
|
+
if (json) {
|
|
54
|
+
return JSON.parse(json);
|
|
65
55
|
}
|
|
66
|
-
|
|
67
|
-
}
|
|
56
|
+
}
|
|
57
|
+
catch { }
|
|
68
58
|
},
|
|
69
59
|
schemaRequestHandlers: {
|
|
70
60
|
http: http_1.default,
|
|
@@ -78,17 +68,15 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
78
68
|
},
|
|
79
69
|
};
|
|
80
70
|
function uriToFileName(uri) {
|
|
81
|
-
var _a;
|
|
82
71
|
const parsed = vscode_uri_1.URI.parse(uri);
|
|
83
|
-
if (
|
|
72
|
+
if (options.typescript?.cdn && uri.startsWith(options.typescript.cdn)) {
|
|
84
73
|
return parsed.toString(true).replace(options.typescript.cdn, '/node_modules/');
|
|
85
74
|
}
|
|
86
75
|
return `/${parsed.scheme}${parsed.authority ? '@' + parsed.authority : ''}${parsed.path}`;
|
|
87
76
|
}
|
|
88
77
|
;
|
|
89
78
|
function fileNameToUri(fileName) {
|
|
90
|
-
|
|
91
|
-
if (fileName.startsWith('/node_modules/') && ((_a = options.typescript) === null || _a === void 0 ? void 0 : _a.cdn)) {
|
|
79
|
+
if (fileName.startsWith('/node_modules/') && options.typescript?.cdn) {
|
|
92
80
|
return vscode_uri_1.URI.parse(fileName.replace('/node_modules/', options.typescript.cdn)).toString();
|
|
93
81
|
}
|
|
94
82
|
const parts = fileName.split('/');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.startsWith = exports.createGetCanonicalFileName = exports.stringContains = exports.endsWith = exports.getStringComparer = exports.compareStringsCaseSensitive = exports.equateStringsCaseSensitive = exports.equateStringsCaseInsensitive = exports.last = exports.lastOrUndefined = exports.sort = exports.some = exports.flatMap = exports.flatten = exports.map = exports.indexOfAnyCharCode = exports.findIndex = exports.every = void 0;
|
|
3
4
|
const emptyArray = [];
|
|
@@ -21,7 +22,7 @@ exports.every = every;
|
|
|
21
22
|
function findIndex(array, predicate, startIndex) {
|
|
22
23
|
if (array === undefined)
|
|
23
24
|
return -1;
|
|
24
|
-
for (let i = startIndex
|
|
25
|
+
for (let i = startIndex ?? 0; i < array.length; i++) {
|
|
25
26
|
if (predicate(array[i], i)) {
|
|
26
27
|
return i;
|
|
27
28
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.Set = exports.Map = exports.version = exports.versionMajorMinor = void 0;
|
|
3
4
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
@@ -19,7 +20,7 @@ var NativeCollections;
|
|
|
19
20
|
*/
|
|
20
21
|
function tryGetNativeMap() {
|
|
21
22
|
// Internet Explorer's Map doesn't support iteration, so don't use it.
|
|
22
|
-
const gMap = globals
|
|
23
|
+
const gMap = globals?.Map;
|
|
23
24
|
// eslint-disable-next-line local/no-in-operator
|
|
24
25
|
const constructor = typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
|
|
25
26
|
if (!constructor) {
|
|
@@ -33,7 +34,7 @@ var NativeCollections;
|
|
|
33
34
|
*/
|
|
34
35
|
function tryGetNativeSet() {
|
|
35
36
|
// Internet Explorer's Set doesn't support iteration, so don't use it.
|
|
36
|
-
const gSet = globals
|
|
37
|
+
const gSet = globals?.Set;
|
|
37
38
|
// eslint-disable-next-line local/no-in-operator
|
|
38
39
|
const constructor = typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
|
|
39
40
|
if (!constructor) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.containsPath = exports.removeTrailingDirectorySeparator = exports.normalizePath = exports.getNormalizedPathComponents = exports.combinePaths = exports.getDirectoryPath = exports.fileExtensionIsOneOf = exports.hasExtension = exports.isRootedDiskPath = exports.directorySeparator = void 0;
|
|
3
4
|
const core_1 = require("./core");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.createCancellationTokenHost = void 0;
|
|
3
4
|
const vscode = require("vscode-languageserver");
|
|
@@ -35,7 +36,7 @@ function createCancellationTokenHost(_cancellationPipeName) {
|
|
|
35
36
|
try {
|
|
36
37
|
return fs.statSync(cancellationPipeName).mtime.valueOf();
|
|
37
38
|
}
|
|
38
|
-
catch
|
|
39
|
+
catch {
|
|
39
40
|
return -1;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -1,52 +1,37 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
1
|
+
"use strict";
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
3
|
exports.createConfigurationHost = void 0;
|
|
12
4
|
const vscode = require("vscode-languageserver");
|
|
13
5
|
function createConfigurationHost(params, connection) {
|
|
14
6
|
const callbacks = [];
|
|
15
7
|
const cache = new Map();
|
|
16
|
-
connection.onDidChangeConfiguration(() =>
|
|
8
|
+
connection.onDidChangeConfiguration(async () => {
|
|
17
9
|
cache.clear();
|
|
18
10
|
for (const cb of callbacks) {
|
|
19
11
|
cb();
|
|
20
12
|
}
|
|
21
|
-
})
|
|
13
|
+
});
|
|
22
14
|
return {
|
|
23
15
|
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) {
|
|
16
|
+
if (params.capabilities.workspace?.didChangeConfiguration?.dynamicRegistration) {
|
|
26
17
|
connection.client.register(vscode.DidChangeConfigurationNotification.type);
|
|
27
18
|
}
|
|
28
19
|
},
|
|
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);
|
|
20
|
+
async getConfiguration(section, scopeUri) {
|
|
21
|
+
if (!scopeUri && params.capabilities.workspace?.didChangeConfiguration) {
|
|
22
|
+
if (!cache.has(section)) {
|
|
23
|
+
cache.set(section, await getConfigurationWorker(section, scopeUri));
|
|
37
24
|
}
|
|
38
|
-
return
|
|
39
|
-
}
|
|
25
|
+
return cache.get(section);
|
|
26
|
+
}
|
|
27
|
+
return await getConfigurationWorker(section, scopeUri);
|
|
40
28
|
},
|
|
41
29
|
onDidChangeConfiguration(cb) {
|
|
42
30
|
callbacks.push(cb);
|
|
43
31
|
},
|
|
44
32
|
};
|
|
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
|
-
});
|
|
33
|
+
async function getConfigurationWorker(section, scopeUri) {
|
|
34
|
+
return (await connection.workspace.getConfiguration({ scopeUri, section })) ?? undefined /* replace null to undefined */;
|
|
50
35
|
}
|
|
51
36
|
}
|
|
52
37
|
exports.createConfigurationHost = createConfigurationHost;
|
package/out/common/documents.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.createDocuments = exports.combineContinuousChangeRanges = void 0;
|
|
3
4
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
@@ -47,7 +48,7 @@ class IncrementalScriptSnapshot {
|
|
|
47
48
|
getLength: () => text.length,
|
|
48
49
|
getChangeRange: (oldSnapshot) => {
|
|
49
50
|
if (!cache.has(oldSnapshot)) {
|
|
50
|
-
const oldIndex = this.changes.findIndex(change =>
|
|
51
|
+
const oldIndex = this.changes.findIndex(change => change.snapshot?.deref() === oldSnapshot);
|
|
51
52
|
if (oldIndex >= 0) {
|
|
52
53
|
const start = oldIndex + 1;
|
|
53
54
|
const end = this.changes.indexOf(lastChange) + 1;
|
|
@@ -75,12 +76,11 @@ class IncrementalScriptSnapshot {
|
|
|
75
76
|
return this.document;
|
|
76
77
|
}
|
|
77
78
|
clearUnReferenceVersions() {
|
|
78
|
-
var _a;
|
|
79
79
|
let versionToApply;
|
|
80
80
|
for (let i = 0; i <= this.changes.length - 2; i++) {
|
|
81
81
|
const change = this.changes[i];
|
|
82
82
|
const nextChange = this.changes[i + 1];
|
|
83
|
-
if (!
|
|
83
|
+
if (!change.snapshot?.deref()) {
|
|
84
84
|
if (change.version !== nextChange.version) {
|
|
85
85
|
versionToApply = change.version;
|
|
86
86
|
}
|