typescript 7.1.0-dev.20261002.1 → 7.1.0-dev.20261004.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 +46 -23
- package/dist/api/async/api.d.ts.map +1 -1
- package/dist/api/async/api.js +87 -19
- package/dist/api/async/api.js.map +1 -1
- package/dist/api/async/client.d.ts.map +1 -1
- package/dist/api/async/client.js +73 -16
- package/dist/api/async/client.js.map +1 -1
- package/dist/api/async/types.d.ts +4 -3
- package/dist/api/async/types.d.ts.map +1 -1
- package/dist/api/compilerOptions.generated.d.ts +9 -8
- package/dist/api/compilerOptions.generated.d.ts.map +1 -1
- package/dist/api/compilerOptions.generated.js.map +1 -1
- package/dist/api/diagnosticFormatter.d.ts.map +1 -1
- package/dist/api/diagnosticFormatter.js.map +1 -1
- package/dist/api/fs.d.ts +10 -8
- package/dist/api/fs.d.ts.map +1 -1
- package/dist/api/fs.js.map +1 -1
- package/dist/api/node/encoder.generated.js +1 -1
- package/dist/api/node/encoder.generated.js.map +1 -1
- package/dist/api/node/node.d.ts +12 -9
- package/dist/api/node/node.d.ts.map +1 -1
- package/dist/api/node/node.generated.js +1 -1
- package/dist/api/node/node.generated.js.map +1 -1
- package/dist/api/node/node.infrastructure.d.ts.map +1 -1
- package/dist/api/node/node.infrastructure.js.map +1 -1
- package/dist/api/node/node.js +35 -10
- package/dist/api/node/node.js.map +1 -1
- package/dist/api/path.d.ts +46 -9
- package/dist/api/path.d.ts.map +1 -1
- package/dist/api/path.js +210 -56
- package/dist/api/path.js.map +1 -1
- package/dist/api/prepareCompilerOptions.generated.d.ts +5 -0
- package/dist/api/prepareCompilerOptions.generated.d.ts.map +1 -0
- package/dist/api/prepareCompilerOptions.generated.js +24 -0
- package/dist/api/prepareCompilerOptions.generated.js.map +1 -0
- package/dist/api/proto.generated.d.ts +197 -32
- package/dist/api/proto.generated.d.ts.map +1 -1
- package/dist/api/proto.generated.js +12 -0
- package/dist/api/proto.generated.js.map +1 -1
- package/dist/api/sourceFileCache.d.ts +7 -7
- package/dist/api/sourceFileCache.d.ts.map +1 -1
- package/dist/api/sourceFileCache.js.map +1 -1
- package/dist/api/sync/api.d.ts +68 -30
- package/dist/api/sync/api.d.ts.map +1 -1
- package/dist/api/sync/api.js +155 -31
- package/dist/api/sync/api.js.map +1 -1
- package/dist/api/sync/types.d.ts +4 -3
- package/dist/api/sync/types.d.ts.map +1 -1
- package/dist/api/typedPaths.d.ts +3 -0
- package/dist/api/typedPaths.d.ts.map +1 -0
- package/dist/api/typedPaths.js +2 -0
- package/dist/api/typedPaths.js.map +1 -0
- package/dist/ast/ast.d.ts +58 -7
- package/dist/ast/ast.d.ts.map +1 -1
- package/dist/ast/ast.generated.d.ts +3 -3
- package/dist/ast/ast.generated.d.ts.map +1 -1
- package/dist/ast/factory.generated.d.ts +2 -2
- package/dist/ast/factory.generated.d.ts.map +1 -1
- package/dist/ast/factory.generated.js.map +1 -1
- package/dist/ast/is.generated.d.ts.map +1 -1
- package/dist/ast/is.generated.js +2 -1
- package/dist/ast/is.generated.js.map +1 -1
- package/dist/ast/scanner.d.ts.map +1 -1
- package/dist/ast/scanner.js +1 -0
- package/dist/ast/scanner.js.map +1 -1
- package/dist/enums/caseSensitivity.d.ts +2 -0
- package/dist/enums/caseSensitivity.d.ts.map +1 -0
- package/dist/enums/caseSensitivity.enum.d.ts +5 -0
- package/dist/enums/caseSensitivity.enum.d.ts.map +1 -0
- package/dist/enums/caseSensitivity.enum.js +7 -0
- package/dist/enums/caseSensitivity.enum.js.map +1 -0
- package/dist/enums/caseSensitivity.js +7 -0
- package/dist/enums/caseSensitivity.js.map +1 -0
- package/dist/enums/syntaxKind.enum.d.ts +198 -197
- package/dist/enums/syntaxKind.enum.d.ts.map +1 -1
- package/dist/enums/syntaxKind.enum.js +198 -197
- package/dist/enums/syntaxKind.enum.js.map +1 -1
- package/dist/enums/syntaxKind.js +198 -197
- package/dist/enums/syntaxKind.js.map +1 -1
- package/dist/vscode/extensionApi.d.ts +56 -0
- package/dist/vscode/extensionApi.d.ts.map +1 -0
- package/dist/vscode/extensionApi.js +2 -0
- package/dist/vscode/extensionApi.js.map +1 -0
- package/dist/vscode/protocol.generated.d.ts +2886 -0
- package/dist/vscode/protocol.generated.d.ts.map +1 -0
- package/dist/vscode/protocol.generated.js +4 -0
- package/dist/vscode/protocol.generated.js.map +1 -0
- package/package.json +13 -9
- package/schemas/jsconfig.schema.json +3 -1
- package/schemas/tsconfig.schema.json +3 -1
package/dist/api/sync/api.js
CHANGED
|
@@ -22,9 +22,10 @@ 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,
|
|
25
|
+
import { decodeNode, getNodeId, parseNodeHandleFromCompiler, readParseOptionsKey, readSourceFileHash, readSourceFileLease, RemoteNode, RemoteSourceFile, } from "../node/node.js";
|
|
26
26
|
import { Wtf8Decoder } from "../node/wtf8.js";
|
|
27
|
-
import {
|
|
27
|
+
import { canonicalize, CaseSensitivity, pathKey, toRootedDirectoryPath, toRootedPath, } from "../path.js";
|
|
28
|
+
import { prepareCompilerOptions } from "../prepareCompilerOptions.generated.js";
|
|
28
29
|
import { resolveFileName, toCreateSnapshotRequest, validateSymbolResponse, } from "../proto.js";
|
|
29
30
|
import { SourceFileCache, } from "../sourceFileCache.js";
|
|
30
31
|
import { Client, } from "./client.js";
|
|
@@ -56,9 +57,9 @@ export class API {
|
|
|
56
57
|
/** @internal */
|
|
57
58
|
sourceFileCache;
|
|
58
59
|
toPath;
|
|
59
|
-
currentDirectory;
|
|
60
60
|
decoder = new Wtf8Decoder();
|
|
61
|
-
|
|
61
|
+
currentDirectory;
|
|
62
|
+
caseSensitivity;
|
|
62
63
|
initialized = false;
|
|
63
64
|
initializing;
|
|
64
65
|
activeSnapshots = new Map();
|
|
@@ -84,7 +85,7 @@ export class API {
|
|
|
84
85
|
const record = file.symbolCache;
|
|
85
86
|
if (!record)
|
|
86
87
|
throw new Error(`Cached source file not found for declaration`);
|
|
87
|
-
const index =
|
|
88
|
+
const index = parseNodeHandleFromCompiler(getNodeId(declaration)).index;
|
|
88
89
|
const cached = record.symbolsByDeclarationNodeIndex.get(index);
|
|
89
90
|
if (cached)
|
|
90
91
|
return cached;
|
|
@@ -96,7 +97,7 @@ export class API {
|
|
|
96
97
|
const record = file.symbolCache;
|
|
97
98
|
if (!record)
|
|
98
99
|
throw new Error(`Cached source file not found for declaration`);
|
|
99
|
-
const index =
|
|
100
|
+
const index = parseNodeHandleFromCompiler(getNodeId(declaration)).index;
|
|
100
101
|
const cached = record.symbolsByDeclarationNodeIndex.get(index);
|
|
101
102
|
if (cached)
|
|
102
103
|
return cached;
|
|
@@ -171,11 +172,9 @@ export class API {
|
|
|
171
172
|
return cacheGeneratorMethod(owner, "initializeWorker", function () {
|
|
172
173
|
try {
|
|
173
174
|
const response = owner.client.apiRequest("initialize", null);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
owner.
|
|
177
|
-
owner.currentDirectory = currentDirectory;
|
|
178
|
-
owner.toPath = (fileName, basePath = currentDirectory) => toPath(fileName, basePath, getCanonicalFileName);
|
|
175
|
+
owner.currentDirectory = response.currentDirectory;
|
|
176
|
+
owner.caseSensitivity = response.caseSensitivity;
|
|
177
|
+
owner.toPath = (fileName, basePath = response.currentDirectory) => pathKey(toRootedPath(fileName, toRootedDirectoryPath(basePath, response.currentDirectory)), response.caseSensitivity);
|
|
179
178
|
owner.initialized = true;
|
|
180
179
|
}
|
|
181
180
|
catch (error) {
|
|
@@ -185,11 +184,9 @@ export class API {
|
|
|
185
184
|
}, function* () {
|
|
186
185
|
try {
|
|
187
186
|
const response = yield* apiRequest("initialize", null);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
owner.
|
|
191
|
-
owner.currentDirectory = currentDirectory;
|
|
192
|
-
owner.toPath = (fileName, basePath = currentDirectory) => toPath(fileName, basePath, getCanonicalFileName);
|
|
187
|
+
owner.currentDirectory = response.currentDirectory;
|
|
188
|
+
owner.caseSensitivity = response.caseSensitivity;
|
|
189
|
+
owner.toPath = (fileName, basePath = response.currentDirectory) => pathKey(toRootedPath(fileName, toRootedDirectoryPath(basePath, response.currentDirectory)), response.caseSensitivity);
|
|
193
190
|
owner.initialized = true;
|
|
194
191
|
}
|
|
195
192
|
catch (error) {
|
|
@@ -205,10 +202,13 @@ export class API {
|
|
|
205
202
|
return this.currentDirectory;
|
|
206
203
|
}
|
|
207
204
|
getCanonicalFileName(fileName) {
|
|
208
|
-
|
|
205
|
+
return canonicalize(fileName, this.getCaseSensitivity());
|
|
206
|
+
}
|
|
207
|
+
getCaseSensitivity() {
|
|
208
|
+
if (this.caseSensitivity === undefined) {
|
|
209
209
|
throw new Error("API has not been initialized");
|
|
210
210
|
}
|
|
211
|
-
return this.
|
|
211
|
+
return this.caseSensitivity;
|
|
212
212
|
}
|
|
213
213
|
getNewLine() {
|
|
214
214
|
return "\n";
|
|
@@ -220,6 +220,9 @@ export class API {
|
|
|
220
220
|
const orchestratorResponse = owner.client.apiRequest("createBuildOrchestrator", {
|
|
221
221
|
...buildOrchestratorOptions,
|
|
222
222
|
...buildOrchestratorOptions.overrideCompilerOptions,
|
|
223
|
+
cwd: buildOrchestratorOptions.cwd === undefined
|
|
224
|
+
? undefined
|
|
225
|
+
: toRootedDirectoryPath(buildOrchestratorOptions.cwd, owner.getCurrentDirectory()),
|
|
223
226
|
rootNames,
|
|
224
227
|
});
|
|
225
228
|
const orchestrator = new BuildOrchestrator(owner.client, orchestratorResponse, () => {
|
|
@@ -232,6 +235,9 @@ export class API {
|
|
|
232
235
|
const orchestratorResponse = yield* apiRequest("createBuildOrchestrator", {
|
|
233
236
|
...buildOrchestratorOptions,
|
|
234
237
|
...buildOrchestratorOptions.overrideCompilerOptions,
|
|
238
|
+
cwd: buildOrchestratorOptions.cwd === undefined
|
|
239
|
+
? undefined
|
|
240
|
+
: toRootedDirectoryPath(buildOrchestratorOptions.cwd, owner.getCurrentDirectory()),
|
|
235
241
|
rootNames,
|
|
236
242
|
});
|
|
237
243
|
const orchestrator = new BuildOrchestrator(owner.client, orchestratorResponse, () => {
|
|
@@ -494,11 +500,15 @@ export class API {
|
|
|
494
500
|
const prepareOptions = (options) => {
|
|
495
501
|
if (!options)
|
|
496
502
|
return undefined;
|
|
497
|
-
const { moduleResolver, ...rest } = options;
|
|
503
|
+
const { moduleResolver, projectReferences, ...rest } = options;
|
|
498
504
|
moduleResolver?.ensureNotDisposed();
|
|
499
505
|
return {
|
|
500
506
|
...rest,
|
|
501
507
|
moduleResolver: moduleResolver?.id,
|
|
508
|
+
projectReferences: projectReferences?.map(reference => ({
|
|
509
|
+
...reference,
|
|
510
|
+
path: toRootedPath(reference.path, this.getCurrentDirectory()),
|
|
511
|
+
})),
|
|
502
512
|
};
|
|
503
513
|
};
|
|
504
514
|
return {
|
|
@@ -627,7 +637,7 @@ export class API {
|
|
|
627
637
|
: undefined;
|
|
628
638
|
try {
|
|
629
639
|
const id = owner.client.apiRequest("createModuleResolver", {
|
|
630
|
-
compilerOptions,
|
|
640
|
+
compilerOptions: prepareCompilerOptions(compilerOptions, owner.getCurrentDirectory()),
|
|
631
641
|
moduleResolutions: options?.moduleResolutions,
|
|
632
642
|
resolveModuleNameCallback: callback?.name,
|
|
633
643
|
});
|
|
@@ -644,7 +654,7 @@ export class API {
|
|
|
644
654
|
: undefined;
|
|
645
655
|
try {
|
|
646
656
|
const id = yield* apiRequest("createModuleResolver", {
|
|
647
|
-
compilerOptions,
|
|
657
|
+
compilerOptions: prepareCompilerOptions(compilerOptions, owner.getCurrentDirectory()),
|
|
648
658
|
moduleResolutions: options?.moduleResolutions,
|
|
649
659
|
resolveModuleNameCallback: callback?.name,
|
|
650
660
|
});
|
|
@@ -939,7 +949,8 @@ export class Snapshot {
|
|
|
939
949
|
}
|
|
940
950
|
getConfiguredProject(configFileName) {
|
|
941
951
|
this.ensureNotDisposed();
|
|
942
|
-
|
|
952
|
+
const id = this.toPath(configFileName);
|
|
953
|
+
return this.projectMap.get(id);
|
|
943
954
|
}
|
|
944
955
|
getProject(projectId) {
|
|
945
956
|
this.ensureNotDisposed();
|
|
@@ -1912,7 +1923,34 @@ export class Program {
|
|
|
1912
1923
|
const owner = this;
|
|
1913
1924
|
return cacheGeneratorMethod(owner, "getSourceFile", function (file) {
|
|
1914
1925
|
const fileName = resolveFileName(file);
|
|
1915
|
-
const path = owner.
|
|
1926
|
+
const path = owner.pathKeyForFileName(fileName);
|
|
1927
|
+
return owner.getSourceFileWorker(file, path);
|
|
1928
|
+
}, function* (file) {
|
|
1929
|
+
const fileName = resolveFileName(file);
|
|
1930
|
+
const path = owner.pathKeyForFileName(fileName);
|
|
1931
|
+
return yield* owner.getSourceFileWorker.gen(file, path);
|
|
1932
|
+
});
|
|
1933
|
+
}
|
|
1934
|
+
/**
|
|
1935
|
+
* Returns the source file for an already-canonical path.
|
|
1936
|
+
*
|
|
1937
|
+
* @internal
|
|
1938
|
+
*/
|
|
1939
|
+
get getSourceFileByPath() {
|
|
1940
|
+
const owner = this;
|
|
1941
|
+
return cacheGeneratorMethod(owner, "getSourceFileByPath", function (path) {
|
|
1942
|
+
// The wire format is a string, but the cache key remains the supplied
|
|
1943
|
+
// PathKey and is never treated as a RootedPath.
|
|
1944
|
+
return owner.getSourceFileWorker(path, path);
|
|
1945
|
+
}, function* (path) {
|
|
1946
|
+
// The wire format is a string, but the cache key remains the supplied
|
|
1947
|
+
// PathKey and is never treated as a RootedPath.
|
|
1948
|
+
return yield* owner.getSourceFileWorker.gen(path, path);
|
|
1949
|
+
});
|
|
1950
|
+
}
|
|
1951
|
+
get getSourceFileWorker() {
|
|
1952
|
+
const owner = this;
|
|
1953
|
+
return cacheGeneratorMethod(owner, "getSourceFileWorker", function (file, path) {
|
|
1916
1954
|
// Check if we already have a retained cache entry for this (snapshot, project) pair
|
|
1917
1955
|
const retained = owner.sourceFileCache.getRetained(path, owner.snapshotId, owner.project.id);
|
|
1918
1956
|
if (retained) {
|
|
@@ -1930,9 +1968,7 @@ export class Program {
|
|
|
1930
1968
|
// Create a new RemoteSourceFile and cache it (set returns existing if hash matches)
|
|
1931
1969
|
const decoded = new RemoteSourceFile(binaryData, owner.decoder, owner.client.getTimingCollector(), owner.project.api);
|
|
1932
1970
|
return owner.sourceFileCache.set(decoded, owner.snapshotId, owner.project.id);
|
|
1933
|
-
}, function* (file) {
|
|
1934
|
-
const fileName = resolveFileName(file);
|
|
1935
|
-
const path = owner.toPath(fileName, owner.project.currentDirectory);
|
|
1971
|
+
}, function* (file, path) {
|
|
1936
1972
|
// Check if we already have a retained cache entry for this (snapshot, project) pair
|
|
1937
1973
|
const retained = owner.sourceFileCache.getRetained(path, owner.snapshotId, owner.project.id);
|
|
1938
1974
|
if (retained) {
|
|
@@ -2098,9 +2134,9 @@ export class Program {
|
|
|
2098
2134
|
get getSourceFileMetadata() {
|
|
2099
2135
|
const owner = this;
|
|
2100
2136
|
return cacheGeneratorMethod(owner, "getSourceFileMetadata", function (file) {
|
|
2101
|
-
return owner.getSourceFileMetadataByPath(owner.
|
|
2137
|
+
return owner.getSourceFileMetadataByPath(owner.pathKeyForFileName(resolveFileName(file)));
|
|
2102
2138
|
}, function* (file) {
|
|
2103
|
-
return yield* owner.getSourceFileMetadataByPath.gen(owner.
|
|
2139
|
+
return yield* owner.getSourceFileMetadataByPath.gen(owner.pathKeyForFileName(resolveFileName(file)));
|
|
2104
2140
|
});
|
|
2105
2141
|
}
|
|
2106
2142
|
/**
|
|
@@ -2130,6 +2166,8 @@ export class Program {
|
|
|
2130
2166
|
get fetchSourceFileMetadata() {
|
|
2131
2167
|
const owner = this;
|
|
2132
2168
|
return cacheGeneratorMethod(owner, "fetchSourceFileMetadata", function (path) {
|
|
2169
|
+
// PathKey is serialized as a string; the server deliberately treats all
|
|
2170
|
+
// client-provided path text as untrusted input.
|
|
2133
2171
|
const data = owner.client.apiRequest("getSourceFileMetadata", {
|
|
2134
2172
|
snapshot: owner.snapshotId,
|
|
2135
2173
|
project: owner.project.id,
|
|
@@ -2137,6 +2175,8 @@ export class Program {
|
|
|
2137
2175
|
});
|
|
2138
2176
|
return data ?? undefined;
|
|
2139
2177
|
}, function* (path) {
|
|
2178
|
+
// PathKey is serialized as a string; the server deliberately treats all
|
|
2179
|
+
// client-provided path text as untrusted input.
|
|
2140
2180
|
const data = yield* apiRequest("getSourceFileMetadata", {
|
|
2141
2181
|
snapshot: owner.snapshotId,
|
|
2142
2182
|
project: owner.project.id,
|
|
@@ -2145,6 +2185,9 @@ export class Program {
|
|
|
2145
2185
|
return data ?? undefined;
|
|
2146
2186
|
});
|
|
2147
2187
|
}
|
|
2188
|
+
pathKeyForFileName(fileName) {
|
|
2189
|
+
return this.toPath(fileName, this.project.currentDirectory);
|
|
2190
|
+
}
|
|
2148
2191
|
/**
|
|
2149
2192
|
* Returns whether the given source file was loaded as part of an external library
|
|
2150
2193
|
* (e.g. a dependency resolved from `node_modules`). The underlying program metadata is
|
|
@@ -2691,6 +2734,87 @@ export class Checker {
|
|
|
2691
2734
|
dispose() {
|
|
2692
2735
|
this.objectRegistry.clear();
|
|
2693
2736
|
}
|
|
2737
|
+
/** Get the merged symbol, or the original symbol if it has not been merged. */
|
|
2738
|
+
get getMergedSymbol() {
|
|
2739
|
+
const owner = this;
|
|
2740
|
+
return cacheGeneratorMethod(owner, "getMergedSymbol", function (symbol) {
|
|
2741
|
+
const data = owner.client.apiRequest("getMergedSymbol", {
|
|
2742
|
+
snapshot: owner.snapshotId,
|
|
2743
|
+
project: owner.project.id,
|
|
2744
|
+
symbol: symbol.reference,
|
|
2745
|
+
});
|
|
2746
|
+
return owner.objectRegistry.getOrCreateSymbol(data);
|
|
2747
|
+
}, function* (symbol) {
|
|
2748
|
+
const data = yield* apiRequest("getMergedSymbol", {
|
|
2749
|
+
snapshot: owner.snapshotId,
|
|
2750
|
+
project: owner.project.id,
|
|
2751
|
+
symbol: symbol.reference,
|
|
2752
|
+
});
|
|
2753
|
+
return owner.objectRegistry.getOrCreateSymbol(data);
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2756
|
+
/**
|
|
2757
|
+
* Get a node's merged symbol. For a declaration, prefer
|
|
2758
|
+
* {@link Checker.getSymbolOfDeclaration} for a non-nullable result.
|
|
2759
|
+
*/
|
|
2760
|
+
get getSymbolOfNode() {
|
|
2761
|
+
const owner = this;
|
|
2762
|
+
return cacheGeneratorMethod(owner, "getSymbolOfNode", function (node) {
|
|
2763
|
+
const data = owner.client.apiRequest("getSymbolOfNode", {
|
|
2764
|
+
snapshot: owner.snapshotId,
|
|
2765
|
+
project: owner.project.id,
|
|
2766
|
+
location: getNodeId(node),
|
|
2767
|
+
});
|
|
2768
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
2769
|
+
}, function* (node) {
|
|
2770
|
+
const data = yield* apiRequest("getSymbolOfNode", {
|
|
2771
|
+
snapshot: owner.snapshotId,
|
|
2772
|
+
project: owner.project.id,
|
|
2773
|
+
location: getNodeId(node),
|
|
2774
|
+
});
|
|
2775
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
2776
|
+
});
|
|
2777
|
+
}
|
|
2778
|
+
/** Get a declaration's merged symbol. */
|
|
2779
|
+
get getSymbolOfDeclaration() {
|
|
2780
|
+
const owner = this;
|
|
2781
|
+
return cacheGeneratorMethod(owner, "getSymbolOfDeclaration", function (node) {
|
|
2782
|
+
const data = owner.client.apiRequest("getSymbolOfDeclarationForChecker", {
|
|
2783
|
+
snapshot: owner.snapshotId,
|
|
2784
|
+
project: owner.project.id,
|
|
2785
|
+
location: getNodeId(node),
|
|
2786
|
+
});
|
|
2787
|
+
// Declarations normally have symbols, but preserve unexpected null results at runtime.
|
|
2788
|
+
return (data && owner.objectRegistry.getOrCreateSymbol(data));
|
|
2789
|
+
}, function* (node) {
|
|
2790
|
+
const data = yield* apiRequest("getSymbolOfDeclarationForChecker", {
|
|
2791
|
+
snapshot: owner.snapshotId,
|
|
2792
|
+
project: owner.project.id,
|
|
2793
|
+
location: getNodeId(node),
|
|
2794
|
+
});
|
|
2795
|
+
// Declarations normally have symbols, but preserve unexpected null results at runtime.
|
|
2796
|
+
return (data && owner.objectRegistry.getOrCreateSymbol(data));
|
|
2797
|
+
});
|
|
2798
|
+
}
|
|
2799
|
+
/** Get a symbol's merged parent, if any. */
|
|
2800
|
+
get getParentOfSymbol() {
|
|
2801
|
+
const owner = this;
|
|
2802
|
+
return cacheGeneratorMethod(owner, "getParentOfSymbol", function (symbol) {
|
|
2803
|
+
const data = owner.client.apiRequest("getParentOfSymbolForChecker", {
|
|
2804
|
+
snapshot: owner.snapshotId,
|
|
2805
|
+
project: owner.project.id,
|
|
2806
|
+
symbol: symbol.reference,
|
|
2807
|
+
});
|
|
2808
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
2809
|
+
}, function* (symbol) {
|
|
2810
|
+
const data = yield* apiRequest("getParentOfSymbolForChecker", {
|
|
2811
|
+
snapshot: owner.snapshotId,
|
|
2812
|
+
project: owner.project.id,
|
|
2813
|
+
symbol: symbol.reference,
|
|
2814
|
+
});
|
|
2815
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2694
2818
|
get getSymbolAtLocation() {
|
|
2695
2819
|
const owner = this;
|
|
2696
2820
|
function getSymbolAtLocation(nodeOrNodes) {
|
|
@@ -4327,7 +4451,7 @@ export class NodeHandle {
|
|
|
4327
4451
|
kind;
|
|
4328
4452
|
path;
|
|
4329
4453
|
constructor(handle, canonicalProject, fileOwner) {
|
|
4330
|
-
const parsed =
|
|
4454
|
+
const parsed = parseNodeHandleFromCompiler(handle);
|
|
4331
4455
|
this.index = parsed.index;
|
|
4332
4456
|
this.kind = parsed.kind;
|
|
4333
4457
|
this.path = parsed.path;
|
|
@@ -4349,7 +4473,7 @@ export class NodeHandle {
|
|
|
4349
4473
|
}
|
|
4350
4474
|
if (!project)
|
|
4351
4475
|
throw new Error(`Node handle for '${owner.path}' has no project context`);
|
|
4352
|
-
const sourceFile = project.program.
|
|
4476
|
+
const sourceFile = project.program.getSourceFileByPath(owner.path);
|
|
4353
4477
|
if (!sourceFile) {
|
|
4354
4478
|
return undefined;
|
|
4355
4479
|
}
|
|
@@ -4361,7 +4485,7 @@ export class NodeHandle {
|
|
|
4361
4485
|
}
|
|
4362
4486
|
if (!project)
|
|
4363
4487
|
throw new Error(`Node handle for '${owner.path}' has no project context`);
|
|
4364
|
-
const sourceFile = yield* project.program.
|
|
4488
|
+
const sourceFile = yield* project.program.getSourceFileByPath.gen(owner.path);
|
|
4365
4489
|
if (!sourceFile) {
|
|
4366
4490
|
return undefined;
|
|
4367
4491
|
}
|