typescript 7.1.0-dev.20260930.4 → 7.1.0-dev.20261002.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/async/api.d.ts +32 -24
- package/dist/api/async/api.d.ts.map +1 -1
- package/dist/api/async/api.js +142 -54
- package/dist/api/async/api.js.map +1 -1
- package/dist/api/compilerOptions.generated.d.ts +122 -0
- package/dist/api/compilerOptions.generated.d.ts.map +1 -0
- package/dist/api/compilerOptions.generated.js +8 -0
- package/dist/api/compilerOptions.generated.js.map +1 -0
- package/dist/api/node/node.d.ts +6 -1
- package/dist/api/node/node.d.ts.map +1 -1
- package/dist/api/node/node.js +4 -1
- package/dist/api/node/node.js.map +1 -1
- package/dist/api/path.d.ts.map +1 -1
- package/dist/api/path.js +194 -11
- package/dist/api/path.js.map +1 -1
- package/dist/api/proto.d.ts +1 -0
- package/dist/api/proto.d.ts.map +1 -1
- package/dist/api/proto.generated.d.ts +44 -153
- package/dist/api/proto.generated.d.ts.map +1 -1
- package/dist/api/proto.generated.js +1 -10
- package/dist/api/proto.generated.js.map +1 -1
- package/dist/api/proto.js +1 -0
- package/dist/api/proto.js.map +1 -1
- package/dist/api/sourceFileCache.d.ts +8 -2
- package/dist/api/sourceFileCache.d.ts.map +1 -1
- package/dist/api/sourceFileCache.js +30 -12
- package/dist/api/sourceFileCache.js.map +1 -1
- package/dist/api/sync/api.d.ts +38 -24
- package/dist/api/sync/api.d.ts.map +1 -1
- package/dist/api/sync/api.js +168 -64
- package/dist/api/sync/api.js.map +1 -1
- package/dist/api/userPreferences.generated.d.ts +195 -0
- package/dist/api/userPreferences.generated.d.ts.map +1 -0
- package/dist/api/userPreferences.generated.js +3 -0
- package/dist/api/userPreferences.generated.js.map +1 -0
- package/dist/enums/jsxEmit.enum.js +1 -1
- package/dist/enums/jsxEmit.enum.js.map +1 -1
- package/dist/enums/jsxEmit.js +1 -1
- package/dist/enums/jsxEmit.js.map +1 -1
- package/dist/enums/moduleDetectionKind.enum.js +1 -1
- package/dist/enums/moduleDetectionKind.enum.js.map +1 -1
- package/dist/enums/moduleDetectionKind.js +1 -1
- package/dist/enums/moduleDetectionKind.js.map +1 -1
- package/dist/enums/moduleKind.enum.js +1 -1
- package/dist/enums/moduleKind.enum.js.map +1 -1
- package/dist/enums/moduleKind.js +1 -1
- package/dist/enums/moduleKind.js.map +1 -1
- package/dist/enums/moduleResolutionKind.enum.js +1 -1
- package/dist/enums/moduleResolutionKind.enum.js.map +1 -1
- package/dist/enums/moduleResolutionKind.js +1 -1
- package/dist/enums/moduleResolutionKind.js.map +1 -1
- package/dist/enums/newLineKind.enum.js +1 -1
- package/dist/enums/newLineKind.enum.js.map +1 -1
- package/dist/enums/newLineKind.js +1 -1
- package/dist/enums/newLineKind.js.map +1 -1
- package/dist/enums/scriptTarget.d.ts.map +1 -1
- package/dist/enums/scriptTarget.enum.d.ts.map +1 -1
- package/dist/enums/scriptTarget.enum.js +1 -0
- package/dist/enums/scriptTarget.enum.js.map +1 -1
- package/dist/enums/scriptTarget.js +1 -0
- package/dist/enums/scriptTarget.js.map +1 -1
- package/dist/enums/syntaxKind.enum.js +1 -1
- package/dist/enums/syntaxKind.enum.js.map +1 -1
- package/dist/enums/syntaxKind.js +1 -1
- package/dist/enums/syntaxKind.js.map +1 -1
- package/package.json +12 -9
- package/schemas/jsconfig.schema.json +2205 -0
- package/schemas/tsconfig.schema.json +2204 -0
package/dist/api/sync/api.js
CHANGED
|
@@ -22,7 +22,7 @@ import { TypePredicateKind } from "#enums/typePredicateKind";
|
|
|
22
22
|
import { ModifierFlags, unescapeLeadingUnderscores, } from "../../ast/index.js";
|
|
23
23
|
import { assertNever } from "../../internal/utils.js";
|
|
24
24
|
import { encodeNode, uint8ArrayToBase64, } from "../node/encoder.js";
|
|
25
|
-
import { decodeNode, getNodeId, parseNodeHandle, readSourceFileLease, RemoteSourceFile, } from "../node/node.js";
|
|
25
|
+
import { decodeNode, getNodeId, parseNodeHandle, readSourceFileLease, RemoteNode, RemoteSourceFile, } from "../node/node.js";
|
|
26
26
|
import { Wtf8Decoder } from "../node/wtf8.js";
|
|
27
27
|
import { createGetCanonicalFileName, toPath, } from "../path.js";
|
|
28
28
|
import { resolveFileName, toCreateSnapshotRequest, validateSymbolResponse, } from "../proto.js";
|
|
@@ -51,7 +51,9 @@ export { all, defer } from "./generatorSupport.js";
|
|
|
51
51
|
import { sourceFileResponseToUint8Array } from "../node/encoder.js";
|
|
52
52
|
import { executeRequestGenerators, } from "./generatorSupport.js";
|
|
53
53
|
export class API {
|
|
54
|
+
/** @internal */
|
|
54
55
|
client;
|
|
56
|
+
/** @internal */
|
|
55
57
|
sourceFileCache;
|
|
56
58
|
toPath;
|
|
57
59
|
currentDirectory;
|
|
@@ -70,6 +72,69 @@ export class API {
|
|
|
70
72
|
this.printer = new Printer(this.client);
|
|
71
73
|
this.internal = new InternalAPI(this.client, this.ensureInitialized);
|
|
72
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Looks up a remote declaration's binder symbol. Throws for synthesized or configuration ASTs.
|
|
77
|
+
*/
|
|
78
|
+
get getSymbol() {
|
|
79
|
+
const owner = this;
|
|
80
|
+
return cacheGeneratorMethod(owner, "getSymbol", function (declaration) {
|
|
81
|
+
const file = getRemoteSourceFile(declaration);
|
|
82
|
+
if (!file)
|
|
83
|
+
throw new Error(`Source file not found for declaration`);
|
|
84
|
+
const record = file.symbolCache;
|
|
85
|
+
if (!record)
|
|
86
|
+
throw new Error(`Cached source file not found for declaration`);
|
|
87
|
+
const index = parseNodeHandle(getNodeId(declaration)).index;
|
|
88
|
+
const cached = record.symbolsByDeclarationNodeIndex.get(index);
|
|
89
|
+
if (cached)
|
|
90
|
+
return cached;
|
|
91
|
+
return owner.fetchDeclarationSymbol(record, index);
|
|
92
|
+
}, function* (declaration) {
|
|
93
|
+
const file = getRemoteSourceFile(declaration);
|
|
94
|
+
if (!file)
|
|
95
|
+
throw new Error(`Source file not found for declaration`);
|
|
96
|
+
const record = file.symbolCache;
|
|
97
|
+
if (!record)
|
|
98
|
+
throw new Error(`Cached source file not found for declaration`);
|
|
99
|
+
const index = parseNodeHandle(getNodeId(declaration)).index;
|
|
100
|
+
const cached = record.symbolsByDeclarationNodeIndex.get(index);
|
|
101
|
+
if (cached)
|
|
102
|
+
return cached;
|
|
103
|
+
return yield* owner.fetchDeclarationSymbol.gen(record, index);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
get fetchDeclarationSymbol() {
|
|
107
|
+
const owner = this;
|
|
108
|
+
return cacheGeneratorMethod(owner, "fetchDeclarationSymbol", function (record, index) {
|
|
109
|
+
const data = owner.client.apiRequest("getSymbolOfDeclaration", {
|
|
110
|
+
file: record.descriptor,
|
|
111
|
+
index,
|
|
112
|
+
});
|
|
113
|
+
validateSymbolResponse(data);
|
|
114
|
+
const reference = data.reference;
|
|
115
|
+
if (reference.kind !== SymbolOwnerKind.File) {
|
|
116
|
+
throw new Error(`Symbol ${reference.id} is not file-owned`);
|
|
117
|
+
}
|
|
118
|
+
const fileOwner = { record, api: owner };
|
|
119
|
+
const symbol = owner.sourceFileCache.getOrCreateSymbol(record, reference.file, reference.id, () => new Symbol(data, { kind: SymbolOwnerKind.File, owner: fileOwner }));
|
|
120
|
+
record.symbolsByDeclarationNodeIndex.set(index, symbol);
|
|
121
|
+
return symbol;
|
|
122
|
+
}, function* (record, index) {
|
|
123
|
+
const data = yield* apiRequest("getSymbolOfDeclaration", {
|
|
124
|
+
file: record.descriptor,
|
|
125
|
+
index,
|
|
126
|
+
});
|
|
127
|
+
validateSymbolResponse(data);
|
|
128
|
+
const reference = data.reference;
|
|
129
|
+
if (reference.kind !== SymbolOwnerKind.File) {
|
|
130
|
+
throw new Error(`Symbol ${reference.id} is not file-owned`);
|
|
131
|
+
}
|
|
132
|
+
const fileOwner = { record, api: owner };
|
|
133
|
+
const symbol = owner.sourceFileCache.getOrCreateSymbol(record, reference.file, reference.id, () => new Symbol(data, { kind: SymbolOwnerKind.File, owner: fileOwner }));
|
|
134
|
+
record.symbolsByDeclarationNodeIndex.set(index, symbol);
|
|
135
|
+
return symbol;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
73
138
|
/**
|
|
74
139
|
* Create an API instance from an existing LSP connection's API session.
|
|
75
140
|
* Use this when connecting to an API pipe provided by an LSP server via custom/initializeAPISession.
|
|
@@ -110,7 +175,7 @@ export class API {
|
|
|
110
175
|
const currentDirectory = response.currentDirectory;
|
|
111
176
|
owner.getCanonicalFileNameWorker = getCanonicalFileName;
|
|
112
177
|
owner.currentDirectory = currentDirectory;
|
|
113
|
-
owner.toPath = (fileName) => toPath(fileName,
|
|
178
|
+
owner.toPath = (fileName, basePath = currentDirectory) => toPath(fileName, basePath, getCanonicalFileName);
|
|
114
179
|
owner.initialized = true;
|
|
115
180
|
}
|
|
116
181
|
catch (error) {
|
|
@@ -124,7 +189,7 @@ export class API {
|
|
|
124
189
|
const currentDirectory = response.currentDirectory;
|
|
125
190
|
owner.getCanonicalFileNameWorker = getCanonicalFileName;
|
|
126
191
|
owner.currentDirectory = currentDirectory;
|
|
127
|
-
owner.toPath = (fileName) => toPath(fileName,
|
|
192
|
+
owner.toPath = (fileName, basePath = currentDirectory) => toPath(fileName, basePath, getCanonicalFileName);
|
|
128
193
|
owner.initialized = true;
|
|
129
194
|
}
|
|
130
195
|
catch (error) {
|
|
@@ -293,7 +358,7 @@ export class API {
|
|
|
293
358
|
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
294
359
|
const lease = readSourceFileLease(view);
|
|
295
360
|
try {
|
|
296
|
-
const decoded = new RemoteSourceFile(data, this.decoder, this.client.getTimingCollector());
|
|
361
|
+
const decoded = new RemoteSourceFile(data, this.decoder, this.client.getTimingCollector(), this);
|
|
297
362
|
return this.addSourceFileLease(decoded, lease);
|
|
298
363
|
}
|
|
299
364
|
catch (error) {
|
|
@@ -306,7 +371,7 @@ export class API {
|
|
|
306
371
|
}
|
|
307
372
|
addSourceFileLease(sourceFile, lease) {
|
|
308
373
|
const cached = this.sourceFileCache.setForLease(sourceFile, lease);
|
|
309
|
-
const retained = new RetainedSourceFile(cached, lease,
|
|
374
|
+
const retained = new RetainedSourceFile(cached, lease, () => {
|
|
310
375
|
this.activeSourceFileLeases.delete(lease);
|
|
311
376
|
this.sourceFileCache.releaseLease(lease);
|
|
312
377
|
});
|
|
@@ -359,7 +424,7 @@ export class API {
|
|
|
359
424
|
owner.ensureInitialized();
|
|
360
425
|
const requestParams = toCreateSnapshotRequest(owner.prepareCreateSnapshotParams(params));
|
|
361
426
|
const data = owner.client.apiRequest("createSnapshot", requestParams);
|
|
362
|
-
const snapshot = new Snapshot(data, owner.
|
|
427
|
+
const snapshot = new Snapshot(data, owner.toPath, owner, () => {
|
|
363
428
|
owner.activeSnapshots.delete(snapshot.id);
|
|
364
429
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
365
430
|
}, owner.createSnapshotUpdater(() => snapshot), undefined);
|
|
@@ -370,7 +435,7 @@ export class API {
|
|
|
370
435
|
yield* owner.ensureInitialized.gen();
|
|
371
436
|
const requestParams = toCreateSnapshotRequest(owner.prepareCreateSnapshotParams(params));
|
|
372
437
|
const data = yield* apiRequest("createSnapshot", requestParams);
|
|
373
|
-
const snapshot = new Snapshot(data, owner.
|
|
438
|
+
const snapshot = new Snapshot(data, owner.toPath, owner, () => {
|
|
374
439
|
owner.activeSnapshots.delete(snapshot.id);
|
|
375
440
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
376
441
|
}, owner.createSnapshotUpdater(() => snapshot), undefined);
|
|
@@ -395,7 +460,7 @@ export class API {
|
|
|
395
460
|
return baseSnapshot;
|
|
396
461
|
}
|
|
397
462
|
owner.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
398
|
-
const snapshot = new Snapshot(data, owner.
|
|
463
|
+
const snapshot = new Snapshot(data, owner.toPath, owner, () => {
|
|
399
464
|
owner.activeSnapshots.delete(snapshot.id);
|
|
400
465
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
401
466
|
}, owner.createSnapshotUpdater(() => snapshot), baseSnapshot);
|
|
@@ -415,7 +480,7 @@ export class API {
|
|
|
415
480
|
return baseSnapshot;
|
|
416
481
|
}
|
|
417
482
|
owner.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
418
|
-
const snapshot = new Snapshot(data, owner.
|
|
483
|
+
const snapshot = new Snapshot(data, owner.toPath, owner, () => {
|
|
419
484
|
owner.activeSnapshots.delete(snapshot.id);
|
|
420
485
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
421
486
|
}, owner.createSnapshotUpdater(() => snapshot), baseSnapshot);
|
|
@@ -476,7 +541,7 @@ export class API {
|
|
|
476
541
|
if (baseSnapshot) {
|
|
477
542
|
owner.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
478
543
|
}
|
|
479
|
-
const snapshot = new Snapshot(data, owner.
|
|
544
|
+
const snapshot = new Snapshot(data, owner.toPath, owner, () => {
|
|
480
545
|
owner.activeSnapshots.delete(snapshot.id);
|
|
481
546
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
482
547
|
}, owner.createSnapshotUpdater(() => snapshot), baseSnapshot);
|
|
@@ -497,7 +562,7 @@ export class API {
|
|
|
497
562
|
if (baseSnapshot) {
|
|
498
563
|
owner.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
499
564
|
}
|
|
500
|
-
const snapshot = new Snapshot(data, owner.
|
|
565
|
+
const snapshot = new Snapshot(data, owner.toPath, owner, () => {
|
|
501
566
|
owner.activeSnapshots.delete(snapshot.id);
|
|
502
567
|
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
503
568
|
}, owner.createSnapshotUpdater(() => snapshot), baseSnapshot);
|
|
@@ -702,18 +767,43 @@ function sourceFileDescriptor(sourceFile) {
|
|
|
702
767
|
nodeId: sourceFile.nodeId,
|
|
703
768
|
};
|
|
704
769
|
}
|
|
770
|
+
function getRemoteSourceFile(node) {
|
|
771
|
+
if (!(node instanceof RemoteNode))
|
|
772
|
+
return undefined;
|
|
773
|
+
const file = node.getSourceFile();
|
|
774
|
+
return file instanceof RemoteSourceFile && file.api ? file : undefined;
|
|
775
|
+
}
|
|
776
|
+
function getNodeAPI(node) {
|
|
777
|
+
const api = getRemoteSourceFile(node)?.api;
|
|
778
|
+
if (!api)
|
|
779
|
+
return undefined;
|
|
780
|
+
if (!(api instanceof API))
|
|
781
|
+
throw new Error("Source file does not belong to the sync API");
|
|
782
|
+
return api;
|
|
783
|
+
}
|
|
784
|
+
/** Looks up a remote declaration's binder symbol through its API. Throws for non-remote declarations. */
|
|
785
|
+
export function getSymbol(declaration) {
|
|
786
|
+
const api = getNodeAPI(declaration);
|
|
787
|
+
if (!api)
|
|
788
|
+
throw new Error("Source file not found for declaration");
|
|
789
|
+
return api.getSymbol(declaration);
|
|
790
|
+
}
|
|
791
|
+
getSymbol.gen = function* (declaration) {
|
|
792
|
+
const api = getNodeAPI(declaration);
|
|
793
|
+
if (!api)
|
|
794
|
+
throw new Error("Source file not found for declaration");
|
|
795
|
+
return yield* api.getSymbol.gen(declaration);
|
|
796
|
+
};
|
|
705
797
|
/** An independently retained source file and its disposable remote-lifetime lease. */
|
|
706
798
|
export class RetainedSourceFile {
|
|
707
799
|
sourceFile;
|
|
708
800
|
lease;
|
|
709
|
-
client;
|
|
710
801
|
onDispose;
|
|
711
802
|
disposed = false;
|
|
712
803
|
disposePromise;
|
|
713
|
-
constructor(sourceFile, lease,
|
|
804
|
+
constructor(sourceFile, lease, onDispose) {
|
|
714
805
|
this.sourceFile = sourceFile;
|
|
715
806
|
this.lease = lease;
|
|
716
|
-
this.client = client;
|
|
717
807
|
this.onDispose = onDispose;
|
|
718
808
|
}
|
|
719
809
|
[globalThis.Symbol.dispose]() {
|
|
@@ -732,9 +822,12 @@ export class RetainedSourceFile {
|
|
|
732
822
|
return cacheGeneratorMethod(owner, "disposeWorker", function () {
|
|
733
823
|
if (owner.disposed)
|
|
734
824
|
return;
|
|
825
|
+
const api = getNodeAPI(owner.sourceFile);
|
|
826
|
+
if (!api)
|
|
827
|
+
throw new Error("Retained source file has no owning API");
|
|
735
828
|
owner.disposed = true;
|
|
736
829
|
try {
|
|
737
|
-
|
|
830
|
+
api.client.apiRequest("releaseSourceFile", { lease: owner.lease });
|
|
738
831
|
}
|
|
739
832
|
finally {
|
|
740
833
|
owner.onDispose();
|
|
@@ -742,6 +835,9 @@ export class RetainedSourceFile {
|
|
|
742
835
|
}, function* () {
|
|
743
836
|
if (owner.disposed)
|
|
744
837
|
return;
|
|
838
|
+
const api = getNodeAPI(owner.sourceFile);
|
|
839
|
+
if (!api)
|
|
840
|
+
throw new Error("Retained source file has no owning API");
|
|
745
841
|
owner.disposed = true;
|
|
746
842
|
try {
|
|
747
843
|
yield* apiRequest("releaseSourceFile", { lease: owner.lease });
|
|
@@ -800,7 +896,7 @@ export class Snapshot {
|
|
|
800
896
|
operation;
|
|
801
897
|
projectMap;
|
|
802
898
|
toPath;
|
|
803
|
-
|
|
899
|
+
api;
|
|
804
900
|
disposed = false;
|
|
805
901
|
disposePromise;
|
|
806
902
|
onDispose;
|
|
@@ -808,9 +904,12 @@ export class Snapshot {
|
|
|
808
904
|
projectDataMap;
|
|
809
905
|
updateSnapshot;
|
|
810
906
|
internal;
|
|
811
|
-
|
|
907
|
+
get client() {
|
|
908
|
+
return this.api.client;
|
|
909
|
+
}
|
|
910
|
+
constructor(data, toPath, api, onDispose, updateSnapshot, baseSnapshot) {
|
|
812
911
|
this.id = data.snapshot;
|
|
813
|
-
this.
|
|
912
|
+
this.api = api;
|
|
814
913
|
this.toPath = toPath;
|
|
815
914
|
this.onDispose = onDispose;
|
|
816
915
|
this.updateSnapshot = updateSnapshot;
|
|
@@ -825,14 +924,14 @@ export class Snapshot {
|
|
|
825
924
|
this.projectDataMap = new Map([...projectDataMap].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
826
925
|
this.snapshotRegistry = new SnapshotObjectRegistry(this.id);
|
|
827
926
|
for (const projData of this.projectDataMap.values()) {
|
|
828
|
-
const project = new Project(projData, this.id,
|
|
927
|
+
const project = new Project(projData, this.id, toPath, api, this.snapshotRegistry);
|
|
829
928
|
this.projectMap.set(projData.id, project);
|
|
830
929
|
}
|
|
831
930
|
this.operation = {
|
|
832
931
|
createdPrograms: data.operation.createdPrograms?.map(projectId => this.requireProject(projectId).program),
|
|
833
932
|
openedFiles: data.operation.openedFiles?.map(result => ({ project: this.requireProject(result.project) })),
|
|
834
933
|
};
|
|
835
|
-
this.internal = new SnapshotInternalAPI(this.id, client);
|
|
934
|
+
this.internal = new SnapshotInternalAPI(this.id, api.client);
|
|
836
935
|
}
|
|
837
936
|
getProjects() {
|
|
838
937
|
this.ensureNotDisposed();
|
|
@@ -1050,20 +1149,22 @@ class SnapshotObjectRegistry {
|
|
|
1050
1149
|
}
|
|
1051
1150
|
}
|
|
1052
1151
|
class ProjectObjectRegistry {
|
|
1053
|
-
client;
|
|
1054
1152
|
snapshotId;
|
|
1055
1153
|
project;
|
|
1056
1154
|
snapshotRegistry;
|
|
1057
|
-
sourceFileCache;
|
|
1058
1155
|
types = new Map();
|
|
1059
1156
|
signatures = new Map();
|
|
1060
1157
|
disposed = false;
|
|
1061
|
-
|
|
1062
|
-
this.client
|
|
1158
|
+
get client() {
|
|
1159
|
+
return this.project.api.client;
|
|
1160
|
+
}
|
|
1161
|
+
get sourceFileCache() {
|
|
1162
|
+
return this.project.api.sourceFileCache;
|
|
1163
|
+
}
|
|
1164
|
+
constructor(snapshotId, project, snapshotRegistry) {
|
|
1063
1165
|
this.snapshotId = snapshotId;
|
|
1064
1166
|
this.project = project;
|
|
1065
1167
|
this.snapshotRegistry = snapshotRegistry;
|
|
1066
|
-
this.sourceFileCache = sourceFileCache;
|
|
1067
1168
|
snapshotRegistry.addProjectRegistry(this);
|
|
1068
1169
|
}
|
|
1069
1170
|
getOrCreateSymbol(data) {
|
|
@@ -1076,7 +1177,7 @@ class ProjectObjectRegistry {
|
|
|
1076
1177
|
const record = this.sourceFileCache.getOrCreateRecord(reference.file, this.snapshotId, this.project.id);
|
|
1077
1178
|
return this.sourceFileCache.getOrCreateSymbol(record, reference.file, reference.id, () => new Symbol(data, {
|
|
1078
1179
|
kind: SymbolOwnerKind.File,
|
|
1079
|
-
owner: { record,
|
|
1180
|
+
owner: { record, api: this.project.api },
|
|
1080
1181
|
}));
|
|
1081
1182
|
}
|
|
1082
1183
|
/** Find an already-interned symbol and retain its file record for this registry. */
|
|
@@ -1086,7 +1187,7 @@ class ProjectObjectRegistry {
|
|
|
1086
1187
|
return this.snapshotRegistry.getSymbol(reference.id);
|
|
1087
1188
|
}
|
|
1088
1189
|
const record = this.sourceFileCache.findRecord(reference.file);
|
|
1089
|
-
const symbol = record?.
|
|
1190
|
+
const symbol = record?.symbolsById.get(reference.id);
|
|
1090
1191
|
if (record && symbol) {
|
|
1091
1192
|
this.sourceFileCache.retainRecord(record, this.snapshotId, this.project.id);
|
|
1092
1193
|
}
|
|
@@ -1502,6 +1603,8 @@ class ProjectObjectRegistry {
|
|
|
1502
1603
|
}
|
|
1503
1604
|
}
|
|
1504
1605
|
export class Project {
|
|
1606
|
+
/** @internal */
|
|
1607
|
+
api;
|
|
1505
1608
|
id;
|
|
1506
1609
|
configFileName;
|
|
1507
1610
|
currentDirectory;
|
|
@@ -1514,10 +1617,10 @@ export class Project {
|
|
|
1514
1617
|
program;
|
|
1515
1618
|
checker;
|
|
1516
1619
|
languageService;
|
|
1517
|
-
client;
|
|
1518
1620
|
snapshotId;
|
|
1519
|
-
constructor(data, snapshotId,
|
|
1621
|
+
constructor(data, snapshotId, toPath, api, snapshotRegistry) {
|
|
1520
1622
|
this.id = data.id;
|
|
1623
|
+
this.api = api;
|
|
1521
1624
|
this.configFileName = data.configFileName;
|
|
1522
1625
|
this.currentDirectory = data.currentDirectory;
|
|
1523
1626
|
this.dirty = data.dirty;
|
|
@@ -1527,12 +1630,11 @@ export class Project {
|
|
|
1527
1630
|
this.parsedCommandLine = data.parsedCommandLine;
|
|
1528
1631
|
this.compilerOptions = this.parsedCommandLine.options;
|
|
1529
1632
|
this.rootFiles = this.parsedCommandLine.fileNames;
|
|
1530
|
-
this.client = client;
|
|
1531
1633
|
this.snapshotId = snapshotId;
|
|
1532
|
-
this.program = new Program(snapshotId, this,
|
|
1533
|
-
const objectRegistry = new ProjectObjectRegistry(
|
|
1534
|
-
this.checker = new Checker(snapshotId, this,
|
|
1535
|
-
this.languageService = new LanguageService(snapshotId, this,
|
|
1634
|
+
this.program = new Program(snapshotId, this, toPath);
|
|
1635
|
+
const objectRegistry = new ProjectObjectRegistry(snapshotId, this, snapshotRegistry);
|
|
1636
|
+
this.checker = new Checker(snapshotId, this, objectRegistry);
|
|
1637
|
+
this.languageService = new LanguageService(snapshotId, this, objectRegistry);
|
|
1536
1638
|
}
|
|
1537
1639
|
/** @deprecated Use `languageService.getImportAdderEdits`. */
|
|
1538
1640
|
get getImportAdderEdits() {
|
|
@@ -1559,12 +1661,13 @@ export class Project {
|
|
|
1559
1661
|
export class LanguageService {
|
|
1560
1662
|
snapshotId;
|
|
1561
1663
|
project;
|
|
1562
|
-
client;
|
|
1563
1664
|
objectRegistry;
|
|
1564
|
-
|
|
1665
|
+
get client() {
|
|
1666
|
+
return this.project.api.client;
|
|
1667
|
+
}
|
|
1668
|
+
constructor(snapshotId, project, objectRegistry) {
|
|
1565
1669
|
this.snapshotId = snapshotId;
|
|
1566
1670
|
this.project = project;
|
|
1567
|
-
this.client = client;
|
|
1568
1671
|
this.objectRegistry = objectRegistry;
|
|
1569
1672
|
}
|
|
1570
1673
|
get getImportAdderEdits() {
|
|
@@ -1747,28 +1850,28 @@ export class Program {
|
|
|
1747
1850
|
snapshotId;
|
|
1748
1851
|
id;
|
|
1749
1852
|
project;
|
|
1750
|
-
client;
|
|
1751
|
-
sourceFileCache;
|
|
1752
1853
|
toPath;
|
|
1753
|
-
formatDiagnosticsHost;
|
|
1754
1854
|
decoder = new Wtf8Decoder();
|
|
1755
1855
|
sourceFileMetadataCache = new Map();
|
|
1756
1856
|
ownedSnapshot;
|
|
1757
1857
|
disposePromise;
|
|
1758
|
-
|
|
1858
|
+
get client() {
|
|
1859
|
+
return this.project.api.client;
|
|
1860
|
+
}
|
|
1861
|
+
get sourceFileCache() {
|
|
1862
|
+
return this.project.api.sourceFileCache;
|
|
1863
|
+
}
|
|
1864
|
+
constructor(snapshotId, project, toPath) {
|
|
1759
1865
|
this.snapshotId = snapshotId;
|
|
1760
1866
|
this.id = project.id;
|
|
1761
1867
|
this.project = project;
|
|
1762
|
-
this.client = client;
|
|
1763
|
-
this.sourceFileCache = sourceFileCache;
|
|
1764
1868
|
this.toPath = toPath;
|
|
1765
|
-
this.formatDiagnosticsHost = formatDiagnosticsHost;
|
|
1766
1869
|
}
|
|
1767
1870
|
getCurrentDirectory() {
|
|
1768
1871
|
return this.project.currentDirectory;
|
|
1769
1872
|
}
|
|
1770
1873
|
getCanonicalFileName(fileName) {
|
|
1771
|
-
return this.
|
|
1874
|
+
return this.project.api.getCanonicalFileName(fileName);
|
|
1772
1875
|
}
|
|
1773
1876
|
getNewLine() {
|
|
1774
1877
|
return this.project.compilerOptions.newLine === NewLineKind.CRLF ? "\r\n" : "\n";
|
|
@@ -1809,7 +1912,7 @@ export class Program {
|
|
|
1809
1912
|
const owner = this;
|
|
1810
1913
|
return cacheGeneratorMethod(owner, "getSourceFile", function (file) {
|
|
1811
1914
|
const fileName = resolveFileName(file);
|
|
1812
|
-
const path = owner.toPath(fileName);
|
|
1915
|
+
const path = owner.toPath(fileName, owner.project.currentDirectory);
|
|
1813
1916
|
// Check if we already have a retained cache entry for this (snapshot, project) pair
|
|
1814
1917
|
const retained = owner.sourceFileCache.getRetained(path, owner.snapshotId, owner.project.id);
|
|
1815
1918
|
if (retained) {
|
|
@@ -1825,11 +1928,11 @@ export class Program {
|
|
|
1825
1928
|
return undefined;
|
|
1826
1929
|
}
|
|
1827
1930
|
// Create a new RemoteSourceFile and cache it (set returns existing if hash matches)
|
|
1828
|
-
const decoded = new RemoteSourceFile(binaryData, owner.decoder, owner.client.getTimingCollector());
|
|
1931
|
+
const decoded = new RemoteSourceFile(binaryData, owner.decoder, owner.client.getTimingCollector(), owner.project.api);
|
|
1829
1932
|
return owner.sourceFileCache.set(decoded, owner.snapshotId, owner.project.id);
|
|
1830
1933
|
}, function* (file) {
|
|
1831
1934
|
const fileName = resolveFileName(file);
|
|
1832
|
-
const path = owner.toPath(fileName);
|
|
1935
|
+
const path = owner.toPath(fileName, owner.project.currentDirectory);
|
|
1833
1936
|
// Check if we already have a retained cache entry for this (snapshot, project) pair
|
|
1834
1937
|
const retained = owner.sourceFileCache.getRetained(path, owner.snapshotId, owner.project.id);
|
|
1835
1938
|
if (retained) {
|
|
@@ -1845,7 +1948,7 @@ export class Program {
|
|
|
1845
1948
|
return undefined;
|
|
1846
1949
|
}
|
|
1847
1950
|
// Create a new RemoteSourceFile and cache it (set returns existing if hash matches)
|
|
1848
|
-
const decoded = new RemoteSourceFile(binaryData, owner.decoder, owner.client.getTimingCollector());
|
|
1951
|
+
const decoded = new RemoteSourceFile(binaryData, owner.decoder, owner.client.getTimingCollector(), owner.project.api);
|
|
1849
1952
|
return owner.sourceFileCache.set(decoded, owner.snapshotId, owner.project.id);
|
|
1850
1953
|
});
|
|
1851
1954
|
}
|
|
@@ -1995,9 +2098,9 @@ export class Program {
|
|
|
1995
2098
|
get getSourceFileMetadata() {
|
|
1996
2099
|
const owner = this;
|
|
1997
2100
|
return cacheGeneratorMethod(owner, "getSourceFileMetadata", function (file) {
|
|
1998
|
-
return owner.getSourceFileMetadataByPath(owner.toPath(resolveFileName(file)));
|
|
2101
|
+
return owner.getSourceFileMetadataByPath(owner.toPath(resolveFileName(file), owner.project.currentDirectory));
|
|
1999
2102
|
}, function* (file) {
|
|
2000
|
-
return yield* owner.getSourceFileMetadataByPath.gen(owner.toPath(resolveFileName(file)));
|
|
2103
|
+
return yield* owner.getSourceFileMetadataByPath.gen(owner.toPath(resolveFileName(file), owner.project.currentDirectory));
|
|
2001
2104
|
});
|
|
2002
2105
|
}
|
|
2003
2106
|
/**
|
|
@@ -2107,7 +2210,7 @@ export class Program {
|
|
|
2107
2210
|
if (!binaryData) {
|
|
2108
2211
|
return undefined;
|
|
2109
2212
|
}
|
|
2110
|
-
return new RemoteSourceFile(binaryData, owner.decoder);
|
|
2213
|
+
return new RemoteSourceFile(binaryData, owner.decoder, undefined, owner.project.api);
|
|
2111
2214
|
}, function* (file) {
|
|
2112
2215
|
const binaryData = sourceFileResponseToUint8Array(yield* apiRequest("getConfigSourceFile", {
|
|
2113
2216
|
snapshot: owner.snapshotId,
|
|
@@ -2117,7 +2220,7 @@ export class Program {
|
|
|
2117
2220
|
if (!binaryData) {
|
|
2118
2221
|
return undefined;
|
|
2119
2222
|
}
|
|
2120
|
-
return new RemoteSourceFile(binaryData, owner.decoder);
|
|
2223
|
+
return new RemoteSourceFile(binaryData, owner.decoder, undefined, owner.project.api);
|
|
2121
2224
|
});
|
|
2122
2225
|
}
|
|
2123
2226
|
/**
|
|
@@ -2574,14 +2677,15 @@ function toEmitOutput(response) {
|
|
|
2574
2677
|
export class Checker {
|
|
2575
2678
|
snapshotId;
|
|
2576
2679
|
project;
|
|
2577
|
-
client;
|
|
2578
2680
|
objectRegistry;
|
|
2579
2681
|
wellKnownSymbols;
|
|
2580
2682
|
wellKnownSignatures;
|
|
2581
|
-
|
|
2683
|
+
get client() {
|
|
2684
|
+
return this.project.api.client;
|
|
2685
|
+
}
|
|
2686
|
+
constructor(snapshotId, project, objectRegistry) {
|
|
2582
2687
|
this.snapshotId = snapshotId;
|
|
2583
2688
|
this.project = project;
|
|
2584
|
-
this.client = client;
|
|
2585
2689
|
this.objectRegistry = objectRegistry;
|
|
2586
2690
|
}
|
|
2587
2691
|
dispose() {
|
|
@@ -4267,15 +4371,15 @@ export class NodeHandle {
|
|
|
4267
4371
|
get fetchOwnerFile() {
|
|
4268
4372
|
const owner = this;
|
|
4269
4373
|
return cacheGeneratorMethod(owner, "fetchOwnerFile", function (fileOwner) {
|
|
4270
|
-
const data = fileOwner.client.apiRequestBinary("getCachedSourceFile", { file: fileOwner.record.descriptor });
|
|
4374
|
+
const data = fileOwner.api.client.apiRequestBinary("getCachedSourceFile", { file: fileOwner.record.descriptor });
|
|
4271
4375
|
if (!data)
|
|
4272
4376
|
throw new Error(`Source file '${fileOwner.record.descriptor.fileName}' is not available`);
|
|
4273
|
-
return fileOwner.
|
|
4377
|
+
return fileOwner.api.sourceFileCache.attachFile(fileOwner.record, new RemoteSourceFile(data, new Wtf8Decoder(), fileOwner.api.client.getTimingCollector(), fileOwner.api));
|
|
4274
4378
|
}, function* (fileOwner) {
|
|
4275
4379
|
const data = sourceFileResponseToUint8Array(yield* apiRequest("getCachedSourceFile", { file: fileOwner.record.descriptor }));
|
|
4276
4380
|
if (!data)
|
|
4277
4381
|
throw new Error(`Source file '${fileOwner.record.descriptor.fileName}' is not available`);
|
|
4278
|
-
return fileOwner.
|
|
4382
|
+
return fileOwner.api.sourceFileCache.attachFile(fileOwner.record, new RemoteSourceFile(data, new Wtf8Decoder(), fileOwner.api.client.getTimingCollector(), fileOwner.api));
|
|
4279
4383
|
});
|
|
4280
4384
|
}
|
|
4281
4385
|
}
|
|
@@ -4409,10 +4513,10 @@ export class Symbol {
|
|
|
4409
4513
|
}
|
|
4410
4514
|
const fileOwner = owner.storage.owner;
|
|
4411
4515
|
// A file-owned symbol's relationships are always owned by the same file.
|
|
4412
|
-
const cached = reference.file === fileOwner.record.descriptor.nodeId ? fileOwner.record.
|
|
4516
|
+
const cached = reference.file === fileOwner.record.descriptor.nodeId ? fileOwner.record.symbolsById.get(reference.id) : undefined;
|
|
4413
4517
|
if (cached)
|
|
4414
4518
|
return cached;
|
|
4415
|
-
const data = fileOwner.client.apiRequest(method, { symbol: owner.reference });
|
|
4519
|
+
const data = fileOwner.api.client.apiRequest(method, { symbol: owner.reference });
|
|
4416
4520
|
if (!data)
|
|
4417
4521
|
throw new Error(`${method} returned null symbol for Symbol ${owner.id}`);
|
|
4418
4522
|
return owner.internFileSymbol(fileOwner, data);
|
|
@@ -4422,7 +4526,7 @@ export class Symbol {
|
|
|
4422
4526
|
}
|
|
4423
4527
|
const fileOwner = owner.storage.owner;
|
|
4424
4528
|
// A file-owned symbol's relationships are always owned by the same file.
|
|
4425
|
-
const cached = reference.file === fileOwner.record.descriptor.nodeId ? fileOwner.record.
|
|
4529
|
+
const cached = reference.file === fileOwner.record.descriptor.nodeId ? fileOwner.record.symbolsById.get(reference.id) : undefined;
|
|
4426
4530
|
if (cached)
|
|
4427
4531
|
return cached;
|
|
4428
4532
|
const data = yield* apiRequest(method, { symbol: owner.reference });
|
|
@@ -4438,7 +4542,7 @@ export class Symbol {
|
|
|
4438
4542
|
return owner.storage.registry.fetchSymbols(owner, method);
|
|
4439
4543
|
}
|
|
4440
4544
|
const fileOwner = owner.storage.owner;
|
|
4441
|
-
const data = fileOwner.client.apiRequest(method, { symbol: owner.reference });
|
|
4545
|
+
const data = fileOwner.api.client.apiRequest(method, { symbol: owner.reference });
|
|
4442
4546
|
return data?.map(symbol => owner.internFileSymbol(fileOwner, symbol)) ?? [];
|
|
4443
4547
|
}, function* (method) {
|
|
4444
4548
|
if (owner.storage.kind === SymbolOwnerKind.Snapshot) {
|
|
@@ -4454,7 +4558,7 @@ export class Symbol {
|
|
|
4454
4558
|
const reference = data.reference;
|
|
4455
4559
|
if (reference.kind !== SymbolOwnerKind.File)
|
|
4456
4560
|
throw new Error(`Symbol ${reference.id} is not file-owned`);
|
|
4457
|
-
return fileOwner.
|
|
4561
|
+
return fileOwner.api.sourceFileCache.getOrCreateSymbol(fileOwner.record, reference.file, reference.id, () => new Symbol(data, { kind: SymbolOwnerKind.File, owner: fileOwner }));
|
|
4458
4562
|
}
|
|
4459
4563
|
}
|
|
4460
4564
|
class TypeObject {
|