typescript-language-server 5.1.2 → 5.2.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/lib/cli.mjs +1700 -1130
- package/lib/cli.mjs.map +1 -1
- package/package.json +25 -22
- package/CHANGELOG.md +0 -700
package/lib/cli.mjs
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs$2, { promises, statSync, existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import require$$0 from 'node:events';
|
|
5
|
+
|
|
6
|
+
import require$$1 from 'node:child_process';
|
|
7
|
+
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
|
|
10
|
+
import path__default, { extname, resolve } from 'node:path';
|
|
11
|
+
|
|
12
|
+
import process$1 from 'node:process';
|
|
5
13
|
|
|
6
|
-
import require$$0, { promisify } from 'util';
|
|
14
|
+
import require$$0$3, { promisify as promisify$1 } from 'node:util';
|
|
7
15
|
|
|
8
|
-
import require$$1 from '
|
|
16
|
+
import require$$0$1, { promisify } from 'util';
|
|
17
|
+
|
|
18
|
+
import require$$1$1 from 'path';
|
|
9
19
|
|
|
10
20
|
import require$$2 from 'os';
|
|
11
21
|
|
|
@@ -13,35 +23,25 @@ import crypto from 'crypto';
|
|
|
13
23
|
|
|
14
24
|
import require$$4 from 'net';
|
|
15
25
|
|
|
16
|
-
import require$$0$
|
|
26
|
+
import require$$0$2 from 'url';
|
|
17
27
|
|
|
18
|
-
import require$$
|
|
28
|
+
import require$$2$1 from 'fs';
|
|
19
29
|
|
|
20
30
|
import require$$3 from 'child_process';
|
|
21
31
|
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
import path__default, { extname, resolve } from 'node:path';
|
|
25
|
-
|
|
26
|
-
import require$$0$3 from 'constants';
|
|
32
|
+
import require$$0$4 from 'constants';
|
|
27
33
|
|
|
28
|
-
import require$$0$
|
|
34
|
+
import require$$0$5 from 'stream';
|
|
29
35
|
|
|
30
36
|
import require$$5 from 'assert';
|
|
31
37
|
|
|
32
38
|
import os from 'node:os';
|
|
33
39
|
|
|
34
|
-
import 'node:fs/promises';
|
|
40
|
+
import fsPromises from 'node:fs/promises';
|
|
35
41
|
|
|
36
42
|
import stream from 'node:stream';
|
|
37
43
|
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
import ChildProcess from 'node:child_process';
|
|
41
|
-
|
|
42
|
-
import require$$1$1 from 'fs/promises';
|
|
43
|
-
|
|
44
|
-
import process$1 from 'node:process';
|
|
44
|
+
import { createRequire } from 'node:module';
|
|
45
45
|
|
|
46
46
|
import { fileURLToPath } from 'node:url';
|
|
47
47
|
|
|
@@ -171,36 +171,6 @@ function requireArgument() {
|
|
|
171
171
|
|
|
172
172
|
var command = {};
|
|
173
173
|
|
|
174
|
-
const require$5 = createRequire(import.meta.url);
|
|
175
|
-
|
|
176
|
-
function __require$5() {
|
|
177
|
-
return require$5('node:events');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const require$4 = createRequire(import.meta.url);
|
|
181
|
-
|
|
182
|
-
function __require$4() {
|
|
183
|
-
return require$4('node:child_process');
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const require$3 = createRequire(import.meta.url);
|
|
187
|
-
|
|
188
|
-
function __require$3() {
|
|
189
|
-
return require$3('node:path');
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const require$2 = createRequire(import.meta.url);
|
|
193
|
-
|
|
194
|
-
function __require$2() {
|
|
195
|
-
return require$2('node:fs');
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const require$1 = createRequire(import.meta.url);
|
|
199
|
-
|
|
200
|
-
function __require$1() {
|
|
201
|
-
return require$1('node:process');
|
|
202
|
-
}
|
|
203
|
-
|
|
204
174
|
var help = {};
|
|
205
175
|
|
|
206
176
|
var hasRequiredHelp;
|
|
@@ -779,11 +749,11 @@ var hasRequiredCommand;
|
|
|
779
749
|
function requireCommand() {
|
|
780
750
|
if (hasRequiredCommand) return command;
|
|
781
751
|
hasRequiredCommand = 1;
|
|
782
|
-
const EventEmitter =
|
|
783
|
-
const childProcess =
|
|
784
|
-
const path =
|
|
785
|
-
const fs =
|
|
786
|
-
const process =
|
|
752
|
+
const EventEmitter = require$$0.EventEmitter;
|
|
753
|
+
const childProcess = require$$1;
|
|
754
|
+
const path = path__default;
|
|
755
|
+
const fs = fs$2;
|
|
756
|
+
const process = process$1;
|
|
787
757
|
const {Argument: Argument, humanReadableArgName: humanReadableArgName} = requireArgument();
|
|
788
758
|
const {CommanderError: CommanderError} = requireError();
|
|
789
759
|
const {Help: Help, stripColor: stripColor} = requireHelp();
|
|
@@ -2155,12 +2125,6 @@ const {program: program$1, createCommand: createCommand, createArgument: createA
|
|
|
2155
2125
|
|
|
2156
2126
|
var main$3 = {};
|
|
2157
2127
|
|
|
2158
|
-
const require = createRequire(import.meta.url);
|
|
2159
|
-
|
|
2160
|
-
function __require() {
|
|
2161
|
-
return require('node:util');
|
|
2162
|
-
}
|
|
2163
|
-
|
|
2164
2128
|
var is$2 = {};
|
|
2165
2129
|
|
|
2166
2130
|
var hasRequiredIs$2;
|
|
@@ -5368,7 +5332,7 @@ function requireRil() {
|
|
|
5368
5332
|
Object.defineProperty(ril, '__esModule', {
|
|
5369
5333
|
value: true
|
|
5370
5334
|
});
|
|
5371
|
-
const util_1 = require$$0;
|
|
5335
|
+
const util_1 = require$$0$1;
|
|
5372
5336
|
const api_1 = requireApi$2();
|
|
5373
5337
|
class MessageBuffer extends api_1.AbstractMessageBuffer {
|
|
5374
5338
|
constructor(encoding = 'utf-8') {
|
|
@@ -5556,7 +5520,7 @@ function requireMain$3() {
|
|
|
5556
5520
|
exports.createMessageConnection = exports.createServerSocketTransport = exports.createClientSocketTransport = exports.createServerPipeTransport = exports.createClientPipeTransport = exports.generateRandomPipeName = exports.StreamMessageWriter = exports.StreamMessageReader = exports.SocketMessageWriter = exports.SocketMessageReader = exports.PortMessageWriter = exports.PortMessageReader = exports.IPCMessageWriter = exports.IPCMessageReader = void 0;
|
|
5557
5521
|
const ril_1 = requireRil();
|
|
5558
5522
|
ril_1.default.install();
|
|
5559
|
-
const path = require$$1;
|
|
5523
|
+
const path = require$$1$1;
|
|
5560
5524
|
const os = require$$2;
|
|
5561
5525
|
const crypto_1 = crypto;
|
|
5562
5526
|
const net_1 = require$$4;
|
|
@@ -11167,9 +11131,9 @@ function requireFiles() {
|
|
|
11167
11131
|
value: true
|
|
11168
11132
|
});
|
|
11169
11133
|
files.resolveModulePath = files.FileSystem = files.resolveGlobalYarnPath = files.resolveGlobalNodePath = files.resolve = files.uriToFilePath = void 0;
|
|
11170
|
-
const url = require$$0$
|
|
11171
|
-
const path = require$$1;
|
|
11172
|
-
const fs = require$$
|
|
11134
|
+
const url = require$$0$2;
|
|
11135
|
+
const path = require$$1$1;
|
|
11136
|
+
const fs = require$$2$1;
|
|
11173
11137
|
const child_process_1 = require$$3;
|
|
11174
11138
|
function uriToFilePath(uri) {
|
|
11175
11139
|
let parsed = url.parse(uri);
|
|
@@ -11502,7 +11466,7 @@ function requireMain() {
|
|
|
11502
11466
|
value: true
|
|
11503
11467
|
});
|
|
11504
11468
|
exports.createConnection = exports.Files = void 0;
|
|
11505
|
-
const node_util_1 =
|
|
11469
|
+
const node_util_1 = require$$0$3;
|
|
11506
11470
|
const Is = requireIs$2();
|
|
11507
11471
|
const server_1 = requireServer();
|
|
11508
11472
|
const fm = requireFiles();
|
|
@@ -11791,6 +11755,8 @@ var LogLevel;
|
|
|
11791
11755
|
})(LogLevel || (LogLevel = {}));
|
|
11792
11756
|
|
|
11793
11757
|
class LspClientLogger {
|
|
11758
|
+
client;
|
|
11759
|
+
level;
|
|
11794
11760
|
constructor(client, level) {
|
|
11795
11761
|
this.client = client;
|
|
11796
11762
|
this.level = level;
|
|
@@ -11851,6 +11817,8 @@ class LspClientLogger {
|
|
|
11851
11817
|
}
|
|
11852
11818
|
|
|
11853
11819
|
class PrefixingLogger {
|
|
11820
|
+
logger;
|
|
11821
|
+
prefix;
|
|
11854
11822
|
constructor(logger, prefix) {
|
|
11855
11823
|
this.logger = logger;
|
|
11856
11824
|
this.prefix = prefix;
|
|
@@ -11936,7 +11904,7 @@ var hasRequiredPolyfills;
|
|
|
11936
11904
|
function requirePolyfills() {
|
|
11937
11905
|
if (hasRequiredPolyfills) return polyfills;
|
|
11938
11906
|
hasRequiredPolyfills = 1;
|
|
11939
|
-
var constants = require$$0$
|
|
11907
|
+
var constants = require$$0$4;
|
|
11940
11908
|
var origCwd = process.cwd;
|
|
11941
11909
|
var cwd = null;
|
|
11942
11910
|
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
@@ -12208,7 +12176,7 @@ var hasRequiredLegacyStreams;
|
|
|
12208
12176
|
function requireLegacyStreams() {
|
|
12209
12177
|
if (hasRequiredLegacyStreams) return legacyStreams;
|
|
12210
12178
|
hasRequiredLegacyStreams = 1;
|
|
12211
|
-
var Stream = require$$0$
|
|
12179
|
+
var Stream = require$$0$5.Stream;
|
|
12212
12180
|
legacyStreams = legacy;
|
|
12213
12181
|
function legacy(fs) {
|
|
12214
12182
|
return {
|
|
@@ -12332,11 +12300,11 @@ var hasRequiredGracefulFs;
|
|
|
12332
12300
|
function requireGracefulFs() {
|
|
12333
12301
|
if (hasRequiredGracefulFs) return gracefulFs;
|
|
12334
12302
|
hasRequiredGracefulFs = 1;
|
|
12335
|
-
var fs = require$$
|
|
12303
|
+
var fs = require$$2$1;
|
|
12336
12304
|
var polyfills = requirePolyfills();
|
|
12337
12305
|
var legacy = requireLegacyStreams();
|
|
12338
12306
|
var clone = requireClone();
|
|
12339
|
-
var util = require$$0;
|
|
12307
|
+
var util = require$$0$1;
|
|
12340
12308
|
var gracefulQueue;
|
|
12341
12309
|
var previousSymbol;
|
|
12342
12310
|
if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
|
|
@@ -12735,7 +12703,7 @@ var hasRequiredUtils$1;
|
|
|
12735
12703
|
function requireUtils$1() {
|
|
12736
12704
|
if (hasRequiredUtils$1) return utils$1;
|
|
12737
12705
|
hasRequiredUtils$1 = 1;
|
|
12738
|
-
const path = require$$1;
|
|
12706
|
+
const path = require$$1$1;
|
|
12739
12707
|
utils$1.checkPath = function checkPath(pth) {
|
|
12740
12708
|
if (process.platform === 'win32') {
|
|
12741
12709
|
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
|
|
@@ -12834,24 +12802,39 @@ function requireUtimes() {
|
|
|
12834
12802
|
const u = requireUniversalify().fromPromise;
|
|
12835
12803
|
async function utimesMillis(path, atime, mtime) {
|
|
12836
12804
|
const fd = await fs.open(path, 'r+');
|
|
12837
|
-
let
|
|
12805
|
+
let error = null;
|
|
12838
12806
|
try {
|
|
12839
12807
|
await fs.futimes(fd, atime, mtime);
|
|
12808
|
+
} catch (futimesErr) {
|
|
12809
|
+
error = futimesErr;
|
|
12840
12810
|
} finally {
|
|
12841
12811
|
try {
|
|
12842
12812
|
await fs.close(fd);
|
|
12843
|
-
} catch (
|
|
12844
|
-
|
|
12813
|
+
} catch (closeErr) {
|
|
12814
|
+
if (!error) error = closeErr;
|
|
12845
12815
|
}
|
|
12846
12816
|
}
|
|
12847
|
-
if (
|
|
12848
|
-
throw
|
|
12817
|
+
if (error) {
|
|
12818
|
+
throw error;
|
|
12849
12819
|
}
|
|
12850
12820
|
}
|
|
12851
12821
|
function utimesMillisSync(path, atime, mtime) {
|
|
12852
12822
|
const fd = fs.openSync(path, 'r+');
|
|
12853
|
-
|
|
12854
|
-
|
|
12823
|
+
let error = null;
|
|
12824
|
+
try {
|
|
12825
|
+
fs.futimesSync(fd, atime, mtime);
|
|
12826
|
+
} catch (futimesErr) {
|
|
12827
|
+
error = futimesErr;
|
|
12828
|
+
} finally {
|
|
12829
|
+
try {
|
|
12830
|
+
fs.closeSync(fd);
|
|
12831
|
+
} catch (closeErr) {
|
|
12832
|
+
if (!error) error = closeErr;
|
|
12833
|
+
}
|
|
12834
|
+
}
|
|
12835
|
+
if (error) {
|
|
12836
|
+
throw error;
|
|
12837
|
+
}
|
|
12855
12838
|
}
|
|
12856
12839
|
utimes = {
|
|
12857
12840
|
utimesMillis: u(utimesMillis),
|
|
@@ -12868,7 +12851,7 @@ function requireStat() {
|
|
|
12868
12851
|
if (hasRequiredStat) return stat;
|
|
12869
12852
|
hasRequiredStat = 1;
|
|
12870
12853
|
const fs = requireFs();
|
|
12871
|
-
const path = require$$1;
|
|
12854
|
+
const path = require$$1$1;
|
|
12872
12855
|
const u = requireUniversalify().fromPromise;
|
|
12873
12856
|
function getStats(src, dest, opts) {
|
|
12874
12857
|
const statFunc = opts.dereference ? file => fs.stat(file, {
|
|
@@ -13054,7 +13037,7 @@ function requireCopy$1() {
|
|
|
13054
13037
|
if (hasRequiredCopy$1) return copy_1;
|
|
13055
13038
|
hasRequiredCopy$1 = 1;
|
|
13056
13039
|
const fs = requireFs();
|
|
13057
|
-
const path = require$$1;
|
|
13040
|
+
const path = require$$1$1;
|
|
13058
13041
|
const {mkdirs: mkdirs} = requireMkdirs();
|
|
13059
13042
|
const {pathExists: pathExists} = requirePathExists();
|
|
13060
13043
|
const {utimesMillis: utimesMillis} = requireUtimes();
|
|
@@ -13158,11 +13141,13 @@ function requireCopy$1() {
|
|
|
13158
13141
|
if (opts.dereference) {
|
|
13159
13142
|
resolvedDest = path.resolve(process.cwd(), resolvedDest);
|
|
13160
13143
|
}
|
|
13161
|
-
if (
|
|
13162
|
-
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13144
|
+
if (resolvedSrc !== resolvedDest) {
|
|
13145
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
13146
|
+
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
13147
|
+
}
|
|
13148
|
+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
13149
|
+
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
13150
|
+
}
|
|
13166
13151
|
}
|
|
13167
13152
|
await fs.unlink(dest);
|
|
13168
13153
|
return fs.symlink(resolvedSrc, dest);
|
|
@@ -13179,7 +13164,7 @@ function requireCopySync() {
|
|
|
13179
13164
|
if (hasRequiredCopySync) return copySync_1;
|
|
13180
13165
|
hasRequiredCopySync = 1;
|
|
13181
13166
|
const fs = requireGracefulFs();
|
|
13182
|
-
const path = require$$1;
|
|
13167
|
+
const path = require$$1$1;
|
|
13183
13168
|
const mkdirsSync = requireMkdirs().mkdirsSync;
|
|
13184
13169
|
const utimesMillisSync = requireUtimes().utimesMillisSync;
|
|
13185
13170
|
const stat = requireStat();
|
|
@@ -13287,11 +13272,13 @@ function requireCopySync() {
|
|
|
13287
13272
|
if (opts.dereference) {
|
|
13288
13273
|
resolvedDest = path.resolve(process.cwd(), resolvedDest);
|
|
13289
13274
|
}
|
|
13290
|
-
if (
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13275
|
+
if (resolvedSrc !== resolvedDest) {
|
|
13276
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
13277
|
+
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
13278
|
+
}
|
|
13279
|
+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
13280
|
+
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
13281
|
+
}
|
|
13295
13282
|
}
|
|
13296
13283
|
return copyLink(resolvedSrc, dest);
|
|
13297
13284
|
}
|
|
@@ -13356,7 +13343,7 @@ function requireEmpty() {
|
|
|
13356
13343
|
hasRequiredEmpty = 1;
|
|
13357
13344
|
const u = requireUniversalify().fromPromise;
|
|
13358
13345
|
const fs = requireFs();
|
|
13359
|
-
const path = require$$1;
|
|
13346
|
+
const path = require$$1$1;
|
|
13360
13347
|
const mkdir = requireMkdirs();
|
|
13361
13348
|
const remove = requireRemove();
|
|
13362
13349
|
const emptyDir = u(async function emptyDir(dir) {
|
|
@@ -13397,7 +13384,7 @@ function requireFile() {
|
|
|
13397
13384
|
if (hasRequiredFile) return file$1;
|
|
13398
13385
|
hasRequiredFile = 1;
|
|
13399
13386
|
const u = requireUniversalify().fromPromise;
|
|
13400
|
-
const path = require$$1;
|
|
13387
|
+
const path = require$$1$1;
|
|
13401
13388
|
const fs = requireFs();
|
|
13402
13389
|
const mkdir = requireMkdirs();
|
|
13403
13390
|
async function createFile(file) {
|
|
@@ -13456,7 +13443,7 @@ function requireLink() {
|
|
|
13456
13443
|
if (hasRequiredLink) return link;
|
|
13457
13444
|
hasRequiredLink = 1;
|
|
13458
13445
|
const u = requireUniversalify().fromPromise;
|
|
13459
|
-
const path = require$$1;
|
|
13446
|
+
const path = require$$1$1;
|
|
13460
13447
|
const fs = requireFs();
|
|
13461
13448
|
const mkdir = requireMkdirs();
|
|
13462
13449
|
const {pathExists: pathExists} = requirePathExists();
|
|
@@ -13464,11 +13451,15 @@ function requireLink() {
|
|
|
13464
13451
|
async function createLink(srcpath, dstpath) {
|
|
13465
13452
|
let dstStat;
|
|
13466
13453
|
try {
|
|
13467
|
-
dstStat = await fs.lstat(dstpath
|
|
13454
|
+
dstStat = await fs.lstat(dstpath, {
|
|
13455
|
+
bigint: true
|
|
13456
|
+
});
|
|
13468
13457
|
} catch {}
|
|
13469
13458
|
let srcStat;
|
|
13470
13459
|
try {
|
|
13471
|
-
srcStat = await fs.lstat(srcpath
|
|
13460
|
+
srcStat = await fs.lstat(srcpath, {
|
|
13461
|
+
bigint: true
|
|
13462
|
+
});
|
|
13472
13463
|
} catch (err) {
|
|
13473
13464
|
err.message = err.message.replace('lstat', 'ensureLink');
|
|
13474
13465
|
throw err;
|
|
@@ -13484,10 +13475,14 @@ function requireLink() {
|
|
|
13484
13475
|
function createLinkSync(srcpath, dstpath) {
|
|
13485
13476
|
let dstStat;
|
|
13486
13477
|
try {
|
|
13487
|
-
dstStat = fs.lstatSync(dstpath
|
|
13478
|
+
dstStat = fs.lstatSync(dstpath, {
|
|
13479
|
+
bigint: true
|
|
13480
|
+
});
|
|
13488
13481
|
} catch {}
|
|
13489
13482
|
try {
|
|
13490
|
-
const srcStat = fs.lstatSync(srcpath
|
|
13483
|
+
const srcStat = fs.lstatSync(srcpath, {
|
|
13484
|
+
bigint: true
|
|
13485
|
+
});
|
|
13491
13486
|
if (dstStat && areIdentical(srcStat, dstStat)) return;
|
|
13492
13487
|
} catch (err) {
|
|
13493
13488
|
err.message = err.message.replace('lstat', 'ensureLink');
|
|
@@ -13513,7 +13508,7 @@ var hasRequiredSymlinkPaths;
|
|
|
13513
13508
|
function requireSymlinkPaths() {
|
|
13514
13509
|
if (hasRequiredSymlinkPaths) return symlinkPaths_1;
|
|
13515
13510
|
hasRequiredSymlinkPaths = 1;
|
|
13516
|
-
const path = require$$1;
|
|
13511
|
+
const path = require$$1$1;
|
|
13517
13512
|
const fs = requireFs();
|
|
13518
13513
|
const {pathExists: pathExists} = requirePathExists();
|
|
13519
13514
|
const u = requireUniversalify().fromPromise;
|
|
@@ -13626,7 +13621,7 @@ function requireSymlink() {
|
|
|
13626
13621
|
if (hasRequiredSymlink) return symlink;
|
|
13627
13622
|
hasRequiredSymlink = 1;
|
|
13628
13623
|
const u = requireUniversalify().fromPromise;
|
|
13629
|
-
const path = require$$1;
|
|
13624
|
+
const path = require$$1$1;
|
|
13630
13625
|
const fs = requireFs();
|
|
13631
13626
|
const {mkdirs: mkdirs, mkdirsSync: mkdirsSync} = requireMkdirs();
|
|
13632
13627
|
const {symlinkPaths: symlinkPaths, symlinkPathsSync: symlinkPathsSync} = requireSymlinkPaths();
|
|
@@ -13639,7 +13634,27 @@ function requireSymlink() {
|
|
|
13639
13634
|
stats = await fs.lstat(dstpath);
|
|
13640
13635
|
} catch {}
|
|
13641
13636
|
if (stats && stats.isSymbolicLink()) {
|
|
13642
|
-
|
|
13637
|
+
let srcStat;
|
|
13638
|
+
if (path.isAbsolute(srcpath)) {
|
|
13639
|
+
srcStat = await fs.stat(srcpath, {
|
|
13640
|
+
bigint: true
|
|
13641
|
+
});
|
|
13642
|
+
} else {
|
|
13643
|
+
const dstdir = path.dirname(dstpath);
|
|
13644
|
+
const relativeToDst = path.join(dstdir, srcpath);
|
|
13645
|
+
try {
|
|
13646
|
+
srcStat = await fs.stat(relativeToDst, {
|
|
13647
|
+
bigint: true
|
|
13648
|
+
});
|
|
13649
|
+
} catch {
|
|
13650
|
+
srcStat = await fs.stat(srcpath, {
|
|
13651
|
+
bigint: true
|
|
13652
|
+
});
|
|
13653
|
+
}
|
|
13654
|
+
}
|
|
13655
|
+
const dstStat = await fs.stat(dstpath, {
|
|
13656
|
+
bigint: true
|
|
13657
|
+
});
|
|
13643
13658
|
if (areIdentical(srcStat, dstStat)) return;
|
|
13644
13659
|
}
|
|
13645
13660
|
const relative = await symlinkPaths(srcpath, dstpath);
|
|
@@ -13657,8 +13672,27 @@ function requireSymlink() {
|
|
|
13657
13672
|
stats = fs.lstatSync(dstpath);
|
|
13658
13673
|
} catch {}
|
|
13659
13674
|
if (stats && stats.isSymbolicLink()) {
|
|
13660
|
-
|
|
13661
|
-
|
|
13675
|
+
let srcStat;
|
|
13676
|
+
if (path.isAbsolute(srcpath)) {
|
|
13677
|
+
srcStat = fs.statSync(srcpath, {
|
|
13678
|
+
bigint: true
|
|
13679
|
+
});
|
|
13680
|
+
} else {
|
|
13681
|
+
const dstdir = path.dirname(dstpath);
|
|
13682
|
+
const relativeToDst = path.join(dstdir, srcpath);
|
|
13683
|
+
try {
|
|
13684
|
+
srcStat = fs.statSync(relativeToDst, {
|
|
13685
|
+
bigint: true
|
|
13686
|
+
});
|
|
13687
|
+
} catch {
|
|
13688
|
+
srcStat = fs.statSync(srcpath, {
|
|
13689
|
+
bigint: true
|
|
13690
|
+
});
|
|
13691
|
+
}
|
|
13692
|
+
}
|
|
13693
|
+
const dstStat = fs.statSync(dstpath, {
|
|
13694
|
+
bigint: true
|
|
13695
|
+
});
|
|
13662
13696
|
if (areIdentical(srcStat, dstStat)) return;
|
|
13663
13697
|
}
|
|
13664
13698
|
const relative = symlinkPathsSync(srcpath, dstpath);
|
|
@@ -13714,6 +13748,9 @@ function requireUtils() {
|
|
|
13714
13748
|
function stringify(obj, {EOL: EOL = '\n', finalEOL: finalEOL = true, replacer: replacer = null, spaces: spaces} = {}) {
|
|
13715
13749
|
const EOF = finalEOL ? EOL : '';
|
|
13716
13750
|
const str = JSON.stringify(obj, replacer, spaces);
|
|
13751
|
+
if (str === undefined) {
|
|
13752
|
+
throw new TypeError(`Converting ${typeof obj} value to JSON is not supported`);
|
|
13753
|
+
}
|
|
13717
13754
|
return str.replace(/\n/g, EOL) + EOF;
|
|
13718
13755
|
}
|
|
13719
13756
|
function stripBom(content) {
|
|
@@ -13738,7 +13775,7 @@ function requireJsonfile$1() {
|
|
|
13738
13775
|
try {
|
|
13739
13776
|
_fs = requireGracefulFs();
|
|
13740
13777
|
} catch (_) {
|
|
13741
|
-
_fs = require$$
|
|
13778
|
+
_fs = require$$2$1;
|
|
13742
13779
|
}
|
|
13743
13780
|
const universalify = requireUniversalify();
|
|
13744
13781
|
const {stringify: stringify, stripBom: stripBom} = requireUtils();
|
|
@@ -13833,7 +13870,7 @@ function requireOutputFile() {
|
|
|
13833
13870
|
hasRequiredOutputFile = 1;
|
|
13834
13871
|
const u = requireUniversalify().fromPromise;
|
|
13835
13872
|
const fs = requireFs();
|
|
13836
|
-
const path = require$$1;
|
|
13873
|
+
const path = require$$1$1;
|
|
13837
13874
|
const mkdir = requireMkdirs();
|
|
13838
13875
|
const pathExists = requirePathExists().pathExists;
|
|
13839
13876
|
async function outputFile(file, data, encoding = 'utf-8') {
|
|
@@ -13920,7 +13957,7 @@ function requireMove$1() {
|
|
|
13920
13957
|
if (hasRequiredMove$1) return move_1;
|
|
13921
13958
|
hasRequiredMove$1 = 1;
|
|
13922
13959
|
const fs = requireFs();
|
|
13923
|
-
const path = require$$1;
|
|
13960
|
+
const path = require$$1$1;
|
|
13924
13961
|
const {copy: copy} = requireCopy();
|
|
13925
13962
|
const {remove: remove} = requireRemove();
|
|
13926
13963
|
const {mkdirp: mkdirp} = requireMkdirs();
|
|
@@ -13975,7 +14012,7 @@ function requireMoveSync() {
|
|
|
13975
14012
|
if (hasRequiredMoveSync) return moveSync_1;
|
|
13976
14013
|
hasRequiredMoveSync = 1;
|
|
13977
14014
|
const fs = requireGracefulFs();
|
|
13978
|
-
const path = require$$1;
|
|
14015
|
+
const path = require$$1$1;
|
|
13979
14016
|
const copySync = requireCopy().copySync;
|
|
13980
14017
|
const removeSync = requireRemove().removeSync;
|
|
13981
14018
|
const mkdirpSync = requireMkdirs().mkdirpSync;
|
|
@@ -14815,6 +14852,7 @@ var CommandTypes;
|
|
|
14815
14852
|
CommandTypes['ProvideCallHierarchyIncomingCalls'] = 'provideCallHierarchyIncomingCalls';
|
|
14816
14853
|
CommandTypes['ProvideCallHierarchyOutgoingCalls'] = 'provideCallHierarchyOutgoingCalls';
|
|
14817
14854
|
CommandTypes['ProvideInlayHints'] = 'provideInlayHints';
|
|
14855
|
+
CommandTypes['WatchChange'] = 'watchChange';
|
|
14818
14856
|
})(CommandTypes || (CommandTypes = {}));
|
|
14819
14857
|
|
|
14820
14858
|
var HighlightSpanKind;
|
|
@@ -14963,6 +15001,8 @@ var ScriptTarget;
|
|
|
14963
15001
|
ScriptTarget['ES2020'] = 'es2020';
|
|
14964
15002
|
ScriptTarget['ES2021'] = 'es2021';
|
|
14965
15003
|
ScriptTarget['ES2022'] = 'es2022';
|
|
15004
|
+
ScriptTarget['ES2023'] = 'es2023';
|
|
15005
|
+
ScriptTarget['ES2024'] = 'es2024';
|
|
14966
15006
|
ScriptTarget['ESNext'] = 'esnext';
|
|
14967
15007
|
ScriptTarget['JSON'] = 'json';
|
|
14968
15008
|
ScriptTarget['Latest'] = 'esnext';
|
|
@@ -15006,27 +15046,39 @@ var OrganizeImportsMode;
|
|
|
15006
15046
|
OrganizeImportsMode['RemoveUnused'] = 'RemoveUnused';
|
|
15007
15047
|
})(OrganizeImportsMode || (OrganizeImportsMode = {}));
|
|
15008
15048
|
|
|
15009
|
-
|
|
15010
|
-
|
|
15011
|
-
|
|
15012
|
-
|
|
15013
|
-
|
|
15014
|
-
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
|
|
15020
|
-
|
|
15021
|
-
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
15026
|
-
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
|
|
15049
|
+
var EventName;
|
|
15050
|
+
|
|
15051
|
+
(function(EventName) {
|
|
15052
|
+
EventName['syntaxDiag'] = 'syntaxDiag';
|
|
15053
|
+
EventName['semanticDiag'] = 'semanticDiag';
|
|
15054
|
+
EventName['suggestionDiag'] = 'suggestionDiag';
|
|
15055
|
+
EventName['configFileDiag'] = 'configFileDiag';
|
|
15056
|
+
EventName['telemetry'] = 'telemetry';
|
|
15057
|
+
EventName['projectLanguageServiceState'] = 'projectLanguageServiceState';
|
|
15058
|
+
EventName['projectsUpdatedInBackground'] = 'projectsUpdatedInBackground';
|
|
15059
|
+
EventName['beginInstallTypes'] = 'beginInstallTypes';
|
|
15060
|
+
EventName['endInstallTypes'] = 'endInstallTypes';
|
|
15061
|
+
EventName['typesInstallerInitializationFailed'] = 'typesInstallerInitializationFailed';
|
|
15062
|
+
EventName['surveyReady'] = 'surveyReady';
|
|
15063
|
+
EventName['projectLoadingStart'] = 'projectLoadingStart';
|
|
15064
|
+
EventName['projectLoadingFinish'] = 'projectLoadingFinish';
|
|
15065
|
+
EventName['createFileWatcher'] = 'createFileWatcher';
|
|
15066
|
+
EventName['createDirectoryWatcher'] = 'createDirectoryWatcher';
|
|
15067
|
+
EventName['closeFileWatcher'] = 'closeFileWatcher';
|
|
15068
|
+
})(EventName || (EventName = {}));
|
|
15069
|
+
|
|
15070
|
+
class KindModifiers {
|
|
15071
|
+
static optional='optional';
|
|
15072
|
+
static deprecated='deprecated';
|
|
15073
|
+
static color='color';
|
|
15074
|
+
static dtsFile='.d.ts';
|
|
15075
|
+
static tsFile='.ts';
|
|
15076
|
+
static tsxFile='.tsx';
|
|
15077
|
+
static jsFile='.js';
|
|
15078
|
+
static jsxFile='.jsx';
|
|
15079
|
+
static jsonFile='.json';
|
|
15080
|
+
static fileExtensionKindModifiers=[ KindModifiers.dtsFile, KindModifiers.tsFile, KindModifiers.tsxFile, KindModifiers.jsFile, KindModifiers.jsxFile, KindModifiers.jsonFile ];
|
|
15081
|
+
}
|
|
15030
15082
|
|
|
15031
15083
|
const SYMBOL_DISPLAY_PART_KIND_MAP = {
|
|
15032
15084
|
aliasName: 0,
|
|
@@ -15071,9 +15123,10 @@ var ServerResponse;
|
|
|
15071
15123
|
|
|
15072
15124
|
(function(ServerResponse) {
|
|
15073
15125
|
class Cancelled {
|
|
15126
|
+
reason;
|
|
15127
|
+
type='cancelled';
|
|
15074
15128
|
constructor(reason) {
|
|
15075
15129
|
this.reason = reason;
|
|
15076
|
-
this.type = 'cancelled';
|
|
15077
15130
|
}
|
|
15078
15131
|
}
|
|
15079
15132
|
ServerResponse.Cancelled = Cancelled;
|
|
@@ -15094,6 +15147,7 @@ var ClientCapability;
|
|
|
15094
15147
|
})(ClientCapability || (ClientCapability = {}));
|
|
15095
15148
|
|
|
15096
15149
|
class ClientCapabilities {
|
|
15150
|
+
capabilities;
|
|
15097
15151
|
constructor(...capabilities) {
|
|
15098
15152
|
this.capabilities = new Set(capabilities);
|
|
15099
15153
|
}
|
|
@@ -16016,6 +16070,49 @@ function requireCoerce() {
|
|
|
16016
16070
|
return coerce_1;
|
|
16017
16071
|
}
|
|
16018
16072
|
|
|
16073
|
+
var truncate_1;
|
|
16074
|
+
|
|
16075
|
+
var hasRequiredTruncate;
|
|
16076
|
+
|
|
16077
|
+
function requireTruncate() {
|
|
16078
|
+
if (hasRequiredTruncate) return truncate_1;
|
|
16079
|
+
hasRequiredTruncate = 1;
|
|
16080
|
+
const parse = requireParse();
|
|
16081
|
+
const constants = requireConstants();
|
|
16082
|
+
const SemVer = requireSemver$1();
|
|
16083
|
+
const truncate = (version, truncation, options) => {
|
|
16084
|
+
if (!constants.RELEASE_TYPES.includes(truncation)) {
|
|
16085
|
+
return null;
|
|
16086
|
+
}
|
|
16087
|
+
const clonedVersion = cloneInputVersion(version, options);
|
|
16088
|
+
return clonedVersion && doTruncation(clonedVersion, truncation);
|
|
16089
|
+
};
|
|
16090
|
+
const cloneInputVersion = (version, options) => {
|
|
16091
|
+
const versionStringToParse = version instanceof SemVer ? version.version : version;
|
|
16092
|
+
return parse(versionStringToParse, options);
|
|
16093
|
+
};
|
|
16094
|
+
const doTruncation = (version, truncation) => {
|
|
16095
|
+
if (isPrerelease(truncation)) {
|
|
16096
|
+
return version.version;
|
|
16097
|
+
}
|
|
16098
|
+
version.prerelease = [];
|
|
16099
|
+
switch (truncation) {
|
|
16100
|
+
case 'major':
|
|
16101
|
+
version.minor = 0;
|
|
16102
|
+
version.patch = 0;
|
|
16103
|
+
break;
|
|
16104
|
+
|
|
16105
|
+
case 'minor':
|
|
16106
|
+
version.patch = 0;
|
|
16107
|
+
break;
|
|
16108
|
+
}
|
|
16109
|
+
return version.format();
|
|
16110
|
+
};
|
|
16111
|
+
const isPrerelease = type => type.startsWith('pre');
|
|
16112
|
+
truncate_1 = truncate;
|
|
16113
|
+
return truncate_1;
|
|
16114
|
+
}
|
|
16115
|
+
|
|
16019
16116
|
var lrucache;
|
|
16020
16117
|
|
|
16021
16118
|
var hasRequiredLrucache;
|
|
@@ -17080,6 +17177,7 @@ function requireSemver() {
|
|
|
17080
17177
|
const lte = requireLte();
|
|
17081
17178
|
const cmp = requireCmp();
|
|
17082
17179
|
const coerce = requireCoerce();
|
|
17180
|
+
const truncate = requireTruncate();
|
|
17083
17181
|
const Comparator = requireComparator();
|
|
17084
17182
|
const Range = requireRange();
|
|
17085
17183
|
const satisfies = requireSatisfies();
|
|
@@ -17118,6 +17216,7 @@ function requireSemver() {
|
|
|
17118
17216
|
lte: lte,
|
|
17119
17217
|
cmp: cmp,
|
|
17120
17218
|
coerce: coerce,
|
|
17219
|
+
truncate: truncate,
|
|
17121
17220
|
Comparator: Comparator,
|
|
17122
17221
|
Range: Range,
|
|
17123
17222
|
satisfies: satisfies,
|
|
@@ -17149,9 +17248,38 @@ var semverExports = requireSemver();
|
|
|
17149
17248
|
const semver = getDefaultExportFromCjs(semverExports);
|
|
17150
17249
|
|
|
17151
17250
|
class API {
|
|
17251
|
+
displayName;
|
|
17252
|
+
version;
|
|
17253
|
+
fullVersionString;
|
|
17152
17254
|
static fromSimpleString(value) {
|
|
17153
17255
|
return new API(value, value, value);
|
|
17154
17256
|
}
|
|
17257
|
+
static defaultVersion=API.fromSimpleString('1.0.0');
|
|
17258
|
+
static v300=API.fromSimpleString('3.0.0');
|
|
17259
|
+
static v310=API.fromSimpleString('3.1.0');
|
|
17260
|
+
static v314=API.fromSimpleString('3.1.4');
|
|
17261
|
+
static v320=API.fromSimpleString('3.2.0');
|
|
17262
|
+
static v333=API.fromSimpleString('3.3.3');
|
|
17263
|
+
static v340=API.fromSimpleString('3.4.0');
|
|
17264
|
+
static v345=API.fromSimpleString('3.4.5');
|
|
17265
|
+
static v350=API.fromSimpleString('3.5.0');
|
|
17266
|
+
static v380=API.fromSimpleString('3.8.0');
|
|
17267
|
+
static v381=API.fromSimpleString('3.8.1');
|
|
17268
|
+
static v390=API.fromSimpleString('3.9.0');
|
|
17269
|
+
static v400=API.fromSimpleString('4.0.0');
|
|
17270
|
+
static v401=API.fromSimpleString('4.0.1');
|
|
17271
|
+
static v420=API.fromSimpleString('4.2.0');
|
|
17272
|
+
static v430=API.fromSimpleString('4.3.0');
|
|
17273
|
+
static v440=API.fromSimpleString('4.4.0');
|
|
17274
|
+
static v460=API.fromSimpleString('4.6.0');
|
|
17275
|
+
static v470=API.fromSimpleString('4.7.0');
|
|
17276
|
+
static v480=API.fromSimpleString('4.8.0');
|
|
17277
|
+
static v490=API.fromSimpleString('4.9.0');
|
|
17278
|
+
static v500=API.fromSimpleString('5.0.0');
|
|
17279
|
+
static v510=API.fromSimpleString('5.1.0');
|
|
17280
|
+
static v520=API.fromSimpleString('5.2.0');
|
|
17281
|
+
static v540=API.fromSimpleString('5.4.0');
|
|
17282
|
+
static v544=API.fromSimpleString('5.4.4');
|
|
17155
17283
|
static fromVersionString(versionString) {
|
|
17156
17284
|
let version = semver.valid(versionString);
|
|
17157
17285
|
if (!version) {
|
|
@@ -17179,56 +17307,6 @@ class API {
|
|
|
17179
17307
|
}
|
|
17180
17308
|
}
|
|
17181
17309
|
|
|
17182
|
-
API.defaultVersion = API.fromSimpleString('1.0.0');
|
|
17183
|
-
|
|
17184
|
-
API.v300 = API.fromSimpleString('3.0.0');
|
|
17185
|
-
|
|
17186
|
-
API.v310 = API.fromSimpleString('3.1.0');
|
|
17187
|
-
|
|
17188
|
-
API.v314 = API.fromSimpleString('3.1.4');
|
|
17189
|
-
|
|
17190
|
-
API.v320 = API.fromSimpleString('3.2.0');
|
|
17191
|
-
|
|
17192
|
-
API.v333 = API.fromSimpleString('3.3.3');
|
|
17193
|
-
|
|
17194
|
-
API.v340 = API.fromSimpleString('3.4.0');
|
|
17195
|
-
|
|
17196
|
-
API.v345 = API.fromSimpleString('3.4.5');
|
|
17197
|
-
|
|
17198
|
-
API.v350 = API.fromSimpleString('3.5.0');
|
|
17199
|
-
|
|
17200
|
-
API.v380 = API.fromSimpleString('3.8.0');
|
|
17201
|
-
|
|
17202
|
-
API.v381 = API.fromSimpleString('3.8.1');
|
|
17203
|
-
|
|
17204
|
-
API.v390 = API.fromSimpleString('3.9.0');
|
|
17205
|
-
|
|
17206
|
-
API.v400 = API.fromSimpleString('4.0.0');
|
|
17207
|
-
|
|
17208
|
-
API.v401 = API.fromSimpleString('4.0.1');
|
|
17209
|
-
|
|
17210
|
-
API.v420 = API.fromSimpleString('4.2.0');
|
|
17211
|
-
|
|
17212
|
-
API.v430 = API.fromSimpleString('4.3.0');
|
|
17213
|
-
|
|
17214
|
-
API.v440 = API.fromSimpleString('4.4.0');
|
|
17215
|
-
|
|
17216
|
-
API.v460 = API.fromSimpleString('4.6.0');
|
|
17217
|
-
|
|
17218
|
-
API.v470 = API.fromSimpleString('4.7.0');
|
|
17219
|
-
|
|
17220
|
-
API.v480 = API.fromSimpleString('4.8.0');
|
|
17221
|
-
|
|
17222
|
-
API.v490 = API.fromSimpleString('4.9.0');
|
|
17223
|
-
|
|
17224
|
-
API.v500 = API.fromSimpleString('5.0.0');
|
|
17225
|
-
|
|
17226
|
-
API.v510 = API.fromSimpleString('5.1.0');
|
|
17227
|
-
|
|
17228
|
-
API.v520 = API.fromSimpleString('5.2.0');
|
|
17229
|
-
|
|
17230
|
-
API.v540 = API.fromSimpleString('5.4.0');
|
|
17231
|
-
|
|
17232
17310
|
function equals$1(a, b, itemEquals = (a, b) => a === b) {
|
|
17233
17311
|
if (a === b) {
|
|
17234
17312
|
return true;
|
|
@@ -17244,6 +17322,11 @@ function coalesce(array) {
|
|
|
17244
17322
|
}
|
|
17245
17323
|
|
|
17246
17324
|
class Delayer {
|
|
17325
|
+
defaultDelay;
|
|
17326
|
+
timeout;
|
|
17327
|
+
completionPromise;
|
|
17328
|
+
onSuccess;
|
|
17329
|
+
task;
|
|
17247
17330
|
constructor(defaultDelay) {
|
|
17248
17331
|
this.defaultDelay = defaultDelay;
|
|
17249
17332
|
this.timeout = null;
|
|
@@ -17310,7 +17393,7 @@ const getRootTempDir = (() => {
|
|
|
17310
17393
|
const getInstanceTempDir = (() => {
|
|
17311
17394
|
let dir;
|
|
17312
17395
|
return () => {
|
|
17313
|
-
dir
|
|
17396
|
+
dir ??= path__default.join(getRootTempDir(), makeRandomHexString(20));
|
|
17314
17397
|
if (!fs$2.existsSync(dir)) {
|
|
17315
17398
|
fs$2.mkdirSync(dir);
|
|
17316
17399
|
}
|
|
@@ -17345,10 +17428,18 @@ const onCaseInsensitiveFileSystem = (() => {
|
|
|
17345
17428
|
})();
|
|
17346
17429
|
|
|
17347
17430
|
class ResourceMap {
|
|
17431
|
+
_normalizePath;
|
|
17432
|
+
config;
|
|
17433
|
+
static defaultPathNormalizer=resource => {
|
|
17434
|
+
if (resource.scheme === 'file') {
|
|
17435
|
+
return resource.fsPath;
|
|
17436
|
+
}
|
|
17437
|
+
return resource.toString(true);
|
|
17438
|
+
};
|
|
17439
|
+
_map=new Map;
|
|
17348
17440
|
constructor(_normalizePath = ResourceMap.defaultPathNormalizer, config) {
|
|
17349
17441
|
this._normalizePath = _normalizePath;
|
|
17350
17442
|
this.config = config;
|
|
17351
|
-
this._map = new Map;
|
|
17352
17443
|
}
|
|
17353
17444
|
get size() {
|
|
17354
17445
|
return this._map.size;
|
|
@@ -17410,13 +17501,6 @@ class ResourceMap {
|
|
|
17410
17501
|
}
|
|
17411
17502
|
}
|
|
17412
17503
|
|
|
17413
|
-
ResourceMap.defaultPathNormalizer = resource => {
|
|
17414
|
-
if (resource.scheme === 'file') {
|
|
17415
|
-
return resource.fsPath;
|
|
17416
|
-
}
|
|
17417
|
-
return resource.toString(true);
|
|
17418
|
-
};
|
|
17419
|
-
|
|
17420
17504
|
function mode2ScriptKind(mode) {
|
|
17421
17505
|
switch (mode) {
|
|
17422
17506
|
case typescript:
|
|
@@ -17464,14 +17548,16 @@ class PendingDiagnostics extends ResourceMap {
|
|
|
17464
17548
|
}
|
|
17465
17549
|
|
|
17466
17550
|
class GetErrRequest {
|
|
17551
|
+
client;
|
|
17552
|
+
files;
|
|
17467
17553
|
static executeGetErrRequest(client, files, onDone) {
|
|
17468
17554
|
return new GetErrRequest(client, files, onDone);
|
|
17469
17555
|
}
|
|
17556
|
+
_done=false;
|
|
17557
|
+
_token=new mainExports$2.CancellationTokenSource;
|
|
17470
17558
|
constructor(client, files, onDone) {
|
|
17471
17559
|
this.client = client;
|
|
17472
17560
|
this.files = files;
|
|
17473
|
-
this._done = false;
|
|
17474
|
-
this._token = new mainExports$2.CancellationTokenSource;
|
|
17475
17561
|
if (!this.isErrorReportingEnabled()) {
|
|
17476
17562
|
this._done = true;
|
|
17477
17563
|
setImmediate(onDone);
|
|
@@ -17518,6 +17604,9 @@ class GetErrRequest {
|
|
|
17518
17604
|
}
|
|
17519
17605
|
|
|
17520
17606
|
class LspDocument {
|
|
17607
|
+
_document;
|
|
17608
|
+
_uri;
|
|
17609
|
+
_filepath;
|
|
17521
17610
|
constructor(doc, filepath) {
|
|
17522
17611
|
const {uri: uri, languageId: languageId, version: version, text: text} = doc;
|
|
17523
17612
|
this._document = TextDocument.create(uri, languageId, version, text);
|
|
@@ -17585,12 +17674,17 @@ class LspDocument {
|
|
|
17585
17674
|
}
|
|
17586
17675
|
|
|
17587
17676
|
class LspDocuments {
|
|
17677
|
+
client;
|
|
17678
|
+
lspClient;
|
|
17679
|
+
_validateJavaScript=true;
|
|
17680
|
+
_validateTypeScript=true;
|
|
17681
|
+
modeIds=new Set;
|
|
17682
|
+
_files=[];
|
|
17683
|
+
documents=new Map;
|
|
17684
|
+
pendingDiagnostics;
|
|
17685
|
+
diagnosticDelayer;
|
|
17686
|
+
pendingGetErr;
|
|
17588
17687
|
constructor(client, lspClient, onCaseInsensitiveFileSystem) {
|
|
17589
|
-
this._validateJavaScript = true;
|
|
17590
|
-
this._validateTypeScript = true;
|
|
17591
|
-
this.modeIds = new Set;
|
|
17592
|
-
this._files = [];
|
|
17593
|
-
this.documents = new Map;
|
|
17594
17688
|
this.client = client;
|
|
17595
17689
|
this.lspClient = lspClient;
|
|
17596
17690
|
const pathNormalizer = path => this.client.toTsFilePath(path.toString());
|
|
@@ -17625,7 +17719,7 @@ class LspDocuments {
|
|
|
17625
17719
|
if (detectedLanguageId) {
|
|
17626
17720
|
this.lspClient.logMessage({
|
|
17627
17721
|
type: mainExports$2.MessageType.Warning,
|
|
17628
|
-
message: `Invalid
|
|
17722
|
+
message: `Invalid languageId "${textDocument.languageId}" provided for uri "${textDocument.uri}". Correcting to "${detectedLanguageId}"`
|
|
17629
17723
|
});
|
|
17630
17724
|
textDocument.languageId = detectedLanguageId;
|
|
17631
17725
|
} else {
|
|
@@ -17685,10 +17779,10 @@ class LspDocuments {
|
|
|
17685
17779
|
}
|
|
17686
17780
|
this.client.cancelInflightRequestsForResource(document.uri);
|
|
17687
17781
|
for (const change of params.contentChanges) {
|
|
17688
|
-
let line
|
|
17689
|
-
let offset
|
|
17690
|
-
let endLine
|
|
17691
|
-
let endOffset
|
|
17782
|
+
let line;
|
|
17783
|
+
let offset;
|
|
17784
|
+
let endLine;
|
|
17785
|
+
let endOffset;
|
|
17692
17786
|
if (mainExports$2.TextDocumentContentChangeEvent.isIncremental(change)) {
|
|
17693
17787
|
line = change.range.start.line + 1;
|
|
17694
17788
|
offset = change.range.start.character + 1;
|
|
@@ -17844,6 +17938,7 @@ var TypeScriptServerPlugin;
|
|
|
17844
17938
|
})(TypeScriptServerPlugin || (TypeScriptServerPlugin = {}));
|
|
17845
17939
|
|
|
17846
17940
|
class PluginManager {
|
|
17941
|
+
_plugins;
|
|
17847
17942
|
setPlugins(plugins) {
|
|
17848
17943
|
this._plugins = this.readPlugins(plugins);
|
|
17849
17944
|
}
|
|
@@ -17864,6 +17959,11 @@ class PluginManager {
|
|
|
17864
17959
|
}
|
|
17865
17960
|
|
|
17866
17961
|
class TypeScriptServerError extends Error {
|
|
17962
|
+
serverId;
|
|
17963
|
+
version;
|
|
17964
|
+
response;
|
|
17965
|
+
serverMessage;
|
|
17966
|
+
serverStack;
|
|
17867
17967
|
static create(serverId, version, response) {
|
|
17868
17968
|
const parsedResult = TypeScriptServerError.parseErrorText(response);
|
|
17869
17969
|
return new TypeScriptServerError(serverId, version, response, parsedResult?.message, parsedResult?.stack);
|
|
@@ -18027,25 +18127,78 @@ const temporaryDirectory$1 = await promises.realpath(os.tmpdir());
|
|
|
18027
18127
|
|
|
18028
18128
|
promisify$1(stream.pipeline);
|
|
18029
18129
|
|
|
18030
|
-
|
|
18130
|
+
function assertSafePathComponent(pathComponent) {
|
|
18131
|
+
if (typeof pathComponent !== 'string') {
|
|
18132
|
+
throw new TypeError(`Expected a string, got ${typeof pathComponent}`);
|
|
18133
|
+
}
|
|
18134
|
+
const trimmed = pathComponent.trim();
|
|
18135
|
+
const isSafe = trimmed !== '' && trimmed !== '.' && trimmed !== '..' && !pathComponent.includes('/') && !pathComponent.includes('\\') && !pathComponent.includes('\0');
|
|
18136
|
+
if (!isSafe) {
|
|
18137
|
+
throw new Error(`Unsafe path component: ${JSON.stringify(pathComponent)}`);
|
|
18138
|
+
}
|
|
18139
|
+
}
|
|
18140
|
+
|
|
18141
|
+
function resolveParentDirectory(parentDirectory, rootDirectory) {
|
|
18142
|
+
assertSafePathComponent(parentDirectory);
|
|
18143
|
+
const base = rootDirectory ?? temporaryDirectory$1;
|
|
18144
|
+
const resolved = path__default.join(base, parentDirectory);
|
|
18145
|
+
fs$2.mkdirSync(resolved, {
|
|
18146
|
+
recursive: true
|
|
18147
|
+
});
|
|
18148
|
+
return resolved;
|
|
18149
|
+
}
|
|
18150
|
+
|
|
18151
|
+
const getPath = (prefix = '', {parentDirectory: parentDirectory, rootDirectory: rootDirectory} = {}) => {
|
|
18152
|
+
if (prefix) {
|
|
18153
|
+
assertSafePathComponent(prefix);
|
|
18154
|
+
}
|
|
18155
|
+
if (rootDirectory !== undefined) {
|
|
18156
|
+
if (!path__default.isAbsolute(rootDirectory)) {
|
|
18157
|
+
throw new Error('The `rootDirectory` option must be an absolute path');
|
|
18158
|
+
}
|
|
18159
|
+
fs$2.mkdirSync(rootDirectory, {
|
|
18160
|
+
recursive: true
|
|
18161
|
+
});
|
|
18162
|
+
}
|
|
18163
|
+
const parent = parentDirectory ? resolveParentDirectory(parentDirectory, rootDirectory) : rootDirectory ?? temporaryDirectory$1;
|
|
18164
|
+
return path__default.join(parent, prefix + uniqueString());
|
|
18165
|
+
};
|
|
18031
18166
|
|
|
18032
|
-
function temporaryFile({name: name, extension: extension} = {}) {
|
|
18033
|
-
if (name) {
|
|
18167
|
+
function temporaryFile({name: name, extension: extension, parentDirectory: parentDirectory, rootDirectory: rootDirectory} = {}) {
|
|
18168
|
+
if (name !== undefined && name !== null) {
|
|
18034
18169
|
if (extension !== undefined && extension !== null) {
|
|
18035
18170
|
throw new Error('The `name` and `extension` options are mutually exclusive');
|
|
18036
18171
|
}
|
|
18037
|
-
|
|
18172
|
+
assertSafePathComponent(name);
|
|
18173
|
+
return path__default.join(temporaryDirectory({
|
|
18174
|
+
parentDirectory: parentDirectory,
|
|
18175
|
+
rootDirectory: rootDirectory
|
|
18176
|
+
}), name);
|
|
18177
|
+
}
|
|
18178
|
+
if (extension !== undefined && extension !== null) {
|
|
18179
|
+
assertSafePathComponent(extension);
|
|
18038
18180
|
}
|
|
18039
|
-
return getPath(
|
|
18181
|
+
return getPath('', {
|
|
18182
|
+
parentDirectory: parentDirectory,
|
|
18183
|
+
rootDirectory: rootDirectory
|
|
18184
|
+
}) + (extension === undefined || extension === null ? '' : '.' + extension.replace(/^\./, ''));
|
|
18040
18185
|
}
|
|
18041
18186
|
|
|
18042
|
-
function temporaryDirectory({prefix: prefix = ''} = {}) {
|
|
18043
|
-
const directory = getPath(prefix
|
|
18044
|
-
|
|
18187
|
+
function temporaryDirectory({prefix: prefix = '', parentDirectory: parentDirectory, rootDirectory: rootDirectory} = {}) {
|
|
18188
|
+
const directory = getPath(prefix, {
|
|
18189
|
+
parentDirectory: parentDirectory,
|
|
18190
|
+
rootDirectory: rootDirectory
|
|
18191
|
+
});
|
|
18192
|
+
fs$2.mkdirSync(directory, {
|
|
18193
|
+
recursive: true
|
|
18194
|
+
});
|
|
18045
18195
|
return directory;
|
|
18046
18196
|
}
|
|
18047
18197
|
|
|
18048
18198
|
class NodeRequestCanceller {
|
|
18199
|
+
_serverId;
|
|
18200
|
+
_tracer;
|
|
18201
|
+
cancellationPipeName;
|
|
18049
18202
|
constructor(_serverId, _tracer) {
|
|
18050
18203
|
this._serverId = _serverId;
|
|
18051
18204
|
this._tracer = _tracer;
|
|
@@ -18080,10 +18233,8 @@ var RequestQueueingType;
|
|
|
18080
18233
|
})(RequestQueueingType || (RequestQueueingType = {}));
|
|
18081
18234
|
|
|
18082
18235
|
class RequestQueue {
|
|
18083
|
-
|
|
18084
|
-
|
|
18085
|
-
this.sequenceNumber = 0;
|
|
18086
|
-
}
|
|
18236
|
+
queue=[];
|
|
18237
|
+
sequenceNumber=0;
|
|
18087
18238
|
get length() {
|
|
18088
18239
|
return this.queue.length;
|
|
18089
18240
|
}
|
|
@@ -18124,10 +18275,8 @@ class RequestQueue {
|
|
|
18124
18275
|
}
|
|
18125
18276
|
|
|
18126
18277
|
class CallbackMap {
|
|
18127
|
-
|
|
18128
|
-
|
|
18129
|
-
this._asyncCallbacks = new Map;
|
|
18130
|
-
}
|
|
18278
|
+
_callbacks=new Map;
|
|
18279
|
+
_asyncCallbacks=new Map;
|
|
18131
18280
|
destroy(cause) {
|
|
18132
18281
|
const cancellation = new ServerResponse.Cancelled(cause);
|
|
18133
18282
|
for (const callback of this._callbacks.values()) {
|
|
@@ -18166,6 +18315,20 @@ var ExecutionTarget;
|
|
|
18166
18315
|
})(ExecutionTarget || (ExecutionTarget = {}));
|
|
18167
18316
|
|
|
18168
18317
|
class SingleTsServer {
|
|
18318
|
+
_serverId;
|
|
18319
|
+
_serverSource;
|
|
18320
|
+
_process;
|
|
18321
|
+
_tsServerLogFile;
|
|
18322
|
+
_requestCanceller;
|
|
18323
|
+
_version;
|
|
18324
|
+
_tracer;
|
|
18325
|
+
_requestQueue=new RequestQueue;
|
|
18326
|
+
_callbacks=new CallbackMap;
|
|
18327
|
+
_pendingResponses=new Set;
|
|
18328
|
+
_eventHandlers=new Set;
|
|
18329
|
+
_exitHandlers=new Set;
|
|
18330
|
+
_errorHandlers=new Set;
|
|
18331
|
+
_stdErrHandlers=new Set;
|
|
18169
18332
|
constructor(_serverId, _serverSource, _process, _tsServerLogFile, _requestCanceller, _version, _tracer) {
|
|
18170
18333
|
this._serverId = _serverId;
|
|
18171
18334
|
this._serverSource = _serverSource;
|
|
@@ -18174,13 +18337,6 @@ class SingleTsServer {
|
|
|
18174
18337
|
this._requestCanceller = _requestCanceller;
|
|
18175
18338
|
this._version = _version;
|
|
18176
18339
|
this._tracer = _tracer;
|
|
18177
|
-
this._requestQueue = new RequestQueue;
|
|
18178
|
-
this._callbacks = new CallbackMap;
|
|
18179
|
-
this._pendingResponses = new Set;
|
|
18180
|
-
this._eventHandlers = new Set;
|
|
18181
|
-
this._exitHandlers = new Set;
|
|
18182
|
-
this._errorHandlers = new Set;
|
|
18183
|
-
this._stdErrHandlers = new Set;
|
|
18184
18340
|
this._process.onData(msg => {
|
|
18185
18341
|
this.dispatchMessage(msg);
|
|
18186
18342
|
});
|
|
@@ -18355,6 +18511,7 @@ class SingleTsServer {
|
|
|
18355
18511
|
logTrace(message) {
|
|
18356
18512
|
this._tracer.logTrace(this._serverId, message);
|
|
18357
18513
|
}
|
|
18514
|
+
static fenceCommands=new Set([ 'change', 'close', 'open', 'updateOpen' ]);
|
|
18358
18515
|
static getQueueingType(command, lowPriority) {
|
|
18359
18516
|
if (SingleTsServer.fenceCommands.has(command)) {
|
|
18360
18517
|
return RequestQueueingType.Fence;
|
|
@@ -18363,9 +18520,10 @@ class SingleTsServer {
|
|
|
18363
18520
|
}
|
|
18364
18521
|
}
|
|
18365
18522
|
|
|
18366
|
-
SingleTsServer.fenceCommands = new Set([ 'change', 'close', 'open', 'updateOpen' ]);
|
|
18367
|
-
|
|
18368
18523
|
class RequestRouter {
|
|
18524
|
+
servers;
|
|
18525
|
+
delegate;
|
|
18526
|
+
static sharedCommands=new Set([ CommandTypes.Change, CommandTypes.Close, CommandTypes.Open, CommandTypes.UpdateOpen, CommandTypes.Configure ]);
|
|
18369
18527
|
constructor(servers, delegate) {
|
|
18370
18528
|
this.servers = servers;
|
|
18371
18529
|
this.delegate = delegate;
|
|
@@ -18420,14 +18578,18 @@ class RequestRouter {
|
|
|
18420
18578
|
}
|
|
18421
18579
|
}
|
|
18422
18580
|
|
|
18423
|
-
RequestRouter.sharedCommands = new Set([ CommandTypes.Change, CommandTypes.Close, CommandTypes.Open, CommandTypes.UpdateOpen, CommandTypes.Configure ]);
|
|
18424
|
-
|
|
18425
18581
|
class SyntaxRoutingTsServer {
|
|
18582
|
+
static syntaxAlwaysCommands=new Set([ CommandTypes.NavTree, CommandTypes.GetOutliningSpans, CommandTypes.JsxClosingTag, CommandTypes.SelectionRange, CommandTypes.Format, CommandTypes.Formatonkey, CommandTypes.DocCommentTemplate ]);
|
|
18583
|
+
static semanticCommands=new Set([ CommandTypes.Geterr, CommandTypes.GeterrForProject, CommandTypes.ProjectInfo, CommandTypes.ConfigurePlugin ]);
|
|
18584
|
+
static syntaxAllowedCommands=new Set([ CommandTypes.CompletionDetails, CommandTypes.CompletionInfo, CommandTypes.Definition, CommandTypes.DefinitionAndBoundSpan, CommandTypes.DocumentHighlights, CommandTypes.Implementation, CommandTypes.Navto, CommandTypes.Quickinfo, CommandTypes.References, CommandTypes.Rename, CommandTypes.SignatureHelp ]);
|
|
18585
|
+
syntaxServer;
|
|
18586
|
+
semanticServer;
|
|
18587
|
+
router;
|
|
18588
|
+
_projectLoading=true;
|
|
18589
|
+
_eventHandlers=new Set;
|
|
18590
|
+
_exitHandlers=new Set;
|
|
18591
|
+
_errorHandlers=new Set;
|
|
18426
18592
|
constructor(servers, delegate, enableDynamicRouting) {
|
|
18427
|
-
this._projectLoading = true;
|
|
18428
|
-
this._eventHandlers = new Set;
|
|
18429
|
-
this._exitHandlers = new Set;
|
|
18430
|
-
this._errorHandlers = new Set;
|
|
18431
18593
|
this.syntaxServer = servers.syntax;
|
|
18432
18594
|
this.semanticServer = servers.semantic;
|
|
18433
18595
|
this.router = new RequestRouter([ {
|
|
@@ -18460,15 +18622,15 @@ class SyntaxRoutingTsServer {
|
|
|
18460
18622
|
});
|
|
18461
18623
|
this.semanticServer.onEvent(event => {
|
|
18462
18624
|
switch (event.event) {
|
|
18463
|
-
case
|
|
18625
|
+
case EventName.projectLoadingStart:
|
|
18464
18626
|
this._projectLoading = true;
|
|
18465
18627
|
break;
|
|
18466
18628
|
|
|
18467
|
-
case
|
|
18468
|
-
case
|
|
18469
|
-
case
|
|
18470
|
-
case
|
|
18471
|
-
case
|
|
18629
|
+
case EventName.projectLoadingFinish:
|
|
18630
|
+
case EventName.semanticDiag:
|
|
18631
|
+
case EventName.syntaxDiag:
|
|
18632
|
+
case EventName.suggestionDiag:
|
|
18633
|
+
case EventName.configFileDiag:
|
|
18472
18634
|
this._projectLoading = false;
|
|
18473
18635
|
break;
|
|
18474
18636
|
}
|
|
@@ -18511,12 +18673,6 @@ class SyntaxRoutingTsServer {
|
|
|
18511
18673
|
}
|
|
18512
18674
|
}
|
|
18513
18675
|
|
|
18514
|
-
SyntaxRoutingTsServer.syntaxAlwaysCommands = new Set([ CommandTypes.NavTree, CommandTypes.GetOutliningSpans, CommandTypes.JsxClosingTag, CommandTypes.SelectionRange, CommandTypes.Format, CommandTypes.Formatonkey, CommandTypes.DocCommentTemplate ]);
|
|
18515
|
-
|
|
18516
|
-
SyntaxRoutingTsServer.semanticCommands = new Set([ CommandTypes.Geterr, CommandTypes.GeterrForProject, CommandTypes.ProjectInfo, CommandTypes.ConfigurePlugin ]);
|
|
18517
|
-
|
|
18518
|
-
SyntaxRoutingTsServer.syntaxAllowedCommands = new Set([ CommandTypes.CompletionDetails, CommandTypes.CompletionInfo, CommandTypes.Definition, CommandTypes.DefinitionAndBoundSpan, CommandTypes.DocumentHighlights, CommandTypes.Implementation, CommandTypes.Navto, CommandTypes.Quickinfo, CommandTypes.References, CommandTypes.Rename, CommandTypes.SignatureHelp ]);
|
|
18519
|
-
|
|
18520
18676
|
var RequestState;
|
|
18521
18677
|
|
|
18522
18678
|
(function(RequestState) {
|
|
@@ -18527,9 +18683,10 @@ var RequestState;
|
|
|
18527
18683
|
type: 1
|
|
18528
18684
|
};
|
|
18529
18685
|
class Errored {
|
|
18686
|
+
err;
|
|
18687
|
+
type=2;
|
|
18530
18688
|
constructor(err) {
|
|
18531
18689
|
this.err = err;
|
|
18532
|
-
this.type = 2;
|
|
18533
18690
|
}
|
|
18534
18691
|
}
|
|
18535
18692
|
RequestState.Errored = Errored;
|
|
@@ -18543,7 +18700,7 @@ class NodeTsServerProcessFactory {
|
|
|
18543
18700
|
if (useIpc) {
|
|
18544
18701
|
runtimeArgs.push('--useNodeIpc');
|
|
18545
18702
|
}
|
|
18546
|
-
const childProcess =
|
|
18703
|
+
const childProcess = require$$1.fork(tsServerPath, runtimeArgs, {
|
|
18547
18704
|
silent: true,
|
|
18548
18705
|
cwd: undefined,
|
|
18549
18706
|
env: generatePatchedEnv(process.env, tsServerPath),
|
|
@@ -18597,6 +18754,7 @@ function getTssDebugBrk() {
|
|
|
18597
18754
|
}
|
|
18598
18755
|
|
|
18599
18756
|
class IpcChildServerProcess {
|
|
18757
|
+
_process;
|
|
18600
18758
|
constructor(_process) {
|
|
18601
18759
|
this._process = _process;
|
|
18602
18760
|
}
|
|
@@ -18621,6 +18779,8 @@ class IpcChildServerProcess {
|
|
|
18621
18779
|
}
|
|
18622
18780
|
|
|
18623
18781
|
class StdioChildServerProcess {
|
|
18782
|
+
_process;
|
|
18783
|
+
_reader;
|
|
18624
18784
|
constructor(_process) {
|
|
18625
18785
|
this._process = _process;
|
|
18626
18786
|
this._reader = new Reader(this._process.stdout);
|
|
@@ -18652,12 +18812,12 @@ class StdioChildServerProcess {
|
|
|
18652
18812
|
}
|
|
18653
18813
|
|
|
18654
18814
|
class Reader {
|
|
18815
|
+
buffer=new ProtocolBuffer;
|
|
18816
|
+
nextMessageLength=-1;
|
|
18817
|
+
_onError=_error => {};
|
|
18818
|
+
_onData=_data => {};
|
|
18819
|
+
isDisposed=false;
|
|
18655
18820
|
constructor(readable) {
|
|
18656
|
-
this.buffer = new ProtocolBuffer;
|
|
18657
|
-
this.nextMessageLength = -1;
|
|
18658
|
-
this._onError = _error => {};
|
|
18659
|
-
this._onData = _data => {};
|
|
18660
|
-
this.isDisposed = false;
|
|
18661
18821
|
readable.on('data', data => this.onLengthData(data));
|
|
18662
18822
|
}
|
|
18663
18823
|
dispose() {
|
|
@@ -18711,17 +18871,10 @@ const backslashR = Buffer.from('\r', 'utf8')[0];
|
|
|
18711
18871
|
const backslashN = Buffer.from('\n', 'utf8')[0];
|
|
18712
18872
|
|
|
18713
18873
|
class ProtocolBuffer {
|
|
18714
|
-
|
|
18715
|
-
|
|
18716
|
-
this.buffer = Buffer.allocUnsafe(defaultSize);
|
|
18717
|
-
}
|
|
18874
|
+
index=0;
|
|
18875
|
+
buffer=Buffer.allocUnsafe(defaultSize);
|
|
18718
18876
|
append(data) {
|
|
18719
|
-
|
|
18720
|
-
if (Buffer.isBuffer(data)) {
|
|
18721
|
-
toAppend = data;
|
|
18722
|
-
} else {
|
|
18723
|
-
toAppend = Buffer.from(data, 'utf8');
|
|
18724
|
-
}
|
|
18877
|
+
const toAppend = Buffer.isBuffer(data) ? data : Buffer.from(data, 'utf8');
|
|
18725
18878
|
if (this.buffer.length - this.index >= toAppend.length) {
|
|
18726
18879
|
toAppend.copy(this.buffer, this.index, 0, toAppend.length);
|
|
18727
18880
|
} else {
|
|
@@ -18792,7 +18945,7 @@ var TsServerLogLevel;
|
|
|
18792
18945
|
case 'terse':
|
|
18793
18946
|
return TsServerLogLevel.Terse;
|
|
18794
18947
|
|
|
18795
|
-
case '
|
|
18948
|
+
case 'requesttime':
|
|
18796
18949
|
return TsServerLogLevel.RequestTime;
|
|
18797
18950
|
|
|
18798
18951
|
case 'verbose':
|
|
@@ -18823,18 +18976,39 @@ var TsServerLogLevel;
|
|
|
18823
18976
|
TsServerLogLevel.toString = toString;
|
|
18824
18977
|
})(TsServerLogLevel || (TsServerLogLevel = {}));
|
|
18825
18978
|
|
|
18979
|
+
var SyntaxServerConfiguration;
|
|
18980
|
+
|
|
18981
|
+
(function(SyntaxServerConfiguration) {
|
|
18982
|
+
SyntaxServerConfiguration[SyntaxServerConfiguration['Never'] = 0] = 'Never';
|
|
18983
|
+
SyntaxServerConfiguration[SyntaxServerConfiguration['Always'] = 1] = 'Always';
|
|
18984
|
+
SyntaxServerConfiguration[SyntaxServerConfiguration['Auto'] = 2] = 'Auto';
|
|
18985
|
+
})(SyntaxServerConfiguration || (SyntaxServerConfiguration = {}));
|
|
18986
|
+
|
|
18826
18987
|
function toSyntaxServerConfiguration(value) {
|
|
18827
18988
|
switch (value) {
|
|
18828
18989
|
case 'never':
|
|
18829
|
-
return
|
|
18990
|
+
return SyntaxServerConfiguration.Never;
|
|
18830
18991
|
|
|
18831
18992
|
case 'auto':
|
|
18832
|
-
return
|
|
18993
|
+
return SyntaxServerConfiguration.Auto;
|
|
18833
18994
|
}
|
|
18834
|
-
return
|
|
18995
|
+
return SyntaxServerConfiguration.Auto;
|
|
18835
18996
|
}
|
|
18836
18997
|
|
|
18998
|
+
var CompositeServerType;
|
|
18999
|
+
|
|
19000
|
+
(function(CompositeServerType) {
|
|
19001
|
+
CompositeServerType[CompositeServerType['Single'] = 0] = 'Single';
|
|
19002
|
+
CompositeServerType[CompositeServerType['SeparateSyntax'] = 1] = 'SeparateSyntax';
|
|
19003
|
+
CompositeServerType[CompositeServerType['DynamicSeparateSyntax'] = 2] = 'DynamicSeparateSyntax';
|
|
19004
|
+
CompositeServerType[CompositeServerType['SyntaxOnly'] = 3] = 'SyntaxOnly';
|
|
19005
|
+
})(CompositeServerType || (CompositeServerType = {}));
|
|
19006
|
+
|
|
18837
19007
|
class TypeScriptServerSpawner {
|
|
19008
|
+
_apiVersion;
|
|
19009
|
+
_logDirectoryProvider;
|
|
19010
|
+
_logger;
|
|
19011
|
+
_tracer;
|
|
18838
19012
|
constructor(_apiVersion, _logDirectoryProvider, _logger, _tracer) {
|
|
18839
19013
|
this._apiVersion = _apiVersion;
|
|
18840
19014
|
this._logDirectoryProvider = _logDirectoryProvider;
|
|
@@ -18845,10 +19019,10 @@ class TypeScriptServerSpawner {
|
|
|
18845
19019
|
let primaryServer;
|
|
18846
19020
|
const serverType = this.getCompositeServerType(version, capabilities, configuration);
|
|
18847
19021
|
switch (serverType) {
|
|
18848
|
-
case
|
|
18849
|
-
case
|
|
19022
|
+
case CompositeServerType.SeparateSyntax:
|
|
19023
|
+
case CompositeServerType.DynamicSeparateSyntax:
|
|
18850
19024
|
{
|
|
18851
|
-
const enableDynamicRouting = serverType ===
|
|
19025
|
+
const enableDynamicRouting = serverType === CompositeServerType.DynamicSeparateSyntax;
|
|
18852
19026
|
primaryServer = new SyntaxRoutingTsServer({
|
|
18853
19027
|
syntax: this.spawnTsServer('syntax', version, configuration, pluginManager),
|
|
18854
19028
|
semantic: this.spawnTsServer('semantic', version, configuration, pluginManager)
|
|
@@ -18856,13 +19030,13 @@ class TypeScriptServerSpawner {
|
|
|
18856
19030
|
break;
|
|
18857
19031
|
}
|
|
18858
19032
|
|
|
18859
|
-
case
|
|
19033
|
+
case CompositeServerType.Single:
|
|
18860
19034
|
{
|
|
18861
19035
|
primaryServer = this.spawnTsServer('main', version, configuration, pluginManager);
|
|
18862
19036
|
break;
|
|
18863
19037
|
}
|
|
18864
19038
|
|
|
18865
|
-
case
|
|
19039
|
+
case CompositeServerType.SyntaxOnly:
|
|
18866
19040
|
{
|
|
18867
19041
|
primaryServer = this.spawnTsServer('syntax', version, configuration, pluginManager);
|
|
18868
19042
|
break;
|
|
@@ -18872,20 +19046,20 @@ class TypeScriptServerSpawner {
|
|
|
18872
19046
|
}
|
|
18873
19047
|
getCompositeServerType(version, capabilities, configuration) {
|
|
18874
19048
|
if (!capabilities.has(ClientCapability.Semantic)) {
|
|
18875
|
-
return
|
|
19049
|
+
return CompositeServerType.SyntaxOnly;
|
|
18876
19050
|
}
|
|
18877
19051
|
switch (configuration.useSyntaxServer) {
|
|
18878
|
-
case
|
|
18879
|
-
return
|
|
19052
|
+
case SyntaxServerConfiguration.Always:
|
|
19053
|
+
return CompositeServerType.SyntaxOnly;
|
|
18880
19054
|
|
|
18881
|
-
case
|
|
18882
|
-
return
|
|
19055
|
+
case SyntaxServerConfiguration.Never:
|
|
19056
|
+
return CompositeServerType.Single;
|
|
18883
19057
|
|
|
18884
|
-
case
|
|
19058
|
+
case SyntaxServerConfiguration.Auto:
|
|
18885
19059
|
if (version.version?.gte(API.v340)) {
|
|
18886
|
-
return version.version?.gte(API.v400) ?
|
|
19060
|
+
return version.version?.gte(API.v400) ? CompositeServerType.DynamicSeparateSyntax : CompositeServerType.SeparateSyntax;
|
|
18887
19061
|
}
|
|
18888
|
-
return
|
|
19062
|
+
return CompositeServerType.Single;
|
|
18889
19063
|
}
|
|
18890
19064
|
}
|
|
18891
19065
|
spawnTsServer(kind, version, configuration, pluginManager) {
|
|
@@ -18918,7 +19092,6 @@ class TypeScriptServerSpawner {
|
|
|
18918
19092
|
getTsServerArgs(kind, configuration, apiVersion, pluginManager, cancellationPipeName) {
|
|
18919
19093
|
const args = [];
|
|
18920
19094
|
let tsServerLogFile;
|
|
18921
|
-
let tsServerTraceDirectory;
|
|
18922
19095
|
if (kind === 'syntax') {
|
|
18923
19096
|
if (apiVersion.gte(API.v401)) {
|
|
18924
19097
|
args.push('--serverMode', 'partialSemantic');
|
|
@@ -18956,12 +19129,14 @@ class TypeScriptServerSpawner {
|
|
|
18956
19129
|
this._logger.info(`using npm from ${npmLocation}`);
|
|
18957
19130
|
args.push('--npmLocation', `"${npmLocation}"`);
|
|
18958
19131
|
}
|
|
19132
|
+
if (configuration.useClientFileWatcher && apiVersion.gte(API.v544)) {
|
|
19133
|
+
args.push('--canUseWatchEvents');
|
|
19134
|
+
}
|
|
18959
19135
|
args.push('--locale', locale || 'en');
|
|
18960
19136
|
args.push('--validateDefaultNpmLocation');
|
|
18961
19137
|
return {
|
|
18962
19138
|
args: args,
|
|
18963
|
-
tsServerLogFile: tsServerLogFile
|
|
18964
|
-
tsServerTraceDirectory: tsServerTraceDirectory
|
|
19139
|
+
tsServerLogFile: tsServerLogFile
|
|
18965
19140
|
};
|
|
18966
19141
|
}
|
|
18967
19142
|
isLoggingEnabled(configuration) {
|
|
@@ -18998,6 +19173,8 @@ var Trace;
|
|
|
18998
19173
|
})(Trace || (Trace = {}));
|
|
18999
19174
|
|
|
19000
19175
|
class Tracer {
|
|
19176
|
+
logger;
|
|
19177
|
+
trace;
|
|
19001
19178
|
constructor(logger, trace) {
|
|
19002
19179
|
this.logger = logger;
|
|
19003
19180
|
this.trace = trace;
|
|
@@ -19045,167 +19222,642 @@ class Tracer {
|
|
|
19045
19222
|
}
|
|
19046
19223
|
}
|
|
19047
19224
|
|
|
19048
|
-
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
|
|
19052
|
-
|
|
19053
|
-
|
|
19054
|
-
|
|
19055
|
-
|
|
19056
|
-
|
|
19057
|
-
|
|
19058
|
-
|
|
19059
|
-
|
|
19225
|
+
var index_min = {};
|
|
19226
|
+
|
|
19227
|
+
var hasRequiredIndex_min;
|
|
19228
|
+
|
|
19229
|
+
function requireIndex_min() {
|
|
19230
|
+
if (hasRequiredIndex_min) return index_min;
|
|
19231
|
+
hasRequiredIndex_min = 1;
|
|
19232
|
+
(function(exports) {
|
|
19233
|
+
var a = (t, e) => () => (e || t((e = {
|
|
19234
|
+
exports: {}
|
|
19235
|
+
}).exports, e), e.exports);
|
|
19236
|
+
var _ = a(i => {
|
|
19237
|
+
Object.defineProperty(i, '__esModule', {
|
|
19238
|
+
value: true
|
|
19239
|
+
});
|
|
19240
|
+
i.sync = i.isexe = void 0;
|
|
19241
|
+
var M = fs$2, x = fsPromises, q = async (t, e = {}) => {
|
|
19242
|
+
let {ignoreErrors: r = false} = e;
|
|
19243
|
+
try {
|
|
19244
|
+
return d(await (0, x.stat)(t), e);
|
|
19245
|
+
} catch (s) {
|
|
19246
|
+
let n = s;
|
|
19247
|
+
if (r || n.code === 'EACCES') return false;
|
|
19248
|
+
throw n;
|
|
19249
|
+
}
|
|
19250
|
+
};
|
|
19251
|
+
i.isexe = q;
|
|
19252
|
+
var m = (t, e = {}) => {
|
|
19253
|
+
let {ignoreErrors: r = false} = e;
|
|
19254
|
+
try {
|
|
19255
|
+
return d((0, M.statSync)(t), e);
|
|
19256
|
+
} catch (s) {
|
|
19257
|
+
let n = s;
|
|
19258
|
+
if (r || n.code === 'EACCES') return false;
|
|
19259
|
+
throw n;
|
|
19260
|
+
}
|
|
19261
|
+
};
|
|
19262
|
+
i.sync = m;
|
|
19263
|
+
var d = (t, e) => t.isFile() && A(t, e), A = (t, e) => {
|
|
19264
|
+
let r = e.uid ?? process.getuid?.(), s = e.groups ?? process.getgroups?.() ?? [], n = e.gid ?? process.getgid?.() ?? s[0];
|
|
19265
|
+
if (r === void 0 || n === void 0) throw new Error('cannot get uid or gid');
|
|
19266
|
+
let u = new Set([ n, ...s ]), c = t.mode, S = t.uid, P = t.gid, f = parseInt('100', 8), l = parseInt('010', 8), j = parseInt('001', 8), C = f | l;
|
|
19267
|
+
return !!(c & j || c & l && u.has(P) || c & f && S === r || c & C && r === 0);
|
|
19268
|
+
};
|
|
19269
|
+
});
|
|
19270
|
+
var g = a(o => {
|
|
19271
|
+
Object.defineProperty(o, '__esModule', {
|
|
19272
|
+
value: true
|
|
19273
|
+
});
|
|
19274
|
+
o.sync = o.isexe = void 0;
|
|
19275
|
+
var T = fs$2, I = fsPromises, D = path__default, F = async (t, e = {}) => {
|
|
19276
|
+
let {ignoreErrors: r = false} = e;
|
|
19277
|
+
try {
|
|
19278
|
+
return y(await (0, I.stat)(t), t, e);
|
|
19279
|
+
} catch (s) {
|
|
19280
|
+
let n = s;
|
|
19281
|
+
if (r || n.code === 'EACCES') return false;
|
|
19282
|
+
throw n;
|
|
19283
|
+
}
|
|
19284
|
+
};
|
|
19285
|
+
o.isexe = F;
|
|
19286
|
+
var L = (t, e = {}) => {
|
|
19287
|
+
let {ignoreErrors: r = false} = e;
|
|
19288
|
+
try {
|
|
19289
|
+
return y((0, T.statSync)(t), t, e);
|
|
19290
|
+
} catch (s) {
|
|
19291
|
+
let n = s;
|
|
19292
|
+
if (r || n.code === 'EACCES') return false;
|
|
19293
|
+
throw n;
|
|
19294
|
+
}
|
|
19295
|
+
};
|
|
19296
|
+
o.sync = L;
|
|
19297
|
+
var B = (t, e) => {
|
|
19298
|
+
let {pathExt: r = process.env.PATHEXT || ''} = e, s = r.split(D.delimiter);
|
|
19299
|
+
if (s.indexOf('') !== -1) return true;
|
|
19300
|
+
for (let n of s) {
|
|
19301
|
+
let u = n.toLowerCase(), c = t.substring(t.length - u.length).toLowerCase();
|
|
19302
|
+
if (u && c === u) return true;
|
|
19303
|
+
}
|
|
19304
|
+
return false;
|
|
19305
|
+
}, y = (t, e, r) => t.isFile() && B(e, r);
|
|
19306
|
+
});
|
|
19307
|
+
var p = a(h => {
|
|
19308
|
+
Object.defineProperty(h, '__esModule', {
|
|
19309
|
+
value: true
|
|
19310
|
+
});
|
|
19311
|
+
});
|
|
19312
|
+
var v = exports && exports.__createBinding || (Object.create ? function(t, e, r, s) {
|
|
19313
|
+
s === void 0 && (s = r);
|
|
19314
|
+
var n = Object.getOwnPropertyDescriptor(e, r);
|
|
19315
|
+
(!n || ('get' in n ? !e.__esModule : n.writable || n.configurable)) && (n = {
|
|
19316
|
+
enumerable: true,
|
|
19317
|
+
get: function() {
|
|
19318
|
+
return e[r];
|
|
19319
|
+
}
|
|
19320
|
+
}), Object.defineProperty(t, s, n);
|
|
19321
|
+
} : function(t, e, r, s) {
|
|
19322
|
+
s === void 0 && (s = r), t[s] = e[r];
|
|
19323
|
+
}), G = exports && exports.__setModuleDefault || (Object.create ? function(t, e) {
|
|
19324
|
+
Object.defineProperty(t, 'default', {
|
|
19325
|
+
enumerable: true,
|
|
19326
|
+
value: e
|
|
19327
|
+
});
|
|
19328
|
+
} : function(t, e) {
|
|
19329
|
+
t.default = e;
|
|
19330
|
+
}), w = exports && exports.__importStar || function() {
|
|
19331
|
+
var t = function(e) {
|
|
19332
|
+
return t = Object.getOwnPropertyNames || function(r) {
|
|
19333
|
+
var s = [];
|
|
19334
|
+
for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && (s[s.length] = n);
|
|
19335
|
+
return s;
|
|
19336
|
+
}, t(e);
|
|
19337
|
+
};
|
|
19338
|
+
return function(e) {
|
|
19339
|
+
if (e && e.__esModule) return e;
|
|
19340
|
+
var r = {};
|
|
19341
|
+
if (e != null) for (var s = t(e), n = 0; n < s.length; n++) s[n] !== 'default' && v(r, e, s[n]);
|
|
19342
|
+
return G(r, e), r;
|
|
19343
|
+
};
|
|
19344
|
+
}(), X = exports && exports.__exportStar || function(t, e) {
|
|
19345
|
+
for (var r in t) r !== 'default' && !Object.prototype.hasOwnProperty.call(e, r) && v(e, t, r);
|
|
19346
|
+
};
|
|
19347
|
+
Object.defineProperty(exports, '__esModule', {
|
|
19348
|
+
value: true
|
|
19349
|
+
});
|
|
19350
|
+
exports.sync = exports.isexe = exports.posix = exports.win32 = void 0;
|
|
19351
|
+
var E = w(_());
|
|
19352
|
+
exports.posix = E;
|
|
19353
|
+
var O = w(g());
|
|
19354
|
+
exports.win32 = O;
|
|
19355
|
+
X(p(), exports);
|
|
19356
|
+
var H = process.env._ISEXE_TEST_PLATFORM_ || process.platform, b = H === 'win32' ? O : E;
|
|
19357
|
+
exports.isexe = b.isexe;
|
|
19358
|
+
exports.sync = b.sync;
|
|
19359
|
+
})(index_min);
|
|
19360
|
+
return index_min;
|
|
19060
19361
|
}
|
|
19061
19362
|
|
|
19062
|
-
var
|
|
19363
|
+
var lib;
|
|
19063
19364
|
|
|
19064
|
-
|
|
19065
|
-
|
|
19066
|
-
|
|
19067
|
-
|
|
19068
|
-
|
|
19069
|
-
|
|
19070
|
-
|
|
19071
|
-
|
|
19072
|
-
|
|
19073
|
-
|
|
19074
|
-
|
|
19075
|
-
|
|
19076
|
-
|
|
19077
|
-
|
|
19078
|
-
|
|
19079
|
-
|
|
19080
|
-
|
|
19081
|
-
|
|
19082
|
-
|
|
19083
|
-
|
|
19084
|
-
|
|
19085
|
-
|
|
19086
|
-
|
|
19087
|
-
|
|
19088
|
-
|
|
19089
|
-
|
|
19365
|
+
var hasRequiredLib;
|
|
19366
|
+
|
|
19367
|
+
function requireLib() {
|
|
19368
|
+
if (hasRequiredLib) return lib;
|
|
19369
|
+
hasRequiredLib = 1;
|
|
19370
|
+
const {isexe: isexe, sync: isexeSync} = requireIndex_min();
|
|
19371
|
+
const {join: join, delimiter: delimiter, sep: sep, posix: posix} = require$$1$1;
|
|
19372
|
+
const isWindows = process.platform === 'win32';
|
|
19373
|
+
const rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? '' : sep}]`.replace(/(\\)/g, '\\$1'));
|
|
19374
|
+
const rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
19375
|
+
const getNotFoundError = cmd => Object.assign(new Error(`not found: ${cmd}`), {
|
|
19376
|
+
code: 'ENOENT'
|
|
19377
|
+
});
|
|
19378
|
+
const getPathInfo = (cmd, {path: optPath = process.env.PATH, pathExt: optPathExt = process.env.PATHEXT, delimiter: optDelimiter = delimiter}) => {
|
|
19379
|
+
const pathEnv = cmd.match(rSlash) ? [ '' ] : [ ...isWindows ? [ process.cwd() ] : [], ...(optPath || '').split(optDelimiter) ];
|
|
19380
|
+
if (isWindows) {
|
|
19381
|
+
const pathExtExe = optPathExt || [ '.EXE', '.CMD', '.BAT', '.COM' ].join(optDelimiter);
|
|
19382
|
+
const pathExt = pathExtExe.split(optDelimiter).flatMap(item => [ item, item.toLowerCase() ]);
|
|
19383
|
+
if (cmd.includes('.') && pathExt[0] !== '') {
|
|
19384
|
+
pathExt.unshift('');
|
|
19385
|
+
}
|
|
19386
|
+
return {
|
|
19387
|
+
pathEnv: pathEnv,
|
|
19388
|
+
pathExt: pathExt,
|
|
19389
|
+
pathExtExe: pathExtExe
|
|
19390
|
+
};
|
|
19090
19391
|
}
|
|
19091
|
-
|
|
19092
|
-
|
|
19093
|
-
|
|
19392
|
+
return {
|
|
19393
|
+
pathEnv: pathEnv,
|
|
19394
|
+
pathExt: [ '' ]
|
|
19395
|
+
};
|
|
19396
|
+
};
|
|
19397
|
+
const getPathPart = (raw, cmd) => {
|
|
19398
|
+
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
19399
|
+
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : '';
|
|
19400
|
+
return prefix + join(pathPart, cmd);
|
|
19401
|
+
};
|
|
19402
|
+
const which = async (cmd, opt = {}) => {
|
|
19403
|
+
const {pathEnv: pathEnv, pathExt: pathExt, pathExtExe: pathExtExe} = getPathInfo(cmd, opt);
|
|
19404
|
+
const found = [];
|
|
19405
|
+
for (const envPart of pathEnv) {
|
|
19406
|
+
const p = getPathPart(envPart, cmd);
|
|
19407
|
+
for (const ext of pathExt) {
|
|
19408
|
+
const withExt = p + ext;
|
|
19409
|
+
const is = await isexe(withExt, {
|
|
19410
|
+
pathExt: pathExtExe,
|
|
19411
|
+
ignoreErrors: true
|
|
19412
|
+
});
|
|
19413
|
+
if (is) {
|
|
19414
|
+
if (!opt.all) {
|
|
19415
|
+
return withExt;
|
|
19416
|
+
}
|
|
19417
|
+
found.push(withExt);
|
|
19418
|
+
}
|
|
19419
|
+
}
|
|
19420
|
+
}
|
|
19421
|
+
if (opt.all && found.length) {
|
|
19422
|
+
return found;
|
|
19423
|
+
}
|
|
19424
|
+
if (opt.nothrow) {
|
|
19425
|
+
return null;
|
|
19426
|
+
}
|
|
19427
|
+
throw getNotFoundError(cmd);
|
|
19428
|
+
};
|
|
19429
|
+
const whichSync = (cmd, opt = {}) => {
|
|
19430
|
+
const {pathEnv: pathEnv, pathExt: pathExt, pathExtExe: pathExtExe} = getPathInfo(cmd, opt);
|
|
19431
|
+
const found = [];
|
|
19432
|
+
for (const pathEnvPart of pathEnv) {
|
|
19433
|
+
const p = getPathPart(pathEnvPart, cmd);
|
|
19434
|
+
for (const ext of pathExt) {
|
|
19435
|
+
const withExt = p + ext;
|
|
19436
|
+
const is = isexeSync(withExt, {
|
|
19437
|
+
pathExt: pathExtExe,
|
|
19438
|
+
ignoreErrors: true
|
|
19439
|
+
});
|
|
19440
|
+
if (is) {
|
|
19441
|
+
if (!opt.all) {
|
|
19442
|
+
return withExt;
|
|
19443
|
+
}
|
|
19444
|
+
found.push(withExt);
|
|
19445
|
+
}
|
|
19446
|
+
}
|
|
19447
|
+
}
|
|
19448
|
+
if (opt.all && found.length) {
|
|
19449
|
+
return found;
|
|
19450
|
+
}
|
|
19451
|
+
if (opt.nothrow) {
|
|
19452
|
+
return null;
|
|
19453
|
+
}
|
|
19454
|
+
throw getNotFoundError(cmd);
|
|
19455
|
+
};
|
|
19456
|
+
lib = which;
|
|
19457
|
+
which.sync = whichSync;
|
|
19458
|
+
return lib;
|
|
19459
|
+
}
|
|
19094
19460
|
|
|
19095
|
-
|
|
19096
|
-
switch (event.event) {
|
|
19097
|
-
case 'syntaxDiag':
|
|
19098
|
-
return 0;
|
|
19461
|
+
var libExports = requireLib();
|
|
19099
19462
|
|
|
19100
|
-
|
|
19101
|
-
return 1;
|
|
19463
|
+
const which = getDefaultExportFromCjs(libExports);
|
|
19102
19464
|
|
|
19103
|
-
|
|
19104
|
-
|
|
19465
|
+
const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
19466
|
+
|
|
19467
|
+
function findUpSync(name, {cwd: cwd = process$1.cwd(), type: type = 'file', stopAt: stopAt} = {}) {
|
|
19468
|
+
let directory = path__default.resolve(toPath(cwd) ?? '');
|
|
19469
|
+
const {root: root} = path__default.parse(directory);
|
|
19470
|
+
stopAt = path__default.resolve(directory, toPath(stopAt) ?? root);
|
|
19471
|
+
const isAbsoluteName = path__default.isAbsolute(name);
|
|
19472
|
+
while (directory) {
|
|
19473
|
+
const filePath = isAbsoluteName ? name : path__default.join(directory, name);
|
|
19474
|
+
try {
|
|
19475
|
+
const stats = fs$2.statSync(filePath, {
|
|
19476
|
+
throwIfNoEntry: false
|
|
19477
|
+
});
|
|
19478
|
+
if (type === 'file' && stats?.isFile() || type === 'directory' && stats?.isDirectory()) {
|
|
19479
|
+
return filePath;
|
|
19480
|
+
}
|
|
19481
|
+
} catch {}
|
|
19482
|
+
if (directory === stopAt || directory === root) {
|
|
19483
|
+
break;
|
|
19484
|
+
}
|
|
19485
|
+
directory = path__default.dirname(directory);
|
|
19105
19486
|
}
|
|
19106
|
-
throw new Error('Unknown dignostics kind');
|
|
19107
19487
|
}
|
|
19108
19488
|
|
|
19109
|
-
|
|
19110
|
-
|
|
19111
|
-
|
|
19112
|
-
}
|
|
19113
|
-
|
|
19114
|
-
|
|
19115
|
-
|
|
19116
|
-
|
|
19117
|
-
|
|
19489
|
+
function packageUpSync({cwd: cwd = process$1.cwd()} = {}) {
|
|
19490
|
+
return findUpSync('package.json', {
|
|
19491
|
+
cwd: cwd
|
|
19492
|
+
});
|
|
19493
|
+
}
|
|
19494
|
+
|
|
19495
|
+
function findPathToModule(dir, moduleNames) {
|
|
19496
|
+
const stat = statSync(dir);
|
|
19497
|
+
if (stat.isDirectory()) {
|
|
19498
|
+
const candidates = moduleNames.map(moduleName => resolve(dir, moduleName));
|
|
19499
|
+
const modulePath = candidates.find(existsSync);
|
|
19500
|
+
if (modulePath) {
|
|
19501
|
+
return modulePath;
|
|
19118
19502
|
}
|
|
19119
19503
|
}
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
|
|
19123
|
-
this._task = this.lspClient.createProgressReporter();
|
|
19124
|
-
this._task.then(reporter => reporter.begin('Initializing JS/TS language features…'));
|
|
19125
|
-
}
|
|
19126
|
-
finishedLoadingProject(projectName) {
|
|
19127
|
-
if (this._loadingProjectName === projectName) {
|
|
19128
|
-
this.reset();
|
|
19129
|
-
}
|
|
19504
|
+
const parent = resolve(dir, '..');
|
|
19505
|
+
if (parent !== dir) {
|
|
19506
|
+
return findPathToModule(parent, moduleNames);
|
|
19130
19507
|
}
|
|
19131
19508
|
}
|
|
19132
19509
|
|
|
19133
|
-
|
|
19134
|
-
|
|
19135
|
-
const inMemoryResourcePrefix = '^';
|
|
19510
|
+
var TypeScriptVersionSource;
|
|
19136
19511
|
|
|
19137
|
-
|
|
19512
|
+
(function(TypeScriptVersionSource) {
|
|
19513
|
+
TypeScriptVersionSource['Bundled'] = 'bundled';
|
|
19514
|
+
TypeScriptVersionSource['UserSetting'] = 'user-setting';
|
|
19515
|
+
TypeScriptVersionSource['Workspace'] = 'workspace';
|
|
19516
|
+
})(TypeScriptVersionSource || (TypeScriptVersionSource = {}));
|
|
19138
19517
|
|
|
19139
|
-
class
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
this.
|
|
19146
|
-
this.
|
|
19147
|
-
this.
|
|
19148
|
-
this.
|
|
19149
|
-
this.logger = new PrefixingLogger(logger, '[tsclient]');
|
|
19150
|
-
this.tsserverLogger = new PrefixingLogger(this.logger, '[tsserver]');
|
|
19151
|
-
this.lspClient = lspClient;
|
|
19152
|
-
this.loadingIndicator = new ServerInitializingIndicator(this.lspClient);
|
|
19153
|
-
}
|
|
19154
|
-
get documentsForTesting() {
|
|
19155
|
-
return this.documents.documentsForTesting;
|
|
19518
|
+
class TypeScriptVersion {
|
|
19519
|
+
source;
|
|
19520
|
+
path;
|
|
19521
|
+
logger;
|
|
19522
|
+
_api;
|
|
19523
|
+
constructor(source, path, logger) {
|
|
19524
|
+
this.source = source;
|
|
19525
|
+
this.path = path;
|
|
19526
|
+
this.logger = logger;
|
|
19527
|
+
this._api = null;
|
|
19156
19528
|
}
|
|
19157
|
-
|
|
19158
|
-
return this.
|
|
19529
|
+
get tsServerPath() {
|
|
19530
|
+
return this.path;
|
|
19159
19531
|
}
|
|
19160
|
-
|
|
19161
|
-
this.
|
|
19532
|
+
get isValid() {
|
|
19533
|
+
return this.version !== null;
|
|
19162
19534
|
}
|
|
19163
|
-
|
|
19164
|
-
this.
|
|
19535
|
+
get version() {
|
|
19536
|
+
if (this._api) {
|
|
19537
|
+
return this._api;
|
|
19538
|
+
}
|
|
19539
|
+
this._api = this.getTypeScriptVersion(this.tsServerPath);
|
|
19540
|
+
return this._api;
|
|
19165
19541
|
}
|
|
19166
|
-
|
|
19167
|
-
|
|
19542
|
+
get versionString() {
|
|
19543
|
+
const version = this.version;
|
|
19544
|
+
return version ? version.displayName : null;
|
|
19168
19545
|
}
|
|
19169
|
-
|
|
19170
|
-
|
|
19171
|
-
|
|
19172
|
-
|
|
19173
|
-
|
|
19174
|
-
if (disabledSchemes.has(resource.scheme)) {
|
|
19175
|
-
return undefined;
|
|
19546
|
+
getTypeScriptVersion(serverPath) {
|
|
19547
|
+
this.logger.log(`Resolving TypeScript version from path "${serverPath}"...`);
|
|
19548
|
+
if (!fs$2.existsSync(serverPath)) {
|
|
19549
|
+
this.logger.log('Server path does not exist on disk');
|
|
19550
|
+
return null;
|
|
19176
19551
|
}
|
|
19177
|
-
|
|
19178
|
-
|
|
19552
|
+
const p = serverPath.split(path__default.sep);
|
|
19553
|
+
if (p.length <= 2) {
|
|
19554
|
+
this.logger.log('Server path is invalid (has less than two path components).');
|
|
19555
|
+
return null;
|
|
19179
19556
|
}
|
|
19180
|
-
|
|
19181
|
-
|
|
19182
|
-
|
|
19183
|
-
|
|
19184
|
-
|
|
19185
|
-
|
|
19186
|
-
const uri = URI.parse(textDocumentUri);
|
|
19187
|
-
if (!options.suppressAlertOnFailure && !disabledSchemes.has(uri.scheme)) {
|
|
19188
|
-
console.error(`Unexpected resource ${textDocumentUri}`);
|
|
19557
|
+
const p2 = p.slice(0, -2);
|
|
19558
|
+
const modulePath = p2.join(path__default.sep);
|
|
19559
|
+
let fileName = path__default.join(modulePath, 'package.json');
|
|
19560
|
+
if (!fs$2.existsSync(fileName)) {
|
|
19561
|
+
if (path__default.basename(modulePath) === 'built') {
|
|
19562
|
+
fileName = path__default.join(modulePath, '..', 'package.json');
|
|
19189
19563
|
}
|
|
19190
|
-
return undefined;
|
|
19191
19564
|
}
|
|
19192
|
-
|
|
19193
|
-
|
|
19194
|
-
|
|
19195
|
-
this.documents.requestDiagnosticsForTesting();
|
|
19196
|
-
}
|
|
19197
|
-
hasPendingDiagnostics(resource) {
|
|
19198
|
-
return this.documents.hasPendingDiagnostics(resource);
|
|
19199
|
-
}
|
|
19200
|
-
toResource(filepath) {
|
|
19201
|
-
if (this.isNeovimHost && filepath.startsWith('zipfile:')) {
|
|
19202
|
-
return ZipfileURI.parse(filepath);
|
|
19565
|
+
if (!fs$2.existsSync(fileName)) {
|
|
19566
|
+
this.logger.log(`Failed to find package.json at path "${fileName}"`);
|
|
19567
|
+
return null;
|
|
19203
19568
|
}
|
|
19204
|
-
|
|
19205
|
-
|
|
19206
|
-
|
|
19207
|
-
|
|
19208
|
-
|
|
19569
|
+
this.logger.log(`Reading version from package.json at "${fileName}"`);
|
|
19570
|
+
const contents = fs$2.readFileSync(fileName).toString();
|
|
19571
|
+
let desc;
|
|
19572
|
+
try {
|
|
19573
|
+
desc = JSON.parse(contents);
|
|
19574
|
+
} catch {
|
|
19575
|
+
this.logger.log('Failed parsing contents of package.json.');
|
|
19576
|
+
return null;
|
|
19577
|
+
}
|
|
19578
|
+
if (!desc?.version) {
|
|
19579
|
+
this.logger.log('Failed reading version number from package.json.');
|
|
19580
|
+
return null;
|
|
19581
|
+
}
|
|
19582
|
+
this.logger.log(`Resolved TypeScript version to "${desc.version}"`);
|
|
19583
|
+
return API.fromVersionString(desc.version);
|
|
19584
|
+
}
|
|
19585
|
+
}
|
|
19586
|
+
|
|
19587
|
+
const MODULE_FOLDERS = [ 'node_modules/typescript/lib', '.vscode/pnpify/typescript/lib', '.yarn/sdks/typescript/lib' ];
|
|
19588
|
+
|
|
19589
|
+
class TypeScriptVersionProvider {
|
|
19590
|
+
userTsserverPath;
|
|
19591
|
+
logger;
|
|
19592
|
+
constructor(userTsserverPath, logger) {
|
|
19593
|
+
this.userTsserverPath = userTsserverPath;
|
|
19594
|
+
this.logger = logger;
|
|
19595
|
+
}
|
|
19596
|
+
getUserSettingVersion() {
|
|
19597
|
+
if (!this.userTsserverPath) {
|
|
19598
|
+
return null;
|
|
19599
|
+
}
|
|
19600
|
+
this.logger.log(`Resolving user-provided tsserver path "${this.userTsserverPath}"...`);
|
|
19601
|
+
let resolvedPath = this.userTsserverPath;
|
|
19602
|
+
if (!path__default.isAbsolute(resolvedPath)) {
|
|
19603
|
+
const binaryPath = which.sync(resolvedPath, {
|
|
19604
|
+
nothrow: true
|
|
19605
|
+
});
|
|
19606
|
+
if (binaryPath) {
|
|
19607
|
+
resolvedPath = binaryPath;
|
|
19608
|
+
}
|
|
19609
|
+
this.logger.log(`Non-absolute tsserver path resolved to "${binaryPath ? resolvedPath : '<failed>'}"`);
|
|
19610
|
+
}
|
|
19611
|
+
let stat = fs$2.lstatSync(resolvedPath, {
|
|
19612
|
+
throwIfNoEntry: false
|
|
19613
|
+
});
|
|
19614
|
+
if (stat?.isSymbolicLink()) {
|
|
19615
|
+
resolvedPath = fs$2.realpathSync(resolvedPath);
|
|
19616
|
+
this.logger.log(`Symbolic link tsserver path resolved to "${resolvedPath}"`);
|
|
19617
|
+
}
|
|
19618
|
+
stat = fs$2.lstatSync(resolvedPath, {
|
|
19619
|
+
throwIfNoEntry: false
|
|
19620
|
+
});
|
|
19621
|
+
if (stat?.isFile()) {
|
|
19622
|
+
if (path__default.basename(resolvedPath) === 'tsserver.js') {
|
|
19623
|
+
this.logger.log(`Resolved tsserver location: ${resolvedPath}`);
|
|
19624
|
+
return new TypeScriptVersion(TypeScriptVersionSource.UserSetting, resolvedPath, this.logger);
|
|
19625
|
+
}
|
|
19626
|
+
resolvedPath = path__default.dirname(resolvedPath);
|
|
19627
|
+
this.logger.log(`Resolved directory path from a file path: ${resolvedPath}`);
|
|
19628
|
+
}
|
|
19629
|
+
try {
|
|
19630
|
+
const packageJsonPath = packageUpSync({
|
|
19631
|
+
cwd: resolvedPath
|
|
19632
|
+
});
|
|
19633
|
+
this.logger.log(`Resolved package.json location: "${packageJsonPath}"`);
|
|
19634
|
+
if (packageJsonPath) {
|
|
19635
|
+
resolvedPath = path__default.join(path__default.dirname(packageJsonPath), 'lib', 'tsserver.js');
|
|
19636
|
+
this.logger.log(`Resolved tsserver location: "${resolvedPath}"`);
|
|
19637
|
+
}
|
|
19638
|
+
} catch {}
|
|
19639
|
+
return new TypeScriptVersion(TypeScriptVersionSource.UserSetting, resolvedPath, this.logger);
|
|
19640
|
+
}
|
|
19641
|
+
getWorkspaceVersion(workspaceFolders) {
|
|
19642
|
+
for (const p of workspaceFolders) {
|
|
19643
|
+
const libFolder = findPathToModule(p, MODULE_FOLDERS);
|
|
19644
|
+
if (libFolder) {
|
|
19645
|
+
const tsServerPath = path__default.join(libFolder, 'tsserver.js');
|
|
19646
|
+
const version = new TypeScriptVersion(TypeScriptVersionSource.Workspace, tsServerPath, this.logger);
|
|
19647
|
+
if (version.isValid) {
|
|
19648
|
+
return version;
|
|
19649
|
+
}
|
|
19650
|
+
}
|
|
19651
|
+
}
|
|
19652
|
+
return null;
|
|
19653
|
+
}
|
|
19654
|
+
bundledVersion() {
|
|
19655
|
+
const require = createRequire(import.meta.url);
|
|
19656
|
+
try {
|
|
19657
|
+
const file = require.resolve('typescript');
|
|
19658
|
+
const tsServerPath = path__default.join(path__default.dirname(file), 'tsserver.js');
|
|
19659
|
+
const bundledVersion = new TypeScriptVersion(TypeScriptVersionSource.Bundled, tsServerPath, this.logger);
|
|
19660
|
+
return bundledVersion;
|
|
19661
|
+
} catch {
|
|
19662
|
+
return null;
|
|
19663
|
+
}
|
|
19664
|
+
}
|
|
19665
|
+
}
|
|
19666
|
+
|
|
19667
|
+
class ZipfileURI extends URI {
|
|
19668
|
+
_originalUri;
|
|
19669
|
+
constructor(uri, components) {
|
|
19670
|
+
super(components);
|
|
19671
|
+
this._originalUri = uri;
|
|
19672
|
+
}
|
|
19673
|
+
toString(_skipEncoding = false) {
|
|
19674
|
+
return this._originalUri;
|
|
19675
|
+
}
|
|
19676
|
+
static parse(value, _strict = false) {
|
|
19677
|
+
const uri = URI.parse(value, _strict);
|
|
19678
|
+
return new ZipfileURI(value, uri);
|
|
19679
|
+
}
|
|
19680
|
+
}
|
|
19681
|
+
|
|
19682
|
+
var ServerState;
|
|
19683
|
+
|
|
19684
|
+
(function(ServerState) {
|
|
19685
|
+
let Type;
|
|
19686
|
+
(function(Type) {
|
|
19687
|
+
Type[Type['None'] = 0] = 'None';
|
|
19688
|
+
Type[Type['Running'] = 1] = 'Running';
|
|
19689
|
+
Type[Type['Errored'] = 2] = 'Errored';
|
|
19690
|
+
})(Type = ServerState.Type || (ServerState.Type = {}));
|
|
19691
|
+
ServerState.None = {
|
|
19692
|
+
type: Type.None
|
|
19693
|
+
};
|
|
19694
|
+
class Running {
|
|
19695
|
+
server;
|
|
19696
|
+
apiVersion;
|
|
19697
|
+
tsserverVersion;
|
|
19698
|
+
languageServiceEnabled;
|
|
19699
|
+
type=Type.Running;
|
|
19700
|
+
constructor(server, apiVersion, tsserverVersion, languageServiceEnabled) {
|
|
19701
|
+
this.server = server;
|
|
19702
|
+
this.apiVersion = apiVersion;
|
|
19703
|
+
this.tsserverVersion = tsserverVersion;
|
|
19704
|
+
this.languageServiceEnabled = languageServiceEnabled;
|
|
19705
|
+
}
|
|
19706
|
+
toCancelOnResourceChange=new Set;
|
|
19707
|
+
updateTsserverVersion(tsserverVersion) {
|
|
19708
|
+
this.tsserverVersion = tsserverVersion;
|
|
19709
|
+
}
|
|
19710
|
+
updateLanguageServiceEnabled(enabled) {
|
|
19711
|
+
this.languageServiceEnabled = enabled;
|
|
19712
|
+
}
|
|
19713
|
+
}
|
|
19714
|
+
ServerState.Running = Running;
|
|
19715
|
+
class Errored {
|
|
19716
|
+
error;
|
|
19717
|
+
tsServerLogFile;
|
|
19718
|
+
type=Type.Errored;
|
|
19719
|
+
constructor(error, tsServerLogFile) {
|
|
19720
|
+
this.error = error;
|
|
19721
|
+
this.tsServerLogFile = tsServerLogFile;
|
|
19722
|
+
}
|
|
19723
|
+
}
|
|
19724
|
+
ServerState.Errored = Errored;
|
|
19725
|
+
})(ServerState || (ServerState = {}));
|
|
19726
|
+
|
|
19727
|
+
var DiagnosticKind;
|
|
19728
|
+
|
|
19729
|
+
(function(DiagnosticKind) {
|
|
19730
|
+
DiagnosticKind[DiagnosticKind['Syntax'] = 0] = 'Syntax';
|
|
19731
|
+
DiagnosticKind[DiagnosticKind['Semantic'] = 1] = 'Semantic';
|
|
19732
|
+
DiagnosticKind[DiagnosticKind['Suggestion'] = 2] = 'Suggestion';
|
|
19733
|
+
})(DiagnosticKind || (DiagnosticKind = {}));
|
|
19734
|
+
|
|
19735
|
+
function getDignosticsKind(event) {
|
|
19736
|
+
switch (event.event) {
|
|
19737
|
+
case 'syntaxDiag':
|
|
19738
|
+
return DiagnosticKind.Syntax;
|
|
19739
|
+
|
|
19740
|
+
case 'semanticDiag':
|
|
19741
|
+
return DiagnosticKind.Semantic;
|
|
19742
|
+
|
|
19743
|
+
case 'suggestionDiag':
|
|
19744
|
+
return DiagnosticKind.Suggestion;
|
|
19745
|
+
}
|
|
19746
|
+
throw new Error('Unknown dignostics kind');
|
|
19747
|
+
}
|
|
19748
|
+
|
|
19749
|
+
class ServerInitializingIndicator {
|
|
19750
|
+
lspClient;
|
|
19751
|
+
_loadingProjectName;
|
|
19752
|
+
_task;
|
|
19753
|
+
constructor(lspClient) {
|
|
19754
|
+
this.lspClient = lspClient;
|
|
19755
|
+
}
|
|
19756
|
+
reset() {
|
|
19757
|
+
if (this._task) {
|
|
19758
|
+
const task = this._task;
|
|
19759
|
+
this._task = undefined;
|
|
19760
|
+
task.then(reporter => reporter.done());
|
|
19761
|
+
}
|
|
19762
|
+
}
|
|
19763
|
+
startedLoadingProject(projectName) {
|
|
19764
|
+
this.reset();
|
|
19765
|
+
this._loadingProjectName = projectName;
|
|
19766
|
+
this._task = this.lspClient.createProgressReporter();
|
|
19767
|
+
this._task.then(reporter => reporter.begin('Initializing JS/TS language features…'));
|
|
19768
|
+
}
|
|
19769
|
+
finishedLoadingProject(projectName) {
|
|
19770
|
+
if (this._loadingProjectName === projectName) {
|
|
19771
|
+
this.reset();
|
|
19772
|
+
}
|
|
19773
|
+
}
|
|
19774
|
+
}
|
|
19775
|
+
|
|
19776
|
+
const emptyAuthority = 'ts-nul-authority';
|
|
19777
|
+
|
|
19778
|
+
const inMemoryResourcePrefix = '^';
|
|
19779
|
+
|
|
19780
|
+
const RE_IN_MEMORY_FILEPATH = /^\^\/([^/]+)\/([^/]*)\/(.+)$/;
|
|
19781
|
+
|
|
19782
|
+
class TsClient {
|
|
19783
|
+
apiVersion=API.defaultVersion;
|
|
19784
|
+
typescriptVersionSource=TypeScriptVersionSource.Bundled;
|
|
19785
|
+
pluginManager;
|
|
19786
|
+
serverState=ServerState.None;
|
|
19787
|
+
lspClient;
|
|
19788
|
+
logger;
|
|
19789
|
+
tsserverLogger;
|
|
19790
|
+
loadingIndicator;
|
|
19791
|
+
isNeovimHost=false;
|
|
19792
|
+
tracer;
|
|
19793
|
+
workspaceFolders=[];
|
|
19794
|
+
documents;
|
|
19795
|
+
useSyntaxServer=SyntaxServerConfiguration.Auto;
|
|
19796
|
+
onEvent;
|
|
19797
|
+
onExit;
|
|
19798
|
+
constructor(onCaseInsensitiveFileSystem, logger, lspClient) {
|
|
19799
|
+
this.pluginManager = new PluginManager;
|
|
19800
|
+
this.documents = new LspDocuments(this, lspClient, onCaseInsensitiveFileSystem);
|
|
19801
|
+
this.logger = new PrefixingLogger(logger, '[tsclient]');
|
|
19802
|
+
this.tsserverLogger = new PrefixingLogger(this.logger, '[tsserver]');
|
|
19803
|
+
this.lspClient = lspClient;
|
|
19804
|
+
this.loadingIndicator = new ServerInitializingIndicator(this.lspClient);
|
|
19805
|
+
}
|
|
19806
|
+
get documentsForTesting() {
|
|
19807
|
+
return this.documents.documentsForTesting;
|
|
19808
|
+
}
|
|
19809
|
+
openTextDocument(textDocument) {
|
|
19810
|
+
return this.documents.openTextDocument(textDocument);
|
|
19811
|
+
}
|
|
19812
|
+
onDidCloseTextDocument(uri) {
|
|
19813
|
+
this.documents.onDidCloseTextDocument(uri);
|
|
19814
|
+
}
|
|
19815
|
+
onDidChangeTextDocument(params) {
|
|
19816
|
+
this.documents.onDidChangeTextDocument(params);
|
|
19817
|
+
}
|
|
19818
|
+
lastFileOrDummy() {
|
|
19819
|
+
return this.documents.files[0] || this.workspaceFolders[0]?.uri.fsPath;
|
|
19820
|
+
}
|
|
19821
|
+
toTsFilePath(stringUri) {
|
|
19822
|
+
if (this.isNeovimHost && stringUri.startsWith('zipfile:')) {
|
|
19823
|
+
return stringUri;
|
|
19824
|
+
}
|
|
19825
|
+
const resource = URI.parse(stringUri);
|
|
19826
|
+
if (disabledSchemes.has(resource.scheme)) {
|
|
19827
|
+
return undefined;
|
|
19828
|
+
}
|
|
19829
|
+
if (resource.scheme === file) {
|
|
19830
|
+
return resource.fsPath;
|
|
19831
|
+
}
|
|
19832
|
+
return inMemoryResourcePrefix + '/' + resource.scheme + '/' + (resource.authority || emptyAuthority) + (resource.path.startsWith('/') ? resource.path : '/' + resource.path) + (resource.fragment ? '#' + resource.fragment : '');
|
|
19833
|
+
}
|
|
19834
|
+
toOpenDocument(textDocumentUri, options = {}) {
|
|
19835
|
+
const filepath = this.toTsFilePath(textDocumentUri);
|
|
19836
|
+
const document = filepath && this.documents.get(filepath);
|
|
19837
|
+
if (!document) {
|
|
19838
|
+
const uri = URI.parse(textDocumentUri);
|
|
19839
|
+
if (!options.suppressAlertOnFailure && !disabledSchemes.has(uri.scheme)) {
|
|
19840
|
+
console.error(`Unexpected resource ${textDocumentUri}`);
|
|
19841
|
+
}
|
|
19842
|
+
return undefined;
|
|
19843
|
+
}
|
|
19844
|
+
return document;
|
|
19845
|
+
}
|
|
19846
|
+
requestDiagnosticsForTesting() {
|
|
19847
|
+
this.documents.requestDiagnosticsForTesting();
|
|
19848
|
+
}
|
|
19849
|
+
hasPendingDiagnostics(resource) {
|
|
19850
|
+
return this.documents.hasPendingDiagnostics(resource);
|
|
19851
|
+
}
|
|
19852
|
+
toResource(filepath) {
|
|
19853
|
+
if (this.isNeovimHost && filepath.startsWith('zipfile:')) {
|
|
19854
|
+
return ZipfileURI.parse(filepath);
|
|
19855
|
+
}
|
|
19856
|
+
if (filepath.startsWith(inMemoryResourcePrefix)) {
|
|
19857
|
+
const parts = filepath.match(RE_IN_MEMORY_FILEPATH);
|
|
19858
|
+
if (parts) {
|
|
19859
|
+
const resource = URI.parse(parts[1] + '://' + (parts[2] === emptyAuthority ? '' : parts[2]) + '/' + parts[3]);
|
|
19860
|
+
const tsFilepath = this.toTsFilePath(resource.toString());
|
|
19209
19861
|
const document = tsFilepath && this.documents.get(tsFilepath);
|
|
19210
19862
|
return document ? document.uri : resource;
|
|
19211
19863
|
}
|
|
@@ -19228,7 +19880,7 @@ class TsClient {
|
|
|
19228
19880
|
return undefined;
|
|
19229
19881
|
}
|
|
19230
19882
|
get capabilities() {
|
|
19231
|
-
if (this.useSyntaxServer ===
|
|
19883
|
+
if (this.useSyntaxServer === SyntaxServerConfiguration.Always) {
|
|
19232
19884
|
return new ClientCapabilities(ClientCapability.Syntax, ClientCapability.EnhancedSyntax);
|
|
19233
19885
|
}
|
|
19234
19886
|
if (this.apiVersion.gte(API.v400)) {
|
|
@@ -19261,6 +19913,9 @@ class TsClient {
|
|
|
19261
19913
|
});
|
|
19262
19914
|
}
|
|
19263
19915
|
}
|
|
19916
|
+
sendWatchChanges(args) {
|
|
19917
|
+
this.executeWithoutWaitingForResponse(CommandTypes.WatchChange, args);
|
|
19918
|
+
}
|
|
19264
19919
|
start(workspaceRoot, options) {
|
|
19265
19920
|
this.apiVersion = options.typescriptVersion.version || API.defaultVersion;
|
|
19266
19921
|
this.typescriptVersionSource = options.typescriptVersion.source;
|
|
@@ -19302,24 +19957,28 @@ class TsClient {
|
|
|
19302
19957
|
return true;
|
|
19303
19958
|
}
|
|
19304
19959
|
serviceExited() {
|
|
19305
|
-
if (this.serverState.type ===
|
|
19960
|
+
if (this.serverState.type === ServerState.Type.Running) {
|
|
19306
19961
|
this.serverState.server.kill();
|
|
19307
19962
|
}
|
|
19308
19963
|
this.loadingIndicator.reset();
|
|
19309
19964
|
}
|
|
19310
19965
|
dispatchEvent(event) {
|
|
19311
19966
|
switch (event.event) {
|
|
19312
|
-
case
|
|
19313
|
-
case
|
|
19314
|
-
case
|
|
19315
|
-
case
|
|
19967
|
+
case EventName.syntaxDiag:
|
|
19968
|
+
case EventName.semanticDiag:
|
|
19969
|
+
case EventName.suggestionDiag:
|
|
19970
|
+
case EventName.configFileDiag:
|
|
19971
|
+
this.loadingIndicator.reset();
|
|
19972
|
+
|
|
19973
|
+
case EventName.createDirectoryWatcher:
|
|
19974
|
+
case EventName.createFileWatcher:
|
|
19975
|
+
case EventName.closeFileWatcher:
|
|
19316
19976
|
{
|
|
19317
|
-
this.loadingIndicator.reset();
|
|
19318
19977
|
this.onEvent?.(event);
|
|
19319
19978
|
break;
|
|
19320
19979
|
}
|
|
19321
19980
|
|
|
19322
|
-
case
|
|
19981
|
+
case EventName.projectsUpdatedInBackground:
|
|
19323
19982
|
{
|
|
19324
19983
|
this.loadingIndicator.reset();
|
|
19325
19984
|
const body = event.body;
|
|
@@ -19328,11 +19987,11 @@ class TsClient {
|
|
|
19328
19987
|
break;
|
|
19329
19988
|
}
|
|
19330
19989
|
|
|
19331
|
-
case
|
|
19990
|
+
case EventName.projectLoadingStart:
|
|
19332
19991
|
this.loadingIndicator.startedLoadingProject(event.body.projectName);
|
|
19333
19992
|
break;
|
|
19334
19993
|
|
|
19335
|
-
case
|
|
19994
|
+
case EventName.projectLoadingFinish:
|
|
19336
19995
|
this.loadingIndicator.finishedLoadingProject(event.body.projectName);
|
|
19337
19996
|
break;
|
|
19338
19997
|
}
|
|
@@ -19341,7 +20000,7 @@ class TsClient {
|
|
|
19341
20000
|
if (this.loadingIndicator) {
|
|
19342
20001
|
this.loadingIndicator.reset();
|
|
19343
20002
|
}
|
|
19344
|
-
if (this.serverState.type ===
|
|
20003
|
+
if (this.serverState.type === ServerState.Type.Running) {
|
|
19345
20004
|
this.serverState.server.kill();
|
|
19346
20005
|
}
|
|
19347
20006
|
this.serverState = ServerState.None;
|
|
@@ -19350,7 +20009,7 @@ class TsClient {
|
|
|
19350
20009
|
let executions;
|
|
19351
20010
|
if (config?.cancelOnResourceChange) {
|
|
19352
20011
|
const runningServerState = this.serverState;
|
|
19353
|
-
if (token && runningServerState.type ===
|
|
20012
|
+
if (token && runningServerState.type === ServerState.Type.Running) {
|
|
19354
20013
|
const source = new mainExports$1.CancellationTokenSource;
|
|
19355
20014
|
token.onCancellationRequested(() => source.cancel());
|
|
19356
20015
|
const inFlight = {
|
|
@@ -19420,7 +20079,7 @@ class TsClient {
|
|
|
19420
20079
|
return this.documents.interruptGetErr(f);
|
|
19421
20080
|
}
|
|
19422
20081
|
cancelInflightRequestsForResource(resource) {
|
|
19423
|
-
if (this.serverState.type !==
|
|
20082
|
+
if (this.serverState.type !== ServerState.Type.Running) {
|
|
19424
20083
|
return;
|
|
19425
20084
|
}
|
|
19426
20085
|
for (const request of this.serverState.toCancelOnResourceChange) {
|
|
@@ -19431,7 +20090,7 @@ class TsClient {
|
|
|
19431
20090
|
}
|
|
19432
20091
|
executeImpl(command, args, executeInfo) {
|
|
19433
20092
|
const serverState = this.serverState;
|
|
19434
|
-
if (serverState.type ===
|
|
20093
|
+
if (serverState.type === ServerState.Type.Running) {
|
|
19435
20094
|
return serverState.server.executeImpl(command, args, executeInfo);
|
|
19436
20095
|
} else {
|
|
19437
20096
|
return [ Promise.resolve(ServerResponse.NoServer) ];
|
|
@@ -19442,7 +20101,7 @@ class TsClient {
|
|
|
19442
20101
|
if (error instanceof TypeScriptServerError && error.serverErrorText) {
|
|
19443
20102
|
this.tsserverLogger.error(error.serverErrorText);
|
|
19444
20103
|
}
|
|
19445
|
-
if (this.serverState.type ===
|
|
20104
|
+
if (this.serverState.type === ServerState.Type.Running) {
|
|
19446
20105
|
this.logger.info('Killing TS Server');
|
|
19447
20106
|
const logfile = this.serverState.server.tsServerLogFile;
|
|
19448
20107
|
this.serverState.server.kill();
|
|
@@ -19847,14 +20506,18 @@ function toDocumentHighlightKind(kind) {
|
|
|
19847
20506
|
}
|
|
19848
20507
|
|
|
19849
20508
|
class FileDiagnostics {
|
|
20509
|
+
uri;
|
|
20510
|
+
onPublishDiagnostics;
|
|
20511
|
+
client;
|
|
20512
|
+
features;
|
|
20513
|
+
closed=false;
|
|
20514
|
+
diagnosticsPerKind=new Map;
|
|
20515
|
+
firePublishDiagnostics=pDebounce(() => this.publishDiagnostics(), 50);
|
|
19850
20516
|
constructor(uri, onPublishDiagnostics, client, features) {
|
|
19851
20517
|
this.uri = uri;
|
|
19852
20518
|
this.onPublishDiagnostics = onPublishDiagnostics;
|
|
19853
20519
|
this.client = client;
|
|
19854
20520
|
this.features = features;
|
|
19855
|
-
this.closed = false;
|
|
19856
|
-
this.diagnosticsPerKind = new Map;
|
|
19857
|
-
this.firePublishDiagnostics = pDebounce(() => this.publishDiagnostics(), 50);
|
|
19858
20521
|
}
|
|
19859
20522
|
update(kind, diagnostics) {
|
|
19860
20523
|
if (this.diagnosticsPerKind.get(kind)?.length === 0 && diagnostics.length === 0) {
|
|
@@ -19901,16 +20564,20 @@ class FileDiagnostics {
|
|
|
19901
20564
|
}
|
|
19902
20565
|
|
|
19903
20566
|
class DiagnosticsManager {
|
|
20567
|
+
publishDiagnostics;
|
|
20568
|
+
client;
|
|
20569
|
+
features;
|
|
20570
|
+
logger;
|
|
20571
|
+
diagnostics=new Map;
|
|
20572
|
+
ignoredDiagnosticCodes=new Set;
|
|
19904
20573
|
constructor(publishDiagnostics, client, features, logger) {
|
|
19905
20574
|
this.publishDiagnostics = publishDiagnostics;
|
|
19906
20575
|
this.client = client;
|
|
19907
20576
|
this.features = features;
|
|
19908
20577
|
this.logger = logger;
|
|
19909
|
-
this.diagnostics = new Map;
|
|
19910
|
-
this.ignoredDiagnosticCodes = new Set;
|
|
19911
20578
|
}
|
|
19912
20579
|
updateDiagnostics(kind, file, diagnostics) {
|
|
19913
|
-
if (kind !==
|
|
20580
|
+
if (kind !== DiagnosticKind.Syntax && !this.client.hasCapabilityForResource(this.client.toResource(file), ClientCapability.Semantic)) {
|
|
19914
20581
|
return;
|
|
19915
20582
|
}
|
|
19916
20583
|
if (this.ignoredDiagnosticCodes.size) {
|
|
@@ -19934,6 +20601,22 @@ class DiagnosticsManager {
|
|
|
19934
20601
|
diagnosticsForFile?.onDidClose();
|
|
19935
20602
|
this.diagnostics.delete(uri);
|
|
19936
20603
|
}
|
|
20604
|
+
clearDiagnosticsForFile(file) {
|
|
20605
|
+
if (!this.features.diagnosticsSupport) {
|
|
20606
|
+
return;
|
|
20607
|
+
}
|
|
20608
|
+
const uri = this.client.toResourceUri(file);
|
|
20609
|
+
const diagnosticsForFile = this.diagnostics.get(uri);
|
|
20610
|
+
if (diagnosticsForFile) {
|
|
20611
|
+
diagnosticsForFile.onDidClose();
|
|
20612
|
+
this.diagnostics.delete(uri);
|
|
20613
|
+
} else {
|
|
20614
|
+
this.publishDiagnostics({
|
|
20615
|
+
uri: uri,
|
|
20616
|
+
diagnostics: []
|
|
20617
|
+
});
|
|
20618
|
+
}
|
|
20619
|
+
}
|
|
19937
20620
|
async waitForDiagnosticsForTesting(file) {
|
|
19938
20621
|
const uri = this.client.toResourceUri(file);
|
|
19939
20622
|
let diagnosticsForFile = this.diagnostics.get(uri);
|
|
@@ -19951,6 +20634,8 @@ class DiagnosticsManager {
|
|
|
19951
20634
|
}
|
|
19952
20635
|
|
|
19953
20636
|
class SourceDefinitionCommand {
|
|
20637
|
+
static id='_typescript.goToSourceDefinition';
|
|
20638
|
+
static minVersion=API.v470;
|
|
19954
20639
|
static async execute(uri, position, client, lspClient, reporter, token) {
|
|
19955
20640
|
if (client.apiVersion.lt(SourceDefinitionCommand.minVersion)) {
|
|
19956
20641
|
lspClient.showErrorMessage('Go to Source Definition failed. Requires TypeScript 4.7+.');
|
|
@@ -19985,37 +20670,6 @@ class SourceDefinitionCommand {
|
|
|
19985
20670
|
}
|
|
19986
20671
|
}
|
|
19987
20672
|
|
|
19988
|
-
SourceDefinitionCommand.id = '_typescript.goToSourceDefinition';
|
|
19989
|
-
|
|
19990
|
-
SourceDefinitionCommand.minVersion = API.v470;
|
|
19991
|
-
|
|
19992
|
-
class TSServerRequestCommand {
|
|
19993
|
-
static execute(client, command, args, config, token) {
|
|
19994
|
-
if (args && typeof args === 'object' && !Array.isArray(args)) {
|
|
19995
|
-
const requestArgs = args;
|
|
19996
|
-
const hasFile = typeof requestArgs.file === 'string';
|
|
19997
|
-
if (hasFile) {
|
|
19998
|
-
const newArgs = {
|
|
19999
|
-
...args
|
|
20000
|
-
};
|
|
20001
|
-
if (hasFile) {
|
|
20002
|
-
const document = client.toOpenDocument(requestArgs.file);
|
|
20003
|
-
if (document) {
|
|
20004
|
-
newArgs.file = document.filepath;
|
|
20005
|
-
}
|
|
20006
|
-
}
|
|
20007
|
-
args = newArgs;
|
|
20008
|
-
}
|
|
20009
|
-
}
|
|
20010
|
-
if (config && token && typeof config === 'object' && !Array.isArray(config)) {
|
|
20011
|
-
config.token = token;
|
|
20012
|
-
}
|
|
20013
|
-
return client.executeCustom(command, args, config);
|
|
20014
|
-
}
|
|
20015
|
-
}
|
|
20016
|
-
|
|
20017
|
-
TSServerRequestCommand.id = 'typescript.tsserverRequest';
|
|
20018
|
-
|
|
20019
20673
|
const Commands = {
|
|
20020
20674
|
APPLY_REFACTORING: '_typescript.applyRefactoring',
|
|
20021
20675
|
CONFIGURE_PLUGIN: '_typescript.configurePlugin',
|
|
@@ -20023,18 +20677,25 @@ const Commands = {
|
|
|
20023
20677
|
APPLY_RENAME_FILE: '_typescript.applyRenameFile',
|
|
20024
20678
|
APPLY_COMPLETION_CODE_ACTION: '_typescript.applyCompletionCodeAction',
|
|
20025
20679
|
SELECT_REFACTORING: '_typescript.selectRefactoring',
|
|
20026
|
-
SOURCE_DEFINITION: SourceDefinitionCommand.id
|
|
20027
|
-
TS_SERVER_REQUEST: TSServerRequestCommand.id
|
|
20680
|
+
SOURCE_DEFINITION: SourceDefinitionCommand.id
|
|
20028
20681
|
};
|
|
20029
20682
|
|
|
20030
20683
|
const TypescriptVersionNotification = new mainExports$2.NotificationType('$/typescriptVersion');
|
|
20031
20684
|
|
|
20685
|
+
var MarkdownStringTextNewlineStyle;
|
|
20686
|
+
|
|
20687
|
+
(function(MarkdownStringTextNewlineStyle) {
|
|
20688
|
+
MarkdownStringTextNewlineStyle[MarkdownStringTextNewlineStyle['Paragraph'] = 0] = 'Paragraph';
|
|
20689
|
+
MarkdownStringTextNewlineStyle[MarkdownStringTextNewlineStyle['Break'] = 1] = 'Break';
|
|
20690
|
+
})(MarkdownStringTextNewlineStyle || (MarkdownStringTextNewlineStyle = {}));
|
|
20691
|
+
|
|
20032
20692
|
class MarkdownString {
|
|
20693
|
+
value;
|
|
20033
20694
|
constructor(value = '') {
|
|
20034
20695
|
this.value = value;
|
|
20035
20696
|
}
|
|
20036
|
-
appendText(value, newlineStyle =
|
|
20037
|
-
this.value += escapeMarkdownSyntaxTokens(value).replace(/([ \t]+)/g, (_match, g1) => ' '.repeat(g1.length)).replace(/>/gm, '\\>').replace(/\n/g, newlineStyle ===
|
|
20697
|
+
appendText(value, newlineStyle = MarkdownStringTextNewlineStyle.Paragraph) {
|
|
20698
|
+
this.value += escapeMarkdownSyntaxTokens(value).replace(/([ \t]+)/g, (_match, g1) => ' '.repeat(g1.length)).replace(/>/gm, '\\>').replace(/\n/g, newlineStyle === MarkdownStringTextNewlineStyle.Break ? '\\\n' : '\n\n');
|
|
20038
20699
|
return this;
|
|
20039
20700
|
}
|
|
20040
20701
|
appendMarkdown(value) {
|
|
@@ -20250,8 +20911,9 @@ class SnippetString {
|
|
|
20250
20911
|
static _escape(value) {
|
|
20251
20912
|
return value.replace(/\$|}|\\/g, '\\$&');
|
|
20252
20913
|
}
|
|
20914
|
+
_tabstop=1;
|
|
20915
|
+
value;
|
|
20253
20916
|
constructor(value) {
|
|
20254
|
-
this._tabstop = 1;
|
|
20255
20917
|
this.value = value || '';
|
|
20256
20918
|
}
|
|
20257
20919
|
appendText(str) {
|
|
@@ -20302,10 +20964,8 @@ class SnippetString {
|
|
|
20302
20964
|
}
|
|
20303
20965
|
|
|
20304
20966
|
class CompletionDataCache {
|
|
20305
|
-
|
|
20306
|
-
|
|
20307
|
-
this.lastCacheId = 0;
|
|
20308
|
-
}
|
|
20967
|
+
store=new Map;
|
|
20968
|
+
lastCacheId=0;
|
|
20309
20969
|
reset() {
|
|
20310
20970
|
this.lastCacheId = 0;
|
|
20311
20971
|
this.store.clear();
|
|
@@ -20839,6 +21499,34 @@ function toTsTriggerReason(context) {
|
|
|
20839
21499
|
}
|
|
20840
21500
|
}
|
|
20841
21501
|
|
|
21502
|
+
class TSServerRequestCommand {
|
|
21503
|
+
tsClient;
|
|
21504
|
+
static ID='typescript.tsserverRequest';
|
|
21505
|
+
id=TSServerRequestCommand.ID;
|
|
21506
|
+
constructor(tsClient) {
|
|
21507
|
+
this.tsClient = tsClient;
|
|
21508
|
+
}
|
|
21509
|
+
async execute(command, args, config) {
|
|
21510
|
+
if (args && typeof args === 'object' && !Array.isArray(args)) {
|
|
21511
|
+
const requestArgs = args;
|
|
21512
|
+
const hasFile = typeof requestArgs.file === 'string';
|
|
21513
|
+
if (hasFile) {
|
|
21514
|
+
const newArgs = {
|
|
21515
|
+
...args
|
|
21516
|
+
};
|
|
21517
|
+
if (hasFile) {
|
|
21518
|
+
const document = this.tsClient.toOpenDocument(requestArgs.file);
|
|
21519
|
+
if (document) {
|
|
21520
|
+
newArgs.file = document.filepath;
|
|
21521
|
+
}
|
|
21522
|
+
}
|
|
21523
|
+
args = newArgs;
|
|
21524
|
+
}
|
|
21525
|
+
}
|
|
21526
|
+
return await this.tsClient.executeCustom(command, args, config);
|
|
21527
|
+
}
|
|
21528
|
+
}
|
|
21529
|
+
|
|
20842
21530
|
var CodeActionKind$1;
|
|
20843
21531
|
|
|
20844
21532
|
(function(CodeActionKind) {
|
|
@@ -20926,6 +21614,20 @@ function asKind(action) {
|
|
|
20926
21614
|
}
|
|
20927
21615
|
|
|
20928
21616
|
class CodeActionKind {
|
|
21617
|
+
value;
|
|
21618
|
+
static sep='.';
|
|
21619
|
+
static Empty=new CodeActionKind(mainExports$2.CodeActionKind.Empty);
|
|
21620
|
+
static QuickFix=new CodeActionKind(mainExports$2.CodeActionKind.QuickFix);
|
|
21621
|
+
static Refactor=new CodeActionKind(mainExports$2.CodeActionKind.Refactor);
|
|
21622
|
+
static Source=new CodeActionKind(mainExports$2.CodeActionKind.Source);
|
|
21623
|
+
static SourceAddMissingImportsTs=CodeActionKind.Source.append('addMissingImports').append('ts');
|
|
21624
|
+
static SourceFixAll=new CodeActionKind(mainExports$2.CodeActionKind.SourceFixAll);
|
|
21625
|
+
static SourceFixAllTs=CodeActionKind.SourceFixAll.append('ts');
|
|
21626
|
+
static SourceOrganizeImports=new CodeActionKind(mainExports$2.CodeActionKind.SourceOrganizeImports);
|
|
21627
|
+
static SourceOrganizeImportsTs=CodeActionKind.SourceOrganizeImports.append('ts');
|
|
21628
|
+
static SourceRemoveUnusedImportsTs=CodeActionKind.Source.append('removeUnusedImports').append('ts');
|
|
21629
|
+
static SourceRemoveUnusedTs=CodeActionKind.Source.append('removeUnused').append('ts');
|
|
21630
|
+
static SourceSortImportsTs=CodeActionKind.Source.append('sortImports').append('ts');
|
|
20929
21631
|
constructor(value) {
|
|
20930
21632
|
this.value = value;
|
|
20931
21633
|
}
|
|
@@ -20943,32 +21645,6 @@ class CodeActionKind {
|
|
|
20943
21645
|
}
|
|
20944
21646
|
}
|
|
20945
21647
|
|
|
20946
|
-
CodeActionKind.sep = '.';
|
|
20947
|
-
|
|
20948
|
-
CodeActionKind.Empty = new CodeActionKind(mainExports$2.CodeActionKind.Empty);
|
|
20949
|
-
|
|
20950
|
-
CodeActionKind.QuickFix = new CodeActionKind(mainExports$2.CodeActionKind.QuickFix);
|
|
20951
|
-
|
|
20952
|
-
CodeActionKind.Refactor = new CodeActionKind(mainExports$2.CodeActionKind.Refactor);
|
|
20953
|
-
|
|
20954
|
-
CodeActionKind.Source = new CodeActionKind(mainExports$2.CodeActionKind.Source);
|
|
20955
|
-
|
|
20956
|
-
CodeActionKind.SourceAddMissingImportsTs = CodeActionKind.Source.append('addMissingImports').append('ts');
|
|
20957
|
-
|
|
20958
|
-
CodeActionKind.SourceFixAll = new CodeActionKind(mainExports$2.CodeActionKind.SourceFixAll);
|
|
20959
|
-
|
|
20960
|
-
CodeActionKind.SourceFixAllTs = CodeActionKind.SourceFixAll.append('ts');
|
|
20961
|
-
|
|
20962
|
-
CodeActionKind.SourceOrganizeImports = new CodeActionKind(mainExports$2.CodeActionKind.SourceOrganizeImports);
|
|
20963
|
-
|
|
20964
|
-
CodeActionKind.SourceOrganizeImportsTs = CodeActionKind.SourceOrganizeImports.append('ts');
|
|
20965
|
-
|
|
20966
|
-
CodeActionKind.SourceRemoveUnusedImportsTs = CodeActionKind.Source.append('removeUnusedImports').append('ts');
|
|
20967
|
-
|
|
20968
|
-
CodeActionKind.SourceRemoveUnusedTs = CodeActionKind.Source.append('removeUnused').append('ts');
|
|
20969
|
-
|
|
20970
|
-
CodeActionKind.SourceSortImportsTs = CodeActionKind.Source.append('sortImports').append('ts');
|
|
20971
|
-
|
|
20972
21648
|
const organizeImportsCommand = {
|
|
20973
21649
|
title: 'Organize Imports',
|
|
20974
21650
|
kind: CodeActionKind.SourceOrganizeImportsTs,
|
|
@@ -21195,13 +21871,13 @@ function parseKindModifier(kindModifiers) {
|
|
|
21195
21871
|
return new Set(kindModifiers.split(/,|\s+/g));
|
|
21196
21872
|
}
|
|
21197
21873
|
|
|
21198
|
-
var cjs
|
|
21874
|
+
var cjs;
|
|
21199
21875
|
|
|
21200
|
-
var hasRequiredCjs
|
|
21876
|
+
var hasRequiredCjs;
|
|
21201
21877
|
|
|
21202
|
-
function requireCjs
|
|
21203
|
-
if (hasRequiredCjs
|
|
21204
|
-
hasRequiredCjs
|
|
21878
|
+
function requireCjs() {
|
|
21879
|
+
if (hasRequiredCjs) return cjs;
|
|
21880
|
+
hasRequiredCjs = 1;
|
|
21205
21881
|
var isMergeableObject = function isMergeableObject(value) {
|
|
21206
21882
|
return isNonNullObject(value) && !isSpecial(value);
|
|
21207
21883
|
};
|
|
@@ -21297,11 +21973,11 @@ function requireCjs$1() {
|
|
|
21297
21973
|
}, {});
|
|
21298
21974
|
};
|
|
21299
21975
|
var deepmerge_1 = deepmerge;
|
|
21300
|
-
cjs
|
|
21301
|
-
return cjs
|
|
21976
|
+
cjs = deepmerge_1;
|
|
21977
|
+
return cjs;
|
|
21302
21978
|
}
|
|
21303
21979
|
|
|
21304
|
-
var cjsExports = requireCjs
|
|
21980
|
+
var cjsExports = requireCjs();
|
|
21305
21981
|
|
|
21306
21982
|
const deepmerge = getDefaultExportFromCjs(cjsExports);
|
|
21307
21983
|
|
|
@@ -21367,6 +22043,9 @@ function getInferredProjectCompilerOptions(version, workspaceConfig) {
|
|
|
21367
22043
|
if (workspaceConfig.strictFunctionTypes) {
|
|
21368
22044
|
projectConfig.strictFunctionTypes = true;
|
|
21369
22045
|
}
|
|
22046
|
+
if (workspaceConfig.strict) {
|
|
22047
|
+
projectConfig.strict = true;
|
|
22048
|
+
}
|
|
21370
22049
|
if (workspaceConfig.module) {
|
|
21371
22050
|
projectConfig.module = workspaceConfig.module;
|
|
21372
22051
|
}
|
|
@@ -21428,9 +22107,10 @@ const DEFAULT_IMPLICIT_PROJECT_CONFIGURATION = {
|
|
|
21428
22107
|
checkJs: false,
|
|
21429
22108
|
experimentalDecorators: false,
|
|
21430
22109
|
module: ModuleKind.ESNext,
|
|
22110
|
+
strict: true,
|
|
21431
22111
|
strictFunctionTypes: true,
|
|
21432
22112
|
strictNullChecks: true,
|
|
21433
|
-
target: ScriptTarget.
|
|
22113
|
+
target: ScriptTarget.ES2024
|
|
21434
22114
|
};
|
|
21435
22115
|
|
|
21436
22116
|
const DEFAULT_WORKSPACE_CONFIGURATION = {
|
|
@@ -21442,12 +22122,18 @@ function areFileConfigurationsEqual(a, b) {
|
|
|
21442
22122
|
}
|
|
21443
22123
|
|
|
21444
22124
|
class FileConfigurationManager {
|
|
22125
|
+
client;
|
|
22126
|
+
lspClient;
|
|
22127
|
+
features;
|
|
22128
|
+
tsPreferences=deepmerge({}, DEFAULT_TSSERVER_PREFERENCES);
|
|
22129
|
+
workspaceConfiguration=deepmerge({}, DEFAULT_WORKSPACE_CONFIGURATION);
|
|
22130
|
+
fileOptionsCache;
|
|
22131
|
+
formatOptionsCache;
|
|
22132
|
+
initialConfigurationRequestsMap;
|
|
21445
22133
|
constructor(client, lspClient, features, onCaseInsensitiveFileSystem) {
|
|
21446
22134
|
this.client = client;
|
|
21447
22135
|
this.lspClient = lspClient;
|
|
21448
22136
|
this.features = features;
|
|
21449
|
-
this.tsPreferences = deepmerge({}, DEFAULT_TSSERVER_PREFERENCES);
|
|
21450
|
-
this.workspaceConfiguration = deepmerge({}, DEFAULT_WORKSPACE_CONFIGURATION);
|
|
21451
22137
|
this.fileOptionsCache = new ResourceMap(undefined, {
|
|
21452
22138
|
onCaseInsensitiveFileSystem: onCaseInsensitiveFileSystem
|
|
21453
22139
|
});
|
|
@@ -21631,6 +22317,17 @@ var CodeLensType;
|
|
|
21631
22317
|
})(CodeLensType || (CodeLensType = {}));
|
|
21632
22318
|
|
|
21633
22319
|
class TypeScriptBaseCodeLensProvider {
|
|
22320
|
+
client;
|
|
22321
|
+
cachedResponse;
|
|
22322
|
+
fileConfigurationManager;
|
|
22323
|
+
static cancelledCommand={
|
|
22324
|
+
title: '',
|
|
22325
|
+
command: ''
|
|
22326
|
+
};
|
|
22327
|
+
static errorCommand={
|
|
22328
|
+
title: 'Could not determine references',
|
|
22329
|
+
command: ''
|
|
22330
|
+
};
|
|
21634
22331
|
constructor(client, cachedResponse, fileConfigurationManager) {
|
|
21635
22332
|
this.client = client;
|
|
21636
22333
|
this.cachedResponse = cachedResponse;
|
|
@@ -21663,16 +22360,6 @@ class TypeScriptBaseCodeLensProvider {
|
|
|
21663
22360
|
}
|
|
21664
22361
|
}
|
|
21665
22362
|
|
|
21666
|
-
TypeScriptBaseCodeLensProvider.cancelledCommand = {
|
|
21667
|
-
title: '',
|
|
21668
|
-
command: ''
|
|
21669
|
-
};
|
|
21670
|
-
|
|
21671
|
-
TypeScriptBaseCodeLensProvider.errorCommand = {
|
|
21672
|
-
title: 'Could not determine references',
|
|
21673
|
-
command: ''
|
|
21674
|
-
};
|
|
21675
|
-
|
|
21676
22363
|
function getSymbolRange(document, item) {
|
|
21677
22364
|
if (item.nameSpan) {
|
|
21678
22365
|
return Range.fromTextSpan(item.nameSpan);
|
|
@@ -21831,6 +22518,7 @@ class TypeScriptReferencesCodeLensProvider extends TypeScriptBaseCodeLensProvide
|
|
|
21831
22518
|
}
|
|
21832
22519
|
|
|
21833
22520
|
class TypeScriptInlayHintsProvider {
|
|
22521
|
+
static minVersion=API.v440;
|
|
21834
22522
|
static async provideInlayHints(textDocument, range, client, lspClient, fileConfigurationManager, token) {
|
|
21835
22523
|
if (client.apiVersion.lt(TypeScriptInlayHintsProvider.minVersion)) {
|
|
21836
22524
|
lspClient.showErrorMessage('Inlay Hints request failed. Requires TypeScript 4.4+.');
|
|
@@ -21883,8 +22571,6 @@ class TypeScriptInlayHintsProvider {
|
|
|
21883
22571
|
}
|
|
21884
22572
|
}
|
|
21885
22573
|
|
|
21886
|
-
TypeScriptInlayHintsProvider.minVersion = API.v440;
|
|
21887
|
-
|
|
21888
22574
|
function areInlayHintsEnabledForFile(fileConfigurationManager, document) {
|
|
21889
22575
|
const preferences = fileConfigurationManager.getPreferences(document);
|
|
21890
22576
|
return preferences.includeInlayParameterNameHints === 'literals' || preferences.includeInlayParameterNameHints === 'all' || preferences.includeInlayEnumMemberValueHints || preferences.includeInlayFunctionLikeReturnTypeHints || preferences.includeInlayFunctionParameterTypeHints || preferences.includeInlayPropertyDeclarationTypeHints || preferences.includeInlayVariableTypeHints;
|
|
@@ -21893,580 +22579,106 @@ function areInlayHintsEnabledForFile(fileConfigurationManager, document) {
|
|
|
21893
22579
|
function fromProtocolInlayHintKind(kind) {
|
|
21894
22580
|
switch (kind) {
|
|
21895
22581
|
case 'Parameter':
|
|
21896
|
-
return mainExports$2.InlayHintKind.Parameter;
|
|
21897
|
-
|
|
21898
|
-
case 'Type':
|
|
21899
|
-
return mainExports$2.InlayHintKind.Type;
|
|
21900
|
-
|
|
21901
|
-
case 'Enum':
|
|
21902
|
-
return undefined;
|
|
21903
|
-
|
|
21904
|
-
default:
|
|
21905
|
-
return undefined;
|
|
21906
|
-
}
|
|
21907
|
-
}
|
|
21908
|
-
|
|
21909
|
-
var TokenEncodingConsts;
|
|
21910
|
-
|
|
21911
|
-
(function(TokenEncodingConsts) {
|
|
21912
|
-
TokenEncodingConsts[TokenEncodingConsts['typeOffset'] = 8] = 'typeOffset';
|
|
21913
|
-
TokenEncodingConsts[TokenEncodingConsts['modifierMask'] = 255] = 'modifierMask';
|
|
21914
|
-
})(TokenEncodingConsts || (TokenEncodingConsts = {}));
|
|
21915
|
-
|
|
21916
|
-
function transformSpans(doc, spans) {
|
|
21917
|
-
const lspSpans = [];
|
|
21918
|
-
let previousLine = 0;
|
|
21919
|
-
let previousTokenStart = 0;
|
|
21920
|
-
for (let i = 0; i < spans.length; i += 3) {
|
|
21921
|
-
const tokenStart = spans[i];
|
|
21922
|
-
const tokenLength = spans[i + 1];
|
|
21923
|
-
const tokenTypeBitSet = spans[i + 2];
|
|
21924
|
-
const tokenModifier = tokenTypeBitSet & TokenEncodingConsts.modifierMask;
|
|
21925
|
-
const tokenType = (tokenTypeBitSet >> TokenEncodingConsts.typeOffset) - 1;
|
|
21926
|
-
const {line: line, character: character} = doc.positionAt(tokenStart);
|
|
21927
|
-
const deltaLine = line - previousLine;
|
|
21928
|
-
const deltaStart = previousLine === line ? character - previousTokenStart : character;
|
|
21929
|
-
lspSpans.push(deltaLine, deltaStart, tokenLength, tokenType, tokenModifier);
|
|
21930
|
-
previousTokenStart = character;
|
|
21931
|
-
previousLine = line;
|
|
21932
|
-
}
|
|
21933
|
-
return lspSpans;
|
|
21934
|
-
}
|
|
21935
|
-
|
|
21936
|
-
class CachedResponse {
|
|
21937
|
-
constructor() {
|
|
21938
|
-
this.version = -1;
|
|
21939
|
-
this.document = '';
|
|
21940
|
-
}
|
|
21941
|
-
execute(document, resolve) {
|
|
21942
|
-
if (this.response && this.matches(document)) {
|
|
21943
|
-
return this.response = this.response.then(result => result.type === 'cancelled' ? resolve() : result);
|
|
21944
|
-
}
|
|
21945
|
-
return this.reset(document, resolve);
|
|
21946
|
-
}
|
|
21947
|
-
onDocumentClose(document) {
|
|
21948
|
-
if (this.document === document.uri.toString()) {
|
|
21949
|
-
this.response = undefined;
|
|
21950
|
-
this.version = -1;
|
|
21951
|
-
this.document = '';
|
|
21952
|
-
}
|
|
21953
|
-
}
|
|
21954
|
-
matches(document) {
|
|
21955
|
-
return this.version === document.version && this.document === document.uri.toString();
|
|
21956
|
-
}
|
|
21957
|
-
async reset(document, resolve) {
|
|
21958
|
-
this.version = document.version;
|
|
21959
|
-
this.document = document.uri.toString();
|
|
21960
|
-
return this.response = resolve();
|
|
21961
|
-
}
|
|
21962
|
-
}
|
|
21963
|
-
|
|
21964
|
-
class LogDirectoryProvider {
|
|
21965
|
-
constructor(rootPath) {
|
|
21966
|
-
this.rootPath = rootPath;
|
|
21967
|
-
}
|
|
21968
|
-
getNewLogDirectory() {
|
|
21969
|
-
const root = this.logDirectory();
|
|
21970
|
-
if (root) {
|
|
21971
|
-
try {
|
|
21972
|
-
return fs$2.mkdtempSync(path__default.join(root, 'tsserver-log-'));
|
|
21973
|
-
} catch {
|
|
21974
|
-
return undefined;
|
|
21975
|
-
}
|
|
21976
|
-
}
|
|
21977
|
-
return undefined;
|
|
21978
|
-
}
|
|
21979
|
-
logDirectory() {
|
|
21980
|
-
if (!this.rootPath) {
|
|
21981
|
-
return undefined;
|
|
21982
|
-
}
|
|
21983
|
-
try {
|
|
21984
|
-
if (!fs$2.existsSync(this.rootPath)) {
|
|
21985
|
-
fs$2.mkdirSync(this.rootPath);
|
|
21986
|
-
}
|
|
21987
|
-
return this.rootPath;
|
|
21988
|
-
} catch {
|
|
21989
|
-
return undefined;
|
|
21990
|
-
}
|
|
21991
|
-
}
|
|
21992
|
-
}
|
|
21993
|
-
|
|
21994
|
-
var cjs = {};
|
|
21995
|
-
|
|
21996
|
-
var posix = {};
|
|
21997
|
-
|
|
21998
|
-
var hasRequiredPosix;
|
|
21999
|
-
|
|
22000
|
-
function requirePosix() {
|
|
22001
|
-
if (hasRequiredPosix) return posix;
|
|
22002
|
-
hasRequiredPosix = 1;
|
|
22003
|
-
Object.defineProperty(posix, '__esModule', {
|
|
22004
|
-
value: true
|
|
22005
|
-
});
|
|
22006
|
-
posix.sync = posix.isexe = void 0;
|
|
22007
|
-
const fs_1 = require$$0$2;
|
|
22008
|
-
const promises_1 = require$$1$1;
|
|
22009
|
-
const isexe = async (path, options = {}) => {
|
|
22010
|
-
const {ignoreErrors: ignoreErrors = false} = options;
|
|
22011
|
-
try {
|
|
22012
|
-
return checkStat(await (0, promises_1.stat)(path), options);
|
|
22013
|
-
} catch (e) {
|
|
22014
|
-
const er = e;
|
|
22015
|
-
if (ignoreErrors || er.code === 'EACCES') return false;
|
|
22016
|
-
throw er;
|
|
22017
|
-
}
|
|
22018
|
-
};
|
|
22019
|
-
posix.isexe = isexe;
|
|
22020
|
-
const sync = (path, options = {}) => {
|
|
22021
|
-
const {ignoreErrors: ignoreErrors = false} = options;
|
|
22022
|
-
try {
|
|
22023
|
-
return checkStat((0, fs_1.statSync)(path), options);
|
|
22024
|
-
} catch (e) {
|
|
22025
|
-
const er = e;
|
|
22026
|
-
if (ignoreErrors || er.code === 'EACCES') return false;
|
|
22027
|
-
throw er;
|
|
22028
|
-
}
|
|
22029
|
-
};
|
|
22030
|
-
posix.sync = sync;
|
|
22031
|
-
const checkStat = (stat, options) => stat.isFile() && checkMode(stat, options);
|
|
22032
|
-
const checkMode = (stat, options) => {
|
|
22033
|
-
const myUid = options.uid ?? process.getuid?.();
|
|
22034
|
-
const myGroups = options.groups ?? process.getgroups?.() ?? [];
|
|
22035
|
-
const myGid = options.gid ?? process.getgid?.() ?? myGroups[0];
|
|
22036
|
-
if (myUid === undefined || myGid === undefined) {
|
|
22037
|
-
throw new Error('cannot get uid or gid');
|
|
22038
|
-
}
|
|
22039
|
-
const groups = new Set([ myGid, ...myGroups ]);
|
|
22040
|
-
const mod = stat.mode;
|
|
22041
|
-
const uid = stat.uid;
|
|
22042
|
-
const gid = stat.gid;
|
|
22043
|
-
const u = parseInt('100', 8);
|
|
22044
|
-
const g = parseInt('010', 8);
|
|
22045
|
-
const o = parseInt('001', 8);
|
|
22046
|
-
const ug = u | g;
|
|
22047
|
-
return !!(mod & o || mod & g && groups.has(gid) || mod & u && uid === myUid || mod & ug && myUid === 0);
|
|
22048
|
-
};
|
|
22049
|
-
return posix;
|
|
22050
|
-
}
|
|
22051
|
-
|
|
22052
|
-
var win32 = {};
|
|
22053
|
-
|
|
22054
|
-
var hasRequiredWin32;
|
|
22055
|
-
|
|
22056
|
-
function requireWin32() {
|
|
22057
|
-
if (hasRequiredWin32) return win32;
|
|
22058
|
-
hasRequiredWin32 = 1;
|
|
22059
|
-
Object.defineProperty(win32, '__esModule', {
|
|
22060
|
-
value: true
|
|
22061
|
-
});
|
|
22062
|
-
win32.sync = win32.isexe = void 0;
|
|
22063
|
-
const fs_1 = require$$0$2;
|
|
22064
|
-
const promises_1 = require$$1$1;
|
|
22065
|
-
const isexe = async (path, options = {}) => {
|
|
22066
|
-
const {ignoreErrors: ignoreErrors = false} = options;
|
|
22067
|
-
try {
|
|
22068
|
-
return checkStat(await (0, promises_1.stat)(path), path, options);
|
|
22069
|
-
} catch (e) {
|
|
22070
|
-
const er = e;
|
|
22071
|
-
if (ignoreErrors || er.code === 'EACCES') return false;
|
|
22072
|
-
throw er;
|
|
22073
|
-
}
|
|
22074
|
-
};
|
|
22075
|
-
win32.isexe = isexe;
|
|
22076
|
-
const sync = (path, options = {}) => {
|
|
22077
|
-
const {ignoreErrors: ignoreErrors = false} = options;
|
|
22078
|
-
try {
|
|
22079
|
-
return checkStat((0, fs_1.statSync)(path), path, options);
|
|
22080
|
-
} catch (e) {
|
|
22081
|
-
const er = e;
|
|
22082
|
-
if (ignoreErrors || er.code === 'EACCES') return false;
|
|
22083
|
-
throw er;
|
|
22084
|
-
}
|
|
22085
|
-
};
|
|
22086
|
-
win32.sync = sync;
|
|
22087
|
-
const checkPathExt = (path, options) => {
|
|
22088
|
-
const {pathExt: pathExt = process.env.PATHEXT || ''} = options;
|
|
22089
|
-
const peSplit = pathExt.split(';');
|
|
22090
|
-
if (peSplit.indexOf('') !== -1) {
|
|
22091
|
-
return true;
|
|
22092
|
-
}
|
|
22093
|
-
for (let i = 0; i < peSplit.length; i++) {
|
|
22094
|
-
const p = peSplit[i].toLowerCase();
|
|
22095
|
-
const ext = path.substring(path.length - p.length).toLowerCase();
|
|
22096
|
-
if (p && ext === p) {
|
|
22097
|
-
return true;
|
|
22098
|
-
}
|
|
22099
|
-
}
|
|
22100
|
-
return false;
|
|
22101
|
-
};
|
|
22102
|
-
const checkStat = (stat, path, options) => stat.isFile() && checkPathExt(path, options);
|
|
22103
|
-
return win32;
|
|
22104
|
-
}
|
|
22105
|
-
|
|
22106
|
-
var options$1 = {};
|
|
22107
|
-
|
|
22108
|
-
var hasRequiredOptions;
|
|
22109
|
-
|
|
22110
|
-
function requireOptions() {
|
|
22111
|
-
if (hasRequiredOptions) return options$1;
|
|
22112
|
-
hasRequiredOptions = 1;
|
|
22113
|
-
Object.defineProperty(options$1, '__esModule', {
|
|
22114
|
-
value: true
|
|
22115
|
-
});
|
|
22116
|
-
return options$1;
|
|
22117
|
-
}
|
|
22118
|
-
|
|
22119
|
-
var hasRequiredCjs;
|
|
22120
|
-
|
|
22121
|
-
function requireCjs() {
|
|
22122
|
-
if (hasRequiredCjs) return cjs;
|
|
22123
|
-
hasRequiredCjs = 1;
|
|
22124
|
-
(function(exports) {
|
|
22125
|
-
var __createBinding = cjs && cjs.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
22126
|
-
if (k2 === undefined) k2 = k;
|
|
22127
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
22128
|
-
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22129
|
-
desc = {
|
|
22130
|
-
enumerable: true,
|
|
22131
|
-
get: function() {
|
|
22132
|
-
return m[k];
|
|
22133
|
-
}
|
|
22134
|
-
};
|
|
22135
|
-
}
|
|
22136
|
-
Object.defineProperty(o, k2, desc);
|
|
22137
|
-
} : function(o, m, k, k2) {
|
|
22138
|
-
if (k2 === undefined) k2 = k;
|
|
22139
|
-
o[k2] = m[k];
|
|
22140
|
-
});
|
|
22141
|
-
var __setModuleDefault = cjs && cjs.__setModuleDefault || (Object.create ? function(o, v) {
|
|
22142
|
-
Object.defineProperty(o, 'default', {
|
|
22143
|
-
enumerable: true,
|
|
22144
|
-
value: v
|
|
22145
|
-
});
|
|
22146
|
-
} : function(o, v) {
|
|
22147
|
-
o['default'] = v;
|
|
22148
|
-
});
|
|
22149
|
-
var __importStar = cjs && cjs.__importStar || function(mod) {
|
|
22150
|
-
if (mod && mod.__esModule) return mod;
|
|
22151
|
-
var result = {};
|
|
22152
|
-
if (mod != null) for (var k in mod) if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22153
|
-
__setModuleDefault(result, mod);
|
|
22154
|
-
return result;
|
|
22155
|
-
};
|
|
22156
|
-
var __exportStar = cjs && cjs.__exportStar || function(m, exports) {
|
|
22157
|
-
for (var p in m) if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22158
|
-
};
|
|
22159
|
-
Object.defineProperty(exports, '__esModule', {
|
|
22160
|
-
value: true
|
|
22161
|
-
});
|
|
22162
|
-
exports.sync = exports.isexe = exports.posix = exports.win32 = void 0;
|
|
22163
|
-
const posix = __importStar(requirePosix());
|
|
22164
|
-
exports.posix = posix;
|
|
22165
|
-
const win32 = __importStar(requireWin32());
|
|
22166
|
-
exports.win32 = win32;
|
|
22167
|
-
__exportStar(requireOptions(), exports);
|
|
22168
|
-
const platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
|
|
22169
|
-
const impl = platform === 'win32' ? win32 : posix;
|
|
22170
|
-
exports.isexe = impl.isexe;
|
|
22171
|
-
exports.sync = impl.sync;
|
|
22172
|
-
})(cjs);
|
|
22173
|
-
return cjs;
|
|
22174
|
-
}
|
|
22175
|
-
|
|
22176
|
-
var lib;
|
|
22177
|
-
|
|
22178
|
-
var hasRequiredLib;
|
|
22179
|
-
|
|
22180
|
-
function requireLib() {
|
|
22181
|
-
if (hasRequiredLib) return lib;
|
|
22182
|
-
hasRequiredLib = 1;
|
|
22183
|
-
const {isexe: isexe, sync: isexeSync} = requireCjs();
|
|
22184
|
-
const {join: join, delimiter: delimiter, sep: sep, posix: posix} = require$$1;
|
|
22185
|
-
const isWindows = process.platform === 'win32';
|
|
22186
|
-
const rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? '' : sep}]`.replace(/(\\)/g, '\\$1'));
|
|
22187
|
-
const rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
22188
|
-
const getNotFoundError = cmd => Object.assign(new Error(`not found: ${cmd}`), {
|
|
22189
|
-
code: 'ENOENT'
|
|
22190
|
-
});
|
|
22191
|
-
const getPathInfo = (cmd, {path: optPath = process.env.PATH, pathExt: optPathExt = process.env.PATHEXT, delimiter: optDelimiter = delimiter}) => {
|
|
22192
|
-
const pathEnv = cmd.match(rSlash) ? [ '' ] : [ ...isWindows ? [ process.cwd() ] : [], ...(optPath || '').split(optDelimiter) ];
|
|
22193
|
-
if (isWindows) {
|
|
22194
|
-
const pathExtExe = optPathExt || [ '.EXE', '.CMD', '.BAT', '.COM' ].join(optDelimiter);
|
|
22195
|
-
const pathExt = pathExtExe.split(optDelimiter).flatMap(item => [ item, item.toLowerCase() ]);
|
|
22196
|
-
if (cmd.includes('.') && pathExt[0] !== '') {
|
|
22197
|
-
pathExt.unshift('');
|
|
22198
|
-
}
|
|
22199
|
-
return {
|
|
22200
|
-
pathEnv: pathEnv,
|
|
22201
|
-
pathExt: pathExt,
|
|
22202
|
-
pathExtExe: pathExtExe
|
|
22203
|
-
};
|
|
22204
|
-
}
|
|
22205
|
-
return {
|
|
22206
|
-
pathEnv: pathEnv,
|
|
22207
|
-
pathExt: [ '' ]
|
|
22208
|
-
};
|
|
22209
|
-
};
|
|
22210
|
-
const getPathPart = (raw, cmd) => {
|
|
22211
|
-
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
22212
|
-
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : '';
|
|
22213
|
-
return prefix + join(pathPart, cmd);
|
|
22214
|
-
};
|
|
22215
|
-
const which = async (cmd, opt = {}) => {
|
|
22216
|
-
const {pathEnv: pathEnv, pathExt: pathExt, pathExtExe: pathExtExe} = getPathInfo(cmd, opt);
|
|
22217
|
-
const found = [];
|
|
22218
|
-
for (const envPart of pathEnv) {
|
|
22219
|
-
const p = getPathPart(envPart, cmd);
|
|
22220
|
-
for (const ext of pathExt) {
|
|
22221
|
-
const withExt = p + ext;
|
|
22222
|
-
const is = await isexe(withExt, {
|
|
22223
|
-
pathExt: pathExtExe,
|
|
22224
|
-
ignoreErrors: true
|
|
22225
|
-
});
|
|
22226
|
-
if (is) {
|
|
22227
|
-
if (!opt.all) {
|
|
22228
|
-
return withExt;
|
|
22229
|
-
}
|
|
22230
|
-
found.push(withExt);
|
|
22231
|
-
}
|
|
22232
|
-
}
|
|
22233
|
-
}
|
|
22234
|
-
if (opt.all && found.length) {
|
|
22235
|
-
return found;
|
|
22236
|
-
}
|
|
22237
|
-
if (opt.nothrow) {
|
|
22238
|
-
return null;
|
|
22239
|
-
}
|
|
22240
|
-
throw getNotFoundError(cmd);
|
|
22241
|
-
};
|
|
22242
|
-
const whichSync = (cmd, opt = {}) => {
|
|
22243
|
-
const {pathEnv: pathEnv, pathExt: pathExt, pathExtExe: pathExtExe} = getPathInfo(cmd, opt);
|
|
22244
|
-
const found = [];
|
|
22245
|
-
for (const pathEnvPart of pathEnv) {
|
|
22246
|
-
const p = getPathPart(pathEnvPart, cmd);
|
|
22247
|
-
for (const ext of pathExt) {
|
|
22248
|
-
const withExt = p + ext;
|
|
22249
|
-
const is = isexeSync(withExt, {
|
|
22250
|
-
pathExt: pathExtExe,
|
|
22251
|
-
ignoreErrors: true
|
|
22252
|
-
});
|
|
22253
|
-
if (is) {
|
|
22254
|
-
if (!opt.all) {
|
|
22255
|
-
return withExt;
|
|
22256
|
-
}
|
|
22257
|
-
found.push(withExt);
|
|
22258
|
-
}
|
|
22259
|
-
}
|
|
22260
|
-
}
|
|
22261
|
-
if (opt.all && found.length) {
|
|
22262
|
-
return found;
|
|
22263
|
-
}
|
|
22264
|
-
if (opt.nothrow) {
|
|
22265
|
-
return null;
|
|
22266
|
-
}
|
|
22267
|
-
throw getNotFoundError(cmd);
|
|
22268
|
-
};
|
|
22269
|
-
lib = which;
|
|
22270
|
-
which.sync = whichSync;
|
|
22271
|
-
return lib;
|
|
22272
|
-
}
|
|
22273
|
-
|
|
22274
|
-
var libExports = requireLib();
|
|
22275
|
-
|
|
22276
|
-
const which = getDefaultExportFromCjs(libExports);
|
|
22277
|
-
|
|
22278
|
-
const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
22279
|
-
|
|
22280
|
-
function findUpSync(name, {cwd: cwd = process$1.cwd(), type: type = 'file', stopAt: stopAt} = {}) {
|
|
22281
|
-
let directory = path__default.resolve(toPath(cwd) ?? '');
|
|
22282
|
-
const {root: root} = path__default.parse(directory);
|
|
22283
|
-
stopAt = path__default.resolve(directory, toPath(stopAt) ?? root);
|
|
22284
|
-
const isAbsoluteName = path__default.isAbsolute(name);
|
|
22285
|
-
while (directory) {
|
|
22286
|
-
const filePath = isAbsoluteName ? name : path__default.join(directory, name);
|
|
22287
|
-
try {
|
|
22288
|
-
const stats = fs$2.statSync(filePath, {
|
|
22289
|
-
throwIfNoEntry: false
|
|
22290
|
-
});
|
|
22291
|
-
if (type === 'file' && stats?.isFile() || type === 'directory' && stats?.isDirectory()) {
|
|
22292
|
-
return filePath;
|
|
22293
|
-
}
|
|
22294
|
-
} catch {}
|
|
22295
|
-
if (directory === stopAt || directory === root) {
|
|
22296
|
-
break;
|
|
22297
|
-
}
|
|
22298
|
-
directory = path__default.dirname(directory);
|
|
22299
|
-
}
|
|
22300
|
-
}
|
|
22301
|
-
|
|
22302
|
-
function packageUpSync({cwd: cwd = process$1.cwd()} = {}) {
|
|
22303
|
-
return findUpSync('package.json', {
|
|
22304
|
-
cwd: cwd
|
|
22305
|
-
});
|
|
22306
|
-
}
|
|
22307
|
-
|
|
22308
|
-
function findPathToModule(dir, moduleNames) {
|
|
22309
|
-
const stat = statSync(dir);
|
|
22310
|
-
if (stat.isDirectory()) {
|
|
22311
|
-
const candidates = moduleNames.map(moduleName => resolve(dir, moduleName));
|
|
22312
|
-
const modulePath = candidates.find(existsSync);
|
|
22313
|
-
if (modulePath) {
|
|
22314
|
-
return modulePath;
|
|
22315
|
-
}
|
|
22316
|
-
}
|
|
22317
|
-
const parent = resolve(dir, '..');
|
|
22318
|
-
if (parent !== dir) {
|
|
22319
|
-
return findPathToModule(parent, moduleNames);
|
|
22320
|
-
}
|
|
22321
|
-
}
|
|
22322
|
-
|
|
22323
|
-
class TypeScriptVersion {
|
|
22324
|
-
constructor(source, path, logger) {
|
|
22325
|
-
this.source = source;
|
|
22326
|
-
this.path = path;
|
|
22327
|
-
this.logger = logger;
|
|
22328
|
-
this._api = null;
|
|
22329
|
-
}
|
|
22330
|
-
get tsServerPath() {
|
|
22331
|
-
return this.path;
|
|
22332
|
-
}
|
|
22333
|
-
get isValid() {
|
|
22334
|
-
return this.version !== null;
|
|
22335
|
-
}
|
|
22336
|
-
get version() {
|
|
22337
|
-
if (this._api) {
|
|
22338
|
-
return this._api;
|
|
22339
|
-
}
|
|
22340
|
-
this._api = this.getTypeScriptVersion(this.tsServerPath);
|
|
22341
|
-
return this._api;
|
|
22342
|
-
}
|
|
22343
|
-
get versionString() {
|
|
22344
|
-
const version = this.version;
|
|
22345
|
-
return version ? version.displayName : null;
|
|
22346
|
-
}
|
|
22347
|
-
getTypeScriptVersion(serverPath) {
|
|
22348
|
-
this.logger.log(`Resolving TypeScript version from path "${serverPath}"...`);
|
|
22349
|
-
if (!fs$2.existsSync(serverPath)) {
|
|
22350
|
-
this.logger.log('Server path does not exist on disk');
|
|
22351
|
-
return null;
|
|
22352
|
-
}
|
|
22353
|
-
const p = serverPath.split(path__default.sep);
|
|
22354
|
-
if (p.length <= 2) {
|
|
22355
|
-
this.logger.log('Server path is invalid (has less than two path components).');
|
|
22356
|
-
return null;
|
|
22357
|
-
}
|
|
22358
|
-
const p2 = p.slice(0, -2);
|
|
22359
|
-
const modulePath = p2.join(path__default.sep);
|
|
22360
|
-
let fileName = path__default.join(modulePath, 'package.json');
|
|
22361
|
-
if (!fs$2.existsSync(fileName)) {
|
|
22362
|
-
if (path__default.basename(modulePath) === 'built') {
|
|
22363
|
-
fileName = path__default.join(modulePath, '..', 'package.json');
|
|
22364
|
-
}
|
|
22365
|
-
}
|
|
22366
|
-
if (!fs$2.existsSync(fileName)) {
|
|
22367
|
-
this.logger.log(`Failed to find package.json at path "${fileName}"`);
|
|
22368
|
-
return null;
|
|
22369
|
-
}
|
|
22370
|
-
this.logger.log(`Reading version from package.json at "${fileName}"`);
|
|
22371
|
-
const contents = fs$2.readFileSync(fileName).toString();
|
|
22372
|
-
let desc = null;
|
|
22373
|
-
try {
|
|
22374
|
-
desc = JSON.parse(contents);
|
|
22375
|
-
} catch {
|
|
22376
|
-
this.logger.log('Failed parsing contents of package.json.');
|
|
22377
|
-
return null;
|
|
22378
|
-
}
|
|
22379
|
-
if (!desc?.version) {
|
|
22380
|
-
this.logger.log('Failed reading version number from package.json.');
|
|
22381
|
-
return null;
|
|
22382
|
-
}
|
|
22383
|
-
this.logger.log(`Resolved TypeScript version to "${desc.version}"`);
|
|
22384
|
-
return API.fromVersionString(desc.version);
|
|
22582
|
+
return mainExports$2.InlayHintKind.Parameter;
|
|
22583
|
+
|
|
22584
|
+
case 'Type':
|
|
22585
|
+
return mainExports$2.InlayHintKind.Type;
|
|
22586
|
+
|
|
22587
|
+
case 'Enum':
|
|
22588
|
+
return undefined;
|
|
22589
|
+
|
|
22590
|
+
default:
|
|
22591
|
+
return undefined;
|
|
22385
22592
|
}
|
|
22386
22593
|
}
|
|
22387
22594
|
|
|
22388
|
-
|
|
22595
|
+
var TokenEncodingConsts;
|
|
22389
22596
|
|
|
22390
|
-
|
|
22391
|
-
|
|
22392
|
-
|
|
22393
|
-
|
|
22597
|
+
(function(TokenEncodingConsts) {
|
|
22598
|
+
TokenEncodingConsts[TokenEncodingConsts['typeOffset'] = 8] = 'typeOffset';
|
|
22599
|
+
TokenEncodingConsts[TokenEncodingConsts['modifierMask'] = 255] = 'modifierMask';
|
|
22600
|
+
})(TokenEncodingConsts || (TokenEncodingConsts = {}));
|
|
22601
|
+
|
|
22602
|
+
function transformSpans(doc, spans) {
|
|
22603
|
+
const lspSpans = [];
|
|
22604
|
+
let previousLine = 0;
|
|
22605
|
+
let previousTokenStart = 0;
|
|
22606
|
+
for (let i = 0; i < spans.length; i += 3) {
|
|
22607
|
+
const tokenStart = spans[i];
|
|
22608
|
+
const tokenLength = spans[i + 1];
|
|
22609
|
+
const tokenTypeBitSet = spans[i + 2];
|
|
22610
|
+
const tokenModifier = tokenTypeBitSet & TokenEncodingConsts.modifierMask;
|
|
22611
|
+
const tokenType = (tokenTypeBitSet >> TokenEncodingConsts.typeOffset) - 1;
|
|
22612
|
+
const {line: line, character: character} = doc.positionAt(tokenStart);
|
|
22613
|
+
const deltaLine = line - previousLine;
|
|
22614
|
+
const deltaStart = previousLine === line ? character - previousTokenStart : character;
|
|
22615
|
+
lspSpans.push(deltaLine, deltaStart, tokenLength, tokenType, tokenModifier);
|
|
22616
|
+
previousTokenStart = character;
|
|
22617
|
+
previousLine = line;
|
|
22394
22618
|
}
|
|
22395
|
-
|
|
22396
|
-
|
|
22397
|
-
|
|
22398
|
-
|
|
22399
|
-
|
|
22400
|
-
|
|
22401
|
-
|
|
22402
|
-
|
|
22403
|
-
|
|
22404
|
-
|
|
22405
|
-
if (binaryPath) {
|
|
22406
|
-
resolvedPath = binaryPath;
|
|
22407
|
-
}
|
|
22408
|
-
this.logger.log(`Non-absolute tsserver path resolved to "${binaryPath ? resolvedPath : '<failed>'}"`);
|
|
22409
|
-
}
|
|
22410
|
-
let stat = fs$2.lstatSync(resolvedPath, {
|
|
22411
|
-
throwIfNoEntry: false
|
|
22412
|
-
});
|
|
22413
|
-
if (stat?.isSymbolicLink()) {
|
|
22414
|
-
resolvedPath = fs$2.realpathSync(resolvedPath);
|
|
22415
|
-
this.logger.log(`Symbolic link tsserver path resolved to "${resolvedPath}"`);
|
|
22619
|
+
return lspSpans;
|
|
22620
|
+
}
|
|
22621
|
+
|
|
22622
|
+
class CachedResponse {
|
|
22623
|
+
response;
|
|
22624
|
+
version=-1;
|
|
22625
|
+
document='';
|
|
22626
|
+
execute(document, resolve) {
|
|
22627
|
+
if (this.response && this.matches(document)) {
|
|
22628
|
+
return this.response = this.response.then(result => result.type === 'cancelled' ? resolve() : result);
|
|
22416
22629
|
}
|
|
22417
|
-
|
|
22418
|
-
|
|
22419
|
-
|
|
22420
|
-
if (
|
|
22421
|
-
|
|
22422
|
-
|
|
22423
|
-
|
|
22424
|
-
}
|
|
22425
|
-
resolvedPath = path__default.dirname(resolvedPath);
|
|
22426
|
-
this.logger.log(`Resolved directory path from a file path: ${resolvedPath}`);
|
|
22630
|
+
return this.reset(document, resolve);
|
|
22631
|
+
}
|
|
22632
|
+
onDocumentClose(document) {
|
|
22633
|
+
if (this.document === document.uri.toString()) {
|
|
22634
|
+
this.response = undefined;
|
|
22635
|
+
this.version = -1;
|
|
22636
|
+
this.document = '';
|
|
22427
22637
|
}
|
|
22428
|
-
try {
|
|
22429
|
-
const packageJsonPath = packageUpSync({
|
|
22430
|
-
cwd: resolvedPath
|
|
22431
|
-
});
|
|
22432
|
-
this.logger.log(`Resolved package.json location: "${packageJsonPath}"`);
|
|
22433
|
-
if (packageJsonPath) {
|
|
22434
|
-
resolvedPath = path__default.join(path__default.dirname(packageJsonPath), 'lib', 'tsserver.js');
|
|
22435
|
-
this.logger.log(`Resolved tsserver location: "${resolvedPath}"`);
|
|
22436
|
-
}
|
|
22437
|
-
} catch {}
|
|
22438
|
-
return new TypeScriptVersion('user-setting', resolvedPath, this.logger);
|
|
22439
22638
|
}
|
|
22440
|
-
|
|
22441
|
-
|
|
22442
|
-
|
|
22443
|
-
|
|
22444
|
-
|
|
22445
|
-
|
|
22446
|
-
|
|
22447
|
-
|
|
22448
|
-
|
|
22639
|
+
matches(document) {
|
|
22640
|
+
return this.version === document.version && this.document === document.uri.toString();
|
|
22641
|
+
}
|
|
22642
|
+
async reset(document, resolve) {
|
|
22643
|
+
this.version = document.version;
|
|
22644
|
+
this.document = document.uri.toString();
|
|
22645
|
+
return this.response = resolve();
|
|
22646
|
+
}
|
|
22647
|
+
}
|
|
22648
|
+
|
|
22649
|
+
class LogDirectoryProvider {
|
|
22650
|
+
rootPath;
|
|
22651
|
+
constructor(rootPath) {
|
|
22652
|
+
this.rootPath = rootPath;
|
|
22653
|
+
}
|
|
22654
|
+
getNewLogDirectory() {
|
|
22655
|
+
const root = this.logDirectory();
|
|
22656
|
+
if (root) {
|
|
22657
|
+
try {
|
|
22658
|
+
return fs$2.mkdtempSync(path__default.join(root, 'tsserver-log-'));
|
|
22659
|
+
} catch {
|
|
22660
|
+
return undefined;
|
|
22449
22661
|
}
|
|
22450
22662
|
}
|
|
22451
|
-
return
|
|
22663
|
+
return undefined;
|
|
22452
22664
|
}
|
|
22453
|
-
|
|
22454
|
-
|
|
22665
|
+
logDirectory() {
|
|
22666
|
+
if (!this.rootPath) {
|
|
22667
|
+
return undefined;
|
|
22668
|
+
}
|
|
22455
22669
|
try {
|
|
22456
|
-
|
|
22457
|
-
|
|
22458
|
-
|
|
22459
|
-
return
|
|
22670
|
+
if (!fs$2.existsSync(this.rootPath)) {
|
|
22671
|
+
fs$2.mkdirSync(this.rootPath);
|
|
22672
|
+
}
|
|
22673
|
+
return this.rootPath;
|
|
22460
22674
|
} catch {
|
|
22461
|
-
return
|
|
22675
|
+
return undefined;
|
|
22462
22676
|
}
|
|
22463
22677
|
}
|
|
22464
22678
|
}
|
|
22465
22679
|
|
|
22466
22680
|
class CommandManager {
|
|
22467
|
-
|
|
22468
|
-
this.commands = new Map;
|
|
22469
|
-
}
|
|
22681
|
+
commands=new Map;
|
|
22470
22682
|
dispose() {
|
|
22471
22683
|
this.commands.clear();
|
|
22472
22684
|
}
|
|
@@ -22476,13 +22688,18 @@ class CommandManager {
|
|
|
22476
22688
|
this.commands.set(command.id, command);
|
|
22477
22689
|
}
|
|
22478
22690
|
}
|
|
22691
|
+
get registeredIds() {
|
|
22692
|
+
return Array.from(this.commands.keys());
|
|
22693
|
+
}
|
|
22694
|
+
handlesCommand(commandId) {
|
|
22695
|
+
return this.commands.has(commandId);
|
|
22696
|
+
}
|
|
22479
22697
|
async handle(commandId, ...args) {
|
|
22480
22698
|
const entry = this.commands.get(commandId);
|
|
22481
22699
|
if (entry) {
|
|
22482
|
-
await entry.execute(...args);
|
|
22483
|
-
return true;
|
|
22700
|
+
return await entry.execute(...args);
|
|
22484
22701
|
}
|
|
22485
|
-
return
|
|
22702
|
+
return null;
|
|
22486
22703
|
}
|
|
22487
22704
|
}
|
|
22488
22705
|
|
|
@@ -22527,6 +22744,13 @@ const unreachableCode = 'fixUnreachableCode';
|
|
|
22527
22744
|
const unusedIdentifier = 'unusedIdentifier';
|
|
22528
22745
|
|
|
22529
22746
|
class TsCodeAction {
|
|
22747
|
+
title;
|
|
22748
|
+
kind;
|
|
22749
|
+
command;
|
|
22750
|
+
diagnostics;
|
|
22751
|
+
disabled;
|
|
22752
|
+
edit;
|
|
22753
|
+
isPreferred;
|
|
22530
22754
|
constructor(title, kind) {
|
|
22531
22755
|
this.title = title;
|
|
22532
22756
|
this.kind = kind;
|
|
@@ -22631,6 +22855,7 @@ async function buildCombinedFix(fixes, client, file, diagnostics, token) {
|
|
|
22631
22855
|
class SourceAction extends TsCodeAction {}
|
|
22632
22856
|
|
|
22633
22857
|
class SourceFixAll extends SourceAction {
|
|
22858
|
+
static kind=CodeActionKind.SourceFixAllTs;
|
|
22634
22859
|
constructor() {
|
|
22635
22860
|
super('Fix all fixable JS/TS issues', SourceFixAll.kind.value);
|
|
22636
22861
|
}
|
|
@@ -22652,9 +22877,8 @@ class SourceFixAll extends SourceAction {
|
|
|
22652
22877
|
}
|
|
22653
22878
|
}
|
|
22654
22879
|
|
|
22655
|
-
SourceFixAll.kind = CodeActionKind.SourceFixAllTs;
|
|
22656
|
-
|
|
22657
22880
|
class SourceRemoveUnused extends SourceAction {
|
|
22881
|
+
static kind=CodeActionKind.SourceRemoveUnusedTs;
|
|
22658
22882
|
constructor() {
|
|
22659
22883
|
super('Remove all unused code', SourceRemoveUnused.kind.value);
|
|
22660
22884
|
}
|
|
@@ -22666,9 +22890,8 @@ class SourceRemoveUnused extends SourceAction {
|
|
|
22666
22890
|
}
|
|
22667
22891
|
}
|
|
22668
22892
|
|
|
22669
|
-
SourceRemoveUnused.kind = CodeActionKind.SourceRemoveUnusedTs;
|
|
22670
|
-
|
|
22671
22893
|
class SourceAddMissingImports extends SourceAction {
|
|
22894
|
+
static kind=CodeActionKind.SourceAddMissingImportsTs;
|
|
22672
22895
|
constructor() {
|
|
22673
22896
|
super('Add all missing imports', SourceAddMissingImports.kind.value);
|
|
22674
22897
|
}
|
|
@@ -22680,9 +22903,11 @@ class SourceAddMissingImports extends SourceAction {
|
|
|
22680
22903
|
}
|
|
22681
22904
|
}
|
|
22682
22905
|
|
|
22683
|
-
SourceAddMissingImports.kind = CodeActionKind.SourceAddMissingImportsTs;
|
|
22684
|
-
|
|
22685
22906
|
class TypeScriptAutoFixProvider {
|
|
22907
|
+
client;
|
|
22908
|
+
fileConfigurationManager;
|
|
22909
|
+
diagnosticsManager;
|
|
22910
|
+
static kindProviders=[ SourceFixAll, SourceRemoveUnused, SourceAddMissingImports ];
|
|
22686
22911
|
constructor(client, fileConfigurationManager, diagnosticsManager) {
|
|
22687
22912
|
this.client = client;
|
|
22688
22913
|
this.fileConfigurationManager = fileConfigurationManager;
|
|
@@ -22724,12 +22949,13 @@ class TypeScriptAutoFixProvider {
|
|
|
22724
22949
|
}
|
|
22725
22950
|
}
|
|
22726
22951
|
|
|
22727
|
-
TypeScriptAutoFixProvider.kindProviders = [ SourceFixAll, SourceRemoveUnused, SourceAddMissingImports ];
|
|
22728
|
-
|
|
22729
22952
|
class Lazy {
|
|
22953
|
+
executor;
|
|
22954
|
+
_didRun=false;
|
|
22955
|
+
_value;
|
|
22956
|
+
_error;
|
|
22730
22957
|
constructor(executor) {
|
|
22731
22958
|
this.executor = executor;
|
|
22732
|
-
this._didRun = false;
|
|
22733
22959
|
}
|
|
22734
22960
|
get hasValue() {
|
|
22735
22961
|
return this._didRun;
|
|
@@ -22772,9 +22998,11 @@ async function applyCodeActionCommands(client, commands, token) {
|
|
|
22772
22998
|
}
|
|
22773
22999
|
|
|
22774
23000
|
class ApplyCodeActionCommand {
|
|
23001
|
+
client;
|
|
23002
|
+
static ID='_typescript.applyCodeActionCommand';
|
|
23003
|
+
id=ApplyCodeActionCommand.ID;
|
|
22775
23004
|
constructor(client) {
|
|
22776
23005
|
this.client = client;
|
|
22777
|
-
this.id = ApplyCodeActionCommand.ID;
|
|
22778
23006
|
}
|
|
22779
23007
|
async execute({action: action}) {
|
|
22780
23008
|
const codeActionResult = await applyCodeActionCommands(this.client, action.commands);
|
|
@@ -22782,13 +23010,14 @@ class ApplyCodeActionCommand {
|
|
|
22782
23010
|
}
|
|
22783
23011
|
}
|
|
22784
23012
|
|
|
22785
|
-
ApplyCodeActionCommand.ID = '_typescript.applyCodeActionCommand';
|
|
22786
|
-
|
|
22787
23013
|
class ApplyFixAllCodeAction {
|
|
23014
|
+
client;
|
|
23015
|
+
tsCodeActionProvider;
|
|
23016
|
+
static ID='_typescript.applyFixAllCodeAction';
|
|
23017
|
+
id=ApplyFixAllCodeAction.ID;
|
|
22788
23018
|
constructor(client, tsCodeActionProvider) {
|
|
22789
23019
|
this.client = client;
|
|
22790
23020
|
this.tsCodeActionProvider = tsCodeActionProvider;
|
|
22791
|
-
this.id = ApplyFixAllCodeAction.ID;
|
|
22792
23021
|
}
|
|
22793
23022
|
async execute(args) {
|
|
22794
23023
|
const tsAction = this.tsCodeActionProvider.getQuickFixAllTsCodeActionByFixName(args.tsActionId);
|
|
@@ -22798,9 +23027,8 @@ class ApplyFixAllCodeAction {
|
|
|
22798
23027
|
}
|
|
22799
23028
|
}
|
|
22800
23029
|
|
|
22801
|
-
ApplyFixAllCodeAction.ID = '_typescript.applyFixAllCodeAction';
|
|
22802
|
-
|
|
22803
23030
|
class DiagnosticsSet {
|
|
23031
|
+
_values;
|
|
22804
23032
|
static from(diagnostics) {
|
|
22805
23033
|
const values = new Map;
|
|
22806
23034
|
for (const diagnostic of diagnostics) {
|
|
@@ -22824,6 +23052,7 @@ class DiagnosticsSet {
|
|
|
22824
23052
|
}
|
|
22825
23053
|
|
|
22826
23054
|
class TsQuickFixCodeAction extends TsCodeAction {
|
|
23055
|
+
tsAction;
|
|
22827
23056
|
constructor(tsAction, title, kind) {
|
|
22828
23057
|
super(title, kind);
|
|
22829
23058
|
this.tsAction = tsAction;
|
|
@@ -22831,18 +23060,18 @@ class TsQuickFixCodeAction extends TsCodeAction {
|
|
|
22831
23060
|
}
|
|
22832
23061
|
|
|
22833
23062
|
class TsQuickFixAllCodeAction extends TsQuickFixCodeAction {
|
|
23063
|
+
file;
|
|
22834
23064
|
constructor(tsAction, file, title, kind) {
|
|
22835
23065
|
super(tsAction, title, kind);
|
|
22836
23066
|
this.file = file;
|
|
22837
23067
|
}
|
|
23068
|
+
combinedResponse;
|
|
22838
23069
|
}
|
|
22839
23070
|
|
|
22840
23071
|
class CodeActionSet {
|
|
22841
|
-
|
|
22842
|
-
|
|
22843
|
-
|
|
22844
|
-
this._aiActions = new Set;
|
|
22845
|
-
}
|
|
23072
|
+
_actions=new Set;
|
|
23073
|
+
_fixAllActions=new Map;
|
|
23074
|
+
_aiActions=new Set;
|
|
22846
23075
|
* values() {
|
|
22847
23076
|
yield* this._actions;
|
|
22848
23077
|
yield* this._aiActions;
|
|
@@ -22876,23 +23105,30 @@ class CodeActionSet {
|
|
|
22876
23105
|
}
|
|
22877
23106
|
|
|
22878
23107
|
class SupportedCodeActionProvider {
|
|
23108
|
+
client;
|
|
22879
23109
|
constructor(client) {
|
|
22880
23110
|
this.client = client;
|
|
22881
|
-
this.fixableDiagnosticCodes = new Lazy(() => this.client.execute(CommandTypes.GetSupportedCodeFixes, null).then(response => response.type === 'response' ? response.body || [] : []).then(codes => new Set(codes)));
|
|
22882
23111
|
}
|
|
22883
23112
|
async getFixableDiagnosticsForContext(diagnostics) {
|
|
22884
23113
|
const fixableCodes = await this.fixableDiagnosticCodes.value;
|
|
22885
23114
|
return DiagnosticsSet.from(diagnostics.filter(diagnostic => typeof diagnostic.code !== 'undefined' && fixableCodes.has(diagnostic.code + '')));
|
|
22886
23115
|
}
|
|
23116
|
+
fixableDiagnosticCodes=new Lazy(() => this.client.execute(CommandTypes.GetSupportedCodeFixes, null).then(response => response.type === 'response' ? response.body || [] : []).then(codes => new Set(codes)));
|
|
22887
23117
|
}
|
|
22888
23118
|
|
|
22889
23119
|
class TypeScriptQuickFixProvider {
|
|
23120
|
+
client;
|
|
23121
|
+
fileConfigurationManager;
|
|
23122
|
+
diagnosticsManager;
|
|
23123
|
+
features;
|
|
23124
|
+
static _maxCodeActionsPerFile=1e3;
|
|
23125
|
+
_quickFixAllTsCodeActionMap=new Map;
|
|
23126
|
+
supportedCodeActionProvider;
|
|
22890
23127
|
constructor(client, fileConfigurationManager, commandManager, diagnosticsManager, features) {
|
|
22891
23128
|
this.client = client;
|
|
22892
23129
|
this.fileConfigurationManager = fileConfigurationManager;
|
|
22893
23130
|
this.diagnosticsManager = diagnosticsManager;
|
|
22894
23131
|
this.features = features;
|
|
22895
|
-
this._quickFixAllTsCodeActionMap = new Map;
|
|
22896
23132
|
commandManager.register(new ApplyCodeActionCommand(client));
|
|
22897
23133
|
commandManager.register(new ApplyFixAllCodeAction(client, this));
|
|
22898
23134
|
this.supportedCodeActionProvider = new SupportedCodeActionProvider(client);
|
|
@@ -23035,8 +23271,6 @@ class TypeScriptQuickFixProvider {
|
|
|
23035
23271
|
}
|
|
23036
23272
|
}
|
|
23037
23273
|
|
|
23038
|
-
TypeScriptQuickFixProvider._maxCodeActionsPerFile = 1e3;
|
|
23039
|
-
|
|
23040
23274
|
const fixAllErrorCodes = new Map([ [ 2339, 2339 ], [ 2345, 2339 ] ]);
|
|
23041
23275
|
|
|
23042
23276
|
const preferredFixes = new Map([ [ annotateWithTypeFromJSDoc, {
|
|
@@ -23108,12 +23342,13 @@ const nulToken = {
|
|
|
23108
23342
|
};
|
|
23109
23343
|
|
|
23110
23344
|
class CodeActionManager {
|
|
23345
|
+
features;
|
|
23346
|
+
providerMap=new Map;
|
|
23347
|
+
nextProviderId=1;
|
|
23348
|
+
resolveCodeActionsMap=new Map;
|
|
23349
|
+
nextGlobalCodeActionId=1;
|
|
23111
23350
|
constructor(client, fileConfigurationManager, commandManager, diagnosticsManager, features) {
|
|
23112
23351
|
this.features = features;
|
|
23113
|
-
this.providerMap = new Map;
|
|
23114
|
-
this.nextProviderId = 1;
|
|
23115
|
-
this.resolveCodeActionsMap = new Map;
|
|
23116
|
-
this.nextGlobalCodeActionId = 1;
|
|
23117
23352
|
this.addProvider(new TypeScriptAutoFixProvider(client, fileConfigurationManager, diagnosticsManager));
|
|
23118
23353
|
this.addProvider(new TypeScriptQuickFixProvider(client, fileConfigurationManager, commandManager, diagnosticsManager, features));
|
|
23119
23354
|
}
|
|
@@ -23184,21 +23419,307 @@ class CodeActionManager {
|
|
|
23184
23419
|
}
|
|
23185
23420
|
}
|
|
23186
23421
|
|
|
23422
|
+
class WatchEventManager {
|
|
23423
|
+
options;
|
|
23424
|
+
watchers=new Map;
|
|
23425
|
+
coverage=new Map;
|
|
23426
|
+
coverageUsage=new Map;
|
|
23427
|
+
workspacePaths;
|
|
23428
|
+
registration;
|
|
23429
|
+
registrationHash;
|
|
23430
|
+
updateRegistrationQueue=Promise.resolve();
|
|
23431
|
+
readyForRegistration=false;
|
|
23432
|
+
disposed=false;
|
|
23433
|
+
constructor(options) {
|
|
23434
|
+
this.options = options;
|
|
23435
|
+
this.workspacePaths = options.workspaceFolders.map(folder => this.normalizePath(folder.fsPath));
|
|
23436
|
+
for (const folder of options.workspaceFolders) {
|
|
23437
|
+
const key = this.coverageKey(folder.fsPath, '**/*');
|
|
23438
|
+
const kind = mainExports$2.WatchKind.Create | mainExports$2.WatchKind.Change | mainExports$2.WatchKind.Delete;
|
|
23439
|
+
const entry = {
|
|
23440
|
+
key: key,
|
|
23441
|
+
normalizedBase: this.normalizePath(folder.fsPath),
|
|
23442
|
+
watcher: {
|
|
23443
|
+
globPattern: {
|
|
23444
|
+
baseUri: folder.toString(),
|
|
23445
|
+
pattern: '**/*'
|
|
23446
|
+
},
|
|
23447
|
+
kind: kind
|
|
23448
|
+
},
|
|
23449
|
+
watchKind: kind,
|
|
23450
|
+
permanent: true
|
|
23451
|
+
};
|
|
23452
|
+
this.coverage.set(key, entry);
|
|
23453
|
+
}
|
|
23454
|
+
}
|
|
23455
|
+
onInitialized() {
|
|
23456
|
+
this.readyForRegistration = true;
|
|
23457
|
+
this.updateRegistration();
|
|
23458
|
+
}
|
|
23459
|
+
dispose() {
|
|
23460
|
+
this.disposed = true;
|
|
23461
|
+
this.registration?.dispose();
|
|
23462
|
+
this.registration = undefined;
|
|
23463
|
+
this.watchers.clear();
|
|
23464
|
+
this.coverage.clear();
|
|
23465
|
+
this.coverageUsage.clear();
|
|
23466
|
+
}
|
|
23467
|
+
handleTsserverEvent(event) {
|
|
23468
|
+
switch (event.event) {
|
|
23469
|
+
case EventName.createFileWatcher:
|
|
23470
|
+
this.addFileWatcher(event.body);
|
|
23471
|
+
return true;
|
|
23472
|
+
|
|
23473
|
+
case EventName.createDirectoryWatcher:
|
|
23474
|
+
this.addDirectoryWatcher(event.body);
|
|
23475
|
+
return true;
|
|
23476
|
+
|
|
23477
|
+
case EventName.closeFileWatcher:
|
|
23478
|
+
this.closeWatcher(event.body);
|
|
23479
|
+
return true;
|
|
23480
|
+
|
|
23481
|
+
default:
|
|
23482
|
+
return false;
|
|
23483
|
+
}
|
|
23484
|
+
}
|
|
23485
|
+
handleFileChanges(params) {
|
|
23486
|
+
if (!this.watchers.size || !params.changes.length) {
|
|
23487
|
+
return;
|
|
23488
|
+
}
|
|
23489
|
+
const collected = new Map;
|
|
23490
|
+
for (const change of params.changes) {
|
|
23491
|
+
const uri = URI.parse(change.uri);
|
|
23492
|
+
const fsPath = uri.fsPath;
|
|
23493
|
+
const normalizedFsPath = this.normalizePath(fsPath);
|
|
23494
|
+
for (const watcher of this.watchers.values()) {
|
|
23495
|
+
if (!this.watcherMatchesPath(watcher, normalizedFsPath)) {
|
|
23496
|
+
continue;
|
|
23497
|
+
}
|
|
23498
|
+
if (change.type === mainExports$2.FileChangeType.Changed && watcher.ignoreUpdate) {
|
|
23499
|
+
continue;
|
|
23500
|
+
}
|
|
23501
|
+
const changes = this.ensureChangeBucket(collected, watcher.id);
|
|
23502
|
+
switch (change.type) {
|
|
23503
|
+
case mainExports$2.FileChangeType.Created:
|
|
23504
|
+
changes.created.push(normalizedFsPath);
|
|
23505
|
+
break;
|
|
23506
|
+
|
|
23507
|
+
case mainExports$2.FileChangeType.Deleted:
|
|
23508
|
+
changes.deleted.push(normalizedFsPath);
|
|
23509
|
+
break;
|
|
23510
|
+
|
|
23511
|
+
case mainExports$2.FileChangeType.Changed:
|
|
23512
|
+
changes.updated.push(normalizedFsPath);
|
|
23513
|
+
break;
|
|
23514
|
+
}
|
|
23515
|
+
}
|
|
23516
|
+
}
|
|
23517
|
+
if (!collected.size) {
|
|
23518
|
+
return;
|
|
23519
|
+
}
|
|
23520
|
+
const payload = [];
|
|
23521
|
+
for (const [id, changes] of collected.entries()) {
|
|
23522
|
+
payload.push({
|
|
23523
|
+
id: id,
|
|
23524
|
+
created: changes.created.length ? changes.created : undefined,
|
|
23525
|
+
deleted: changes.deleted.length ? changes.deleted : undefined,
|
|
23526
|
+
updated: changes.updated.length ? changes.updated : undefined
|
|
23527
|
+
});
|
|
23528
|
+
}
|
|
23529
|
+
this.options.sendWatchChanges(payload.length === 1 ? payload[0] : payload);
|
|
23530
|
+
}
|
|
23531
|
+
ensureChangeBucket(collected, id) {
|
|
23532
|
+
let bucket = collected.get(id);
|
|
23533
|
+
if (!bucket) {
|
|
23534
|
+
bucket = {
|
|
23535
|
+
created: [],
|
|
23536
|
+
deleted: [],
|
|
23537
|
+
updated: []
|
|
23538
|
+
};
|
|
23539
|
+
collected.set(id, bucket);
|
|
23540
|
+
}
|
|
23541
|
+
return bucket;
|
|
23542
|
+
}
|
|
23543
|
+
addFileWatcher(body) {
|
|
23544
|
+
const normalizedPath = this.normalizePath(body.path);
|
|
23545
|
+
const watcher = {
|
|
23546
|
+
id: body.id,
|
|
23547
|
+
path: body.path,
|
|
23548
|
+
normalizedPath: normalizedPath,
|
|
23549
|
+
kind: 'file',
|
|
23550
|
+
recursive: false,
|
|
23551
|
+
ignoreUpdate: false
|
|
23552
|
+
};
|
|
23553
|
+
watcher.coverageKey = this.ensureCoverageForWatcher(watcher);
|
|
23554
|
+
this.watchers.set(body.id, watcher);
|
|
23555
|
+
}
|
|
23556
|
+
addDirectoryWatcher(body) {
|
|
23557
|
+
const normalizedPath = this.normalizePath(body.path);
|
|
23558
|
+
const watcher = {
|
|
23559
|
+
id: body.id,
|
|
23560
|
+
path: body.path,
|
|
23561
|
+
normalizedPath: normalizedPath,
|
|
23562
|
+
kind: 'directory',
|
|
23563
|
+
recursive: !!body.recursive,
|
|
23564
|
+
ignoreUpdate: !!body.ignoreUpdate
|
|
23565
|
+
};
|
|
23566
|
+
watcher.coverageKey = this.ensureCoverageForWatcher(watcher);
|
|
23567
|
+
this.watchers.set(body.id, watcher);
|
|
23568
|
+
}
|
|
23569
|
+
closeWatcher(body) {
|
|
23570
|
+
const watcher = this.watchers.get(body.id);
|
|
23571
|
+
if (!watcher) {
|
|
23572
|
+
return;
|
|
23573
|
+
}
|
|
23574
|
+
this.watchers.delete(body.id);
|
|
23575
|
+
if (!watcher.coverageKey) {
|
|
23576
|
+
return;
|
|
23577
|
+
}
|
|
23578
|
+
const usage = (this.coverageUsage.get(watcher.coverageKey) ?? 1) - 1;
|
|
23579
|
+
if (usage <= 0) {
|
|
23580
|
+
this.coverageUsage.delete(watcher.coverageKey);
|
|
23581
|
+
const coverage = this.coverage.get(watcher.coverageKey);
|
|
23582
|
+
if (coverage && !coverage.permanent) {
|
|
23583
|
+
this.coverage.delete(watcher.coverageKey);
|
|
23584
|
+
this.registrationHash = undefined;
|
|
23585
|
+
this.updateRegistration();
|
|
23586
|
+
}
|
|
23587
|
+
} else {
|
|
23588
|
+
this.coverageUsage.set(watcher.coverageKey, usage);
|
|
23589
|
+
}
|
|
23590
|
+
}
|
|
23591
|
+
ensureCoverageForWatcher(watcher) {
|
|
23592
|
+
if (this.isCoveredByWorkspace(watcher.normalizedPath)) {
|
|
23593
|
+
return undefined;
|
|
23594
|
+
}
|
|
23595
|
+
const basePath = watcher.kind === 'file' ? path__default.dirname(watcher.path) : watcher.path;
|
|
23596
|
+
const pattern = watcher.kind === 'file' ? path__default.basename(watcher.path) : watcher.recursive ? '**/*' : '*';
|
|
23597
|
+
const coverageKey = this.coverageKey(basePath, pattern);
|
|
23598
|
+
const desiredWatchKind = watcher.ignoreUpdate ? mainExports$2.WatchKind.Create | mainExports$2.WatchKind.Delete : mainExports$2.WatchKind.Create | mainExports$2.WatchKind.Change | mainExports$2.WatchKind.Delete;
|
|
23599
|
+
const existing = this.coverage.get(coverageKey);
|
|
23600
|
+
let coverageChanged = false;
|
|
23601
|
+
if (existing) {
|
|
23602
|
+
const addedChangeWatch = desiredWatchKind !== existing.watchKind && (existing.watchKind & mainExports$2.WatchKind.Change) === 0 && (desiredWatchKind & mainExports$2.WatchKind.Change) !== 0;
|
|
23603
|
+
if (addedChangeWatch) {
|
|
23604
|
+
const updated = this.createCoverageEntry(basePath, pattern, desiredWatchKind, coverageKey, false);
|
|
23605
|
+
this.coverage.set(coverageKey, updated);
|
|
23606
|
+
coverageChanged = true;
|
|
23607
|
+
}
|
|
23608
|
+
} else {
|
|
23609
|
+
const entry = this.createCoverageEntry(basePath, pattern, desiredWatchKind, coverageKey, false);
|
|
23610
|
+
this.coverage.set(coverageKey, entry);
|
|
23611
|
+
coverageChanged = true;
|
|
23612
|
+
}
|
|
23613
|
+
this.coverageUsage.set(coverageKey, (this.coverageUsage.get(coverageKey) ?? 0) + 1);
|
|
23614
|
+
if (coverageChanged) {
|
|
23615
|
+
this.registrationHash = undefined;
|
|
23616
|
+
this.updateRegistration();
|
|
23617
|
+
}
|
|
23618
|
+
return coverageKey;
|
|
23619
|
+
}
|
|
23620
|
+
createCoverageEntry(basePath, pattern, watchKind, key, permanent) {
|
|
23621
|
+
return {
|
|
23622
|
+
key: key,
|
|
23623
|
+
watchKind: watchKind,
|
|
23624
|
+
normalizedBase: this.normalizePath(basePath),
|
|
23625
|
+
watcher: {
|
|
23626
|
+
globPattern: {
|
|
23627
|
+
baseUri: URI.file(basePath).toString(),
|
|
23628
|
+
pattern: pattern
|
|
23629
|
+
},
|
|
23630
|
+
kind: watchKind
|
|
23631
|
+
},
|
|
23632
|
+
permanent: permanent
|
|
23633
|
+
};
|
|
23634
|
+
}
|
|
23635
|
+
updateRegistration() {
|
|
23636
|
+
this.updateRegistrationQueue = this.updateRegistrationQueue.then(() => this.doUpdateRegistration());
|
|
23637
|
+
}
|
|
23638
|
+
async doUpdateRegistration() {
|
|
23639
|
+
if (this.disposed || !this.readyForRegistration) {
|
|
23640
|
+
return;
|
|
23641
|
+
}
|
|
23642
|
+
const watchers = Array.from(this.coverage.values(), entry => entry.watcher);
|
|
23643
|
+
if (!watchers.length) {
|
|
23644
|
+
this.registration?.dispose();
|
|
23645
|
+
this.registration = undefined;
|
|
23646
|
+
this.registrationHash = undefined;
|
|
23647
|
+
return;
|
|
23648
|
+
}
|
|
23649
|
+
const hash = watchers.map(watcher => {
|
|
23650
|
+
const {baseUri: baseUri, pattern: pattern} = watcher.globPattern;
|
|
23651
|
+
const baseUriString = typeof baseUri === 'string' ? baseUri : baseUri.uri;
|
|
23652
|
+
return `${baseUriString}|${pattern}|${watcher.kind}`;
|
|
23653
|
+
}).join('-');
|
|
23654
|
+
if (hash === this.registrationHash) {
|
|
23655
|
+
return;
|
|
23656
|
+
}
|
|
23657
|
+
this.registrationHash = hash;
|
|
23658
|
+
try {
|
|
23659
|
+
this.registration?.dispose();
|
|
23660
|
+
this.registration = await this.options.lspClient.registerDidChangeWatchedFilesCapability(watchers);
|
|
23661
|
+
if (this.disposed) {
|
|
23662
|
+
this.registration.dispose();
|
|
23663
|
+
this.registration = undefined;
|
|
23664
|
+
}
|
|
23665
|
+
} catch (err) {
|
|
23666
|
+
this.options.logger.warn('Failed to register file watchers for tsserver watch events', err);
|
|
23667
|
+
}
|
|
23668
|
+
}
|
|
23669
|
+
watcherMatchesPath(watcher, normalizedFsPath) {
|
|
23670
|
+
if (watcher.kind === 'file') {
|
|
23671
|
+
return watcher.normalizedPath === normalizedFsPath;
|
|
23672
|
+
}
|
|
23673
|
+
const base = watcher.normalizedPath;
|
|
23674
|
+
if (watcher.recursive) {
|
|
23675
|
+
return normalizedFsPath === base || normalizedFsPath.startsWith(base + '/');
|
|
23676
|
+
}
|
|
23677
|
+
return this.dirname(normalizedFsPath) === base;
|
|
23678
|
+
}
|
|
23679
|
+
isCoveredByWorkspace(normalizedPath) {
|
|
23680
|
+
return this.workspacePaths.some(base => normalizedPath === base || normalizedPath.startsWith(base + '/'));
|
|
23681
|
+
}
|
|
23682
|
+
normalizePath(filePath) {
|
|
23683
|
+
const normalized = path__default.normalize(filePath).replace(/\\/g, '/');
|
|
23684
|
+
const isDriveRoot = /^[a-zA-Z]:\/?$/.test(normalized);
|
|
23685
|
+
const isPosixRoot = normalized === '/';
|
|
23686
|
+
const trimmed = isDriveRoot || isPosixRoot ? normalized.replace(/\/+$/, '/') : normalized.replace(/\/+$/, '');
|
|
23687
|
+
return this.options.caseInsensitive ? trimmed.toLowerCase() : trimmed;
|
|
23688
|
+
}
|
|
23689
|
+
dirname(normalizedPath) {
|
|
23690
|
+
const dir = normalizedPath.substring(0, normalizedPath.lastIndexOf('/'));
|
|
23691
|
+
return dir || normalizedPath;
|
|
23692
|
+
}
|
|
23693
|
+
coverageKey(basePath, pattern) {
|
|
23694
|
+
return `${this.normalizePath(basePath)}|${pattern}`;
|
|
23695
|
+
}
|
|
23696
|
+
}
|
|
23697
|
+
|
|
23187
23698
|
class LspServer {
|
|
23699
|
+
options;
|
|
23700
|
+
tsClient;
|
|
23701
|
+
fileConfigurationManager;
|
|
23702
|
+
initializeParams=null;
|
|
23703
|
+
diagnosticsManager;
|
|
23704
|
+
completionDataCache=new CompletionDataCache;
|
|
23705
|
+
logger;
|
|
23706
|
+
codeActionsManager;
|
|
23707
|
+
commandManager;
|
|
23708
|
+
workspaceRoot;
|
|
23709
|
+
features={};
|
|
23710
|
+
cachedNavTreeResponse=new CachedResponse;
|
|
23711
|
+
implementationsCodeLensProvider=null;
|
|
23712
|
+
referencesCodeLensProvider=null;
|
|
23713
|
+
watchEventManager=null;
|
|
23188
23714
|
constructor(options) {
|
|
23189
23715
|
this.options = options;
|
|
23190
|
-
this.initializeParams = null;
|
|
23191
|
-
this.completionDataCache = new CompletionDataCache;
|
|
23192
|
-
this.features = {};
|
|
23193
|
-
this.cachedNavTreeResponse = new CachedResponse;
|
|
23194
|
-
this.implementationsCodeLensProvider = null;
|
|
23195
|
-
this.referencesCodeLensProvider = null;
|
|
23196
23716
|
this.logger = new PrefixingLogger(options.logger, '[lspserver]');
|
|
23197
23717
|
this.tsClient = new TsClient(onCaseInsensitiveFileSystem(), this.logger, options.lspClient);
|
|
23198
23718
|
this.fileConfigurationManager = new FileConfigurationManager(this.tsClient, this.options.lspClient, this.features, onCaseInsensitiveFileSystem());
|
|
23199
23719
|
this.commandManager = new CommandManager;
|
|
23200
23720
|
this.diagnosticsManager = new DiagnosticsManager(diagnostics => this.options.lspClient.publishDiagnostics(diagnostics), this.tsClient, this.features, this.logger);
|
|
23201
23721
|
this.codeActionsManager = new CodeActionManager(this.tsClient, this.fileConfigurationManager, this.commandManager, this.diagnosticsManager, this.features);
|
|
23722
|
+
this.commandManager.register(new TSServerRequestCommand(this.tsClient));
|
|
23202
23723
|
}
|
|
23203
23724
|
closeAllForTesting() {
|
|
23204
23725
|
for (const document of this.tsClient.documentsForTesting.values()) {
|
|
@@ -23213,6 +23734,8 @@ class LspServer {
|
|
|
23213
23734
|
await this.diagnosticsManager.waitForDiagnosticsForTesting(document.filepath);
|
|
23214
23735
|
}
|
|
23215
23736
|
shutdown() {
|
|
23737
|
+
this.watchEventManager?.dispose();
|
|
23738
|
+
this.watchEventManager = null;
|
|
23216
23739
|
this.tsClient.shutdown();
|
|
23217
23740
|
}
|
|
23218
23741
|
initialize(params) {
|
|
@@ -23262,6 +23785,22 @@ class LspServer {
|
|
|
23262
23785
|
this.fileConfigurationManager.mergeTsPreferences({
|
|
23263
23786
|
useLabelDetailsInCompletionEntries: this.features.completionLabelDetails
|
|
23264
23787
|
});
|
|
23788
|
+
const requestedWatchEvents = tsserver?.useClientFileWatcher ?? false;
|
|
23789
|
+
let canUseWatchEvents = false;
|
|
23790
|
+
if (requestedWatchEvents) {
|
|
23791
|
+
const supportsFileWatcherRegistration = Boolean(workspace?.didChangeWatchedFiles?.dynamicRegistration);
|
|
23792
|
+
const supportsRelativePatterns = workspace?.didChangeWatchedFiles?.relativePatternSupport === true;
|
|
23793
|
+
const typescriptSupportsWatchEvents = typescriptVersion.version?.gte(API.v544);
|
|
23794
|
+
if (!supportsFileWatcherRegistration) {
|
|
23795
|
+
this.logger.logIgnoringVerbosity(LogLevel.Warning, 'Client does not support dynamic file watcher registration; falling back to tsserver file watching.');
|
|
23796
|
+
} else if (!supportsRelativePatterns) {
|
|
23797
|
+
this.logger.logIgnoringVerbosity(LogLevel.Warning, 'Client does not support relative file watcher patterns; falling back to tsserver file watching.');
|
|
23798
|
+
} else if (!typescriptSupportsWatchEvents) {
|
|
23799
|
+
this.logger.logIgnoringVerbosity(LogLevel.Warning, 'Client-side file watching requires TypeScript 5.4.4 or newer; disabling useClientFileWatcher.');
|
|
23800
|
+
} else {
|
|
23801
|
+
canUseWatchEvents = true;
|
|
23802
|
+
}
|
|
23803
|
+
}
|
|
23265
23804
|
const tsserverLogVerbosity = tsserver?.logVerbosity && TsServerLogLevel.fromString(tsserver.logVerbosity);
|
|
23266
23805
|
const started = this.tsClient.start(this.workspaceRoot, {
|
|
23267
23806
|
trace: Trace.fromString(tsserver?.trace || 'off'),
|
|
@@ -23281,7 +23820,8 @@ class LspServer {
|
|
|
23281
23820
|
throw new Error(`tsserver process has exited (exit code: ${exitCode}, signal: ${signal}). Stopping the server.`);
|
|
23282
23821
|
}
|
|
23283
23822
|
},
|
|
23284
|
-
|
|
23823
|
+
useClientFileWatcher: tsserver?.useClientFileWatcher ?? false,
|
|
23824
|
+
useSyntaxServer: toSyntaxServerConfiguration(tsserver?.useSyntaxServer)
|
|
23285
23825
|
});
|
|
23286
23826
|
if (!started) {
|
|
23287
23827
|
throw new Error('tsserver process has failed to start.');
|
|
@@ -23292,6 +23832,15 @@ class LspServer {
|
|
|
23292
23832
|
process.on('SIGINT', () => {
|
|
23293
23833
|
process.exit();
|
|
23294
23834
|
});
|
|
23835
|
+
if (canUseWatchEvents) {
|
|
23836
|
+
this.watchEventManager = new WatchEventManager({
|
|
23837
|
+
lspClient: this.options.lspClient,
|
|
23838
|
+
logger: this.logger,
|
|
23839
|
+
workspaceFolders: this.getWorkspaceFolders(),
|
|
23840
|
+
sendWatchChanges: changes => this.tsClient.sendWatchChanges(changes),
|
|
23841
|
+
caseInsensitive: onCaseInsensitiveFileSystem()
|
|
23842
|
+
});
|
|
23843
|
+
}
|
|
23295
23844
|
this.fileConfigurationManager.setGlobalConfiguration(this.workspaceRoot, hostInfo);
|
|
23296
23845
|
this.registerHandlers();
|
|
23297
23846
|
const prepareSupport = textDocument?.rename?.prepareSupport && this.tsClient.apiVersion.gte(API.v310);
|
|
@@ -23320,7 +23869,7 @@ class LspServer {
|
|
|
23320
23869
|
documentHighlightProvider: true,
|
|
23321
23870
|
documentSymbolProvider: true,
|
|
23322
23871
|
executeCommandProvider: {
|
|
23323
|
-
commands: [ Commands.APPLY_REFACTORING, Commands.CONFIGURE_PLUGIN, Commands.ORGANIZE_IMPORTS, Commands.APPLY_RENAME_FILE, Commands.SOURCE_DEFINITION,
|
|
23872
|
+
commands: [ Commands.APPLY_REFACTORING, Commands.CONFIGURE_PLUGIN, Commands.ORGANIZE_IMPORTS, Commands.APPLY_RENAME_FILE, Commands.SOURCE_DEFINITION, ...this.commandManager.registeredIds ]
|
|
23324
23873
|
},
|
|
23325
23874
|
hoverProvider: true,
|
|
23326
23875
|
inlayHintProvider: true,
|
|
@@ -23389,6 +23938,7 @@ class LspServer {
|
|
|
23389
23938
|
version: apiVersion.displayName,
|
|
23390
23939
|
source: typescriptVersionSource
|
|
23391
23940
|
});
|
|
23941
|
+
this.watchEventManager?.onInitialized();
|
|
23392
23942
|
}
|
|
23393
23943
|
findTypescriptVersion(userTsserverPath, fallbackTsserverPath) {
|
|
23394
23944
|
const typescriptVersionProvider = new TypeScriptVersionProvider(userTsserverPath, this.logger);
|
|
@@ -23428,6 +23978,12 @@ class LspServer {
|
|
|
23428
23978
|
}
|
|
23429
23979
|
return undefined;
|
|
23430
23980
|
}
|
|
23981
|
+
getWorkspaceFolders() {
|
|
23982
|
+
if (this.workspaceRoot) {
|
|
23983
|
+
return [ URI.file(this.workspaceRoot) ];
|
|
23984
|
+
}
|
|
23985
|
+
return [];
|
|
23986
|
+
}
|
|
23431
23987
|
didChangeConfiguration(params) {
|
|
23432
23988
|
this.fileConfigurationManager.setWorkspaceConfiguration(params.settings || {});
|
|
23433
23989
|
const ignoredDiagnosticCodes = this.fileConfigurationManager.workspaceConfiguration.diagnostics?.ignoredCodes || [];
|
|
@@ -23462,9 +24018,18 @@ class LspServer {
|
|
|
23462
24018
|
this.fileConfigurationManager.onDidCloseTextDocument(document.uri);
|
|
23463
24019
|
}
|
|
23464
24020
|
didChangeTextDocument(params) {
|
|
24021
|
+
if (this.fileConfigurationManager.workspaceConfiguration.diagnostics?.eagerClear) {
|
|
24022
|
+
const document = this.tsClient.toOpenDocument(params.textDocument.uri);
|
|
24023
|
+
if (document) {
|
|
24024
|
+
this.diagnosticsManager.clearDiagnosticsForFile(document.filepath);
|
|
24025
|
+
}
|
|
24026
|
+
}
|
|
23465
24027
|
this.tsClient.onDidChangeTextDocument(params);
|
|
23466
24028
|
}
|
|
23467
24029
|
didSaveTextDocument(_params) {}
|
|
24030
|
+
didChangeWatchedFiles(params) {
|
|
24031
|
+
this.watchEventManager?.handleFileChanges(params);
|
|
24032
|
+
}
|
|
23468
24033
|
async definition(params, token) {
|
|
23469
24034
|
return this.getDefinition({
|
|
23470
24035
|
type: this.features.definitionLinkSupport ? CommandTypes.DefinitionAndBoundSpan : CommandTypes.Definition,
|
|
@@ -23605,14 +24170,13 @@ class LspServer {
|
|
|
23605
24170
|
return mainExports$2.CompletionList.create(completions, isIncomplete);
|
|
23606
24171
|
}
|
|
23607
24172
|
async completionResolve(item, token) {
|
|
23608
|
-
let document = undefined;
|
|
23609
24173
|
const data = item.data;
|
|
23610
24174
|
if (data?.cacheId !== undefined) {
|
|
23611
24175
|
const cachedData = this.completionDataCache.get(data.cacheId);
|
|
23612
24176
|
item.data = cachedData;
|
|
23613
24177
|
if (cachedData?.file) {
|
|
23614
24178
|
const uri = this.tsClient.toResourceUri(cachedData.file);
|
|
23615
|
-
document = this.tsClient.toOpenDocument(uri);
|
|
24179
|
+
const document = this.tsClient.toOpenDocument(uri);
|
|
23616
24180
|
if (document) {
|
|
23617
24181
|
const response = await this.tsClient.interruptGetErr(() => this.tsClient.execute(CommandTypes.CompletionDetails, cachedData, token));
|
|
23618
24182
|
if (response.type !== 'response' || !response.body?.length) {
|
|
@@ -23819,7 +24383,7 @@ class LspServer {
|
|
|
23819
24383
|
return actions;
|
|
23820
24384
|
}
|
|
23821
24385
|
async getRefactors(fileRangeArgs, context, features, token) {
|
|
23822
|
-
const kinds = context.only || [ undefined ];
|
|
24386
|
+
const kinds = (context.only || [ undefined ]).filter(kind => kind === undefined || CodeActionKind.Refactor.contains(new CodeActionKind(kind)));
|
|
23823
24387
|
const responses = await Promise.all(kinds.map(async kind => {
|
|
23824
24388
|
const args = {
|
|
23825
24389
|
...fileRangeArgs,
|
|
@@ -23836,7 +24400,9 @@ class LspServer {
|
|
|
23836
24400
|
return this.codeActionsManager.resolveCodeAction(params);
|
|
23837
24401
|
}
|
|
23838
24402
|
async executeCommand(params, token, workDoneProgress) {
|
|
23839
|
-
if (
|
|
24403
|
+
if (this.commandManager.handlesCommand(params.command)) {
|
|
24404
|
+
return await this.commandManager.handle(params.command, ...params.arguments || []);
|
|
24405
|
+
} else if (params.command === Commands.APPLY_REFACTORING && params.arguments) {
|
|
23840
24406
|
const args = params.arguments[0];
|
|
23841
24407
|
const response = await this.tsClient.execute(CommandTypes.GetEditsForRefactor, args, token);
|
|
23842
24408
|
if (response.type !== 'response' || !response.body) {
|
|
@@ -23917,12 +24483,6 @@ class LspServer {
|
|
|
23917
24483
|
const [uri, position] = params.arguments || [];
|
|
23918
24484
|
const reporter = await this.options.lspClient.createProgressReporter(token, workDoneProgress);
|
|
23919
24485
|
return SourceDefinitionCommand.execute(uri, position, this.tsClient, this.options.lspClient, reporter, token);
|
|
23920
|
-
} else if (params.command === Commands.TS_SERVER_REQUEST) {
|
|
23921
|
-
const [command, args, config] = params.arguments || [];
|
|
23922
|
-
if (typeof command !== 'string') {
|
|
23923
|
-
throw new Error(`"Command" argument must be a string, got: ${typeof command}`);
|
|
23924
|
-
}
|
|
23925
|
-
return TSServerRequestCommand.execute(this.tsClient, command, args, config, token);
|
|
23926
24486
|
} else {
|
|
23927
24487
|
this.logger.error(`Unknown command ${params.command}.`);
|
|
23928
24488
|
}
|
|
@@ -24087,8 +24647,11 @@ class LspServer {
|
|
|
24087
24647
|
}
|
|
24088
24648
|
}
|
|
24089
24649
|
onTsEvent(event) {
|
|
24650
|
+
if (this.watchEventManager?.handleTsserverEvent(event)) {
|
|
24651
|
+
return;
|
|
24652
|
+
}
|
|
24090
24653
|
const eventName = event.event;
|
|
24091
|
-
if (eventName ===
|
|
24654
|
+
if (eventName === EventName.semanticDiag || eventName === EventName.syntaxDiag || eventName === EventName.suggestionDiag) {
|
|
24092
24655
|
const diagnosticEvent = event;
|
|
24093
24656
|
if (diagnosticEvent.body?.diagnostics) {
|
|
24094
24657
|
const {file: file, diagnostics: diagnostics} = diagnosticEvent.body;
|
|
@@ -24204,6 +24767,7 @@ var progressExports = requireProgress();
|
|
|
24204
24767
|
const nullProgressReporter = progressExports.attachWorkDone(undefined, undefined);
|
|
24205
24768
|
|
|
24206
24769
|
class LspClientImpl {
|
|
24770
|
+
connection;
|
|
24207
24771
|
constructor(connection) {
|
|
24208
24772
|
this.connection = connection;
|
|
24209
24773
|
}
|
|
@@ -24251,6 +24815,11 @@ class LspClientImpl {
|
|
|
24251
24815
|
async sendNotification(type, params) {
|
|
24252
24816
|
await this.connection.sendNotification(type, params);
|
|
24253
24817
|
}
|
|
24818
|
+
async registerDidChangeWatchedFilesCapability(watchers) {
|
|
24819
|
+
return await this.connection.client.register(mainExports$2.DidChangeWatchedFilesNotification.type, {
|
|
24820
|
+
watchers: watchers
|
|
24821
|
+
});
|
|
24822
|
+
}
|
|
24254
24823
|
}
|
|
24255
24824
|
|
|
24256
24825
|
function createLspConnection(options) {
|
|
@@ -24268,6 +24837,7 @@ function createLspConnection(options) {
|
|
|
24268
24837
|
connection.onDidSaveTextDocument(server.didSaveTextDocument.bind(server));
|
|
24269
24838
|
connection.onDidCloseTextDocument(server.didCloseTextDocument.bind(server));
|
|
24270
24839
|
connection.onDidChangeTextDocument(server.didChangeTextDocument.bind(server));
|
|
24840
|
+
connection.onDidChangeWatchedFiles(server.didChangeWatchedFiles.bind(server));
|
|
24271
24841
|
connection.onCodeAction(server.codeAction.bind(server));
|
|
24272
24842
|
connection.onCodeActionResolve(server.codeActionResolve.bind(server));
|
|
24273
24843
|
connection.onCodeLens(server.codeLens.bind(server));
|