typescript 7.1.0-dev.20260826.1 → 7.1.0-dev.20260828.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 +24 -5
- package/dist/api/async/api.d.ts.map +1 -1
- package/dist/api/async/api.js +59 -7
- package/dist/api/async/api.js.map +1 -1
- package/dist/api/node/encoder.js +1 -1
- package/dist/api/node/encoder.js.map +1 -1
- package/dist/api/node/node.generated.d.ts +1 -1
- package/dist/api/node/node.generated.d.ts.map +1 -1
- package/dist/api/node/node.generated.js +5 -1
- package/dist/api/node/node.generated.js.map +1 -1
- package/dist/api/node/protocol.d.ts +1 -1
- package/dist/api/node/protocol.js +1 -1
- package/dist/api/proto.generated.d.ts +5 -2
- package/dist/api/proto.generated.d.ts.map +1 -1
- package/dist/api/sync/api.d.ts +782 -202
- package/dist/api/sync/api.d.ts.map +1 -1
- package/dist/api/sync/api.js +2993 -1161
- package/dist/api/sync/api.js.map +1 -1
- package/dist/api/sync/client.d.ts +2 -1
- package/dist/api/sync/client.d.ts.map +1 -1
- package/dist/api/sync/client.js +3 -0
- package/dist/api/sync/client.js.map +1 -1
- package/dist/api/sync/generatorSupport.d.ts +17 -0
- package/dist/api/sync/generatorSupport.d.ts.map +1 -0
- package/dist/api/sync/generatorSupport.js +82 -0
- package/dist/api/sync/generatorSupport.js.map +1 -0
- package/dist/api/sync/types.d.ts +141 -35
- package/dist/api/sync/types.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/api/sync/api.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3
|
-
// !!! THIS FILE IS AUTO-GENERATED - DO NOT EDIT !!!
|
|
4
|
-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
5
|
-
//
|
|
6
|
-
// Source: src/api/async/api.ts
|
|
7
|
-
// Regenerate: npm run generate (from packages/typescript)
|
|
8
|
-
//
|
|
1
|
+
import { apiRequest, cacheGeneratorMethod, } from "./generatorSupport.js";
|
|
9
2
|
import { CheckFlags } from "#enums/checkFlags";
|
|
10
3
|
import { CompletionItemKind } from "#enums/completionItemKind";
|
|
11
4
|
import { DiagnosticCategory } from "#enums/diagnosticCategory";
|
|
@@ -33,6 +26,8 @@ import { Client, } from "./client.js";
|
|
|
33
26
|
export { formatDiagnostics, formatDiagnosticsWithColorAndContext } from "../diagnosticFormatter.js";
|
|
34
27
|
export { documentURIToFileName, fileNameToDocumentURI } from "../path.js";
|
|
35
28
|
export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, ModifierFlags, ModuleKind, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypeFormatFlags, TypePredicateKind };
|
|
29
|
+
export { all } from "./generatorSupport.js";
|
|
30
|
+
import { all, } from "./generatorSupport.js";
|
|
36
31
|
export class API {
|
|
37
32
|
client;
|
|
38
33
|
sourceFileCache;
|
|
@@ -46,33 +41,55 @@ export class API {
|
|
|
46
41
|
constructor(options = {}) {
|
|
47
42
|
this.client = new Client(options);
|
|
48
43
|
this.sourceFileCache = new SourceFileCache();
|
|
49
|
-
this.internal = new InternalAPI(this.client,
|
|
44
|
+
this.internal = new InternalAPI(this.client, this.ensureInitialized);
|
|
50
45
|
}
|
|
51
46
|
/**
|
|
52
47
|
* Create an API instance from an existing LSP connection's API session.
|
|
53
48
|
* Use this when connecting to an API pipe provided by an LSP server via custom/initializeAPISession.
|
|
54
49
|
*/
|
|
55
|
-
static fromLSPConnection(
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.currentDirectory = currentDirectory;
|
|
73
|
-
this.toPath = (fileName) => toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
74
|
-
this.initialized = true;
|
|
50
|
+
static get fromLSPConnection() {
|
|
51
|
+
const owner = this;
|
|
52
|
+
return cacheGeneratorMethod(owner, "fromLSPConnection", function (options) {
|
|
53
|
+
const api = new API(options);
|
|
54
|
+
api.ensureInitialized();
|
|
55
|
+
return api;
|
|
56
|
+
}, function* (options) {
|
|
57
|
+
const api = new API(options);
|
|
58
|
+
yield* api.ensureInitialized.gen();
|
|
59
|
+
return api;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
batch(...requestGenerators) {
|
|
63
|
+
const batches = all(...requestGenerators);
|
|
64
|
+
let state = batches.next();
|
|
65
|
+
while (!state.done) {
|
|
66
|
+
state = batches.next(this.client.batchRequests(state.value).responses);
|
|
75
67
|
}
|
|
68
|
+
return state.value;
|
|
69
|
+
}
|
|
70
|
+
get ensureInitialized() {
|
|
71
|
+
const owner = this;
|
|
72
|
+
return cacheGeneratorMethod(owner, "ensureInitialized", function () {
|
|
73
|
+
if (!owner.initialized) {
|
|
74
|
+
const response = owner.client.apiRequest("initialize", null);
|
|
75
|
+
const getCanonicalFileName = createGetCanonicalFileName(response.useCaseSensitiveFileNames);
|
|
76
|
+
const currentDirectory = response.currentDirectory;
|
|
77
|
+
owner.getCanonicalFileNameWorker = getCanonicalFileName;
|
|
78
|
+
owner.currentDirectory = currentDirectory;
|
|
79
|
+
owner.toPath = (fileName) => toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
80
|
+
owner.initialized = true;
|
|
81
|
+
}
|
|
82
|
+
}, function* () {
|
|
83
|
+
if (!owner.initialized) {
|
|
84
|
+
const response = yield* apiRequest("initialize", null);
|
|
85
|
+
const getCanonicalFileName = createGetCanonicalFileName(response.useCaseSensitiveFileNames);
|
|
86
|
+
const currentDirectory = response.currentDirectory;
|
|
87
|
+
owner.getCanonicalFileNameWorker = getCanonicalFileName;
|
|
88
|
+
owner.currentDirectory = currentDirectory;
|
|
89
|
+
owner.toPath = (fileName) => toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
90
|
+
owner.initialized = true;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
76
93
|
}
|
|
77
94
|
getCurrentDirectory() {
|
|
78
95
|
if (this.currentDirectory === undefined) {
|
|
@@ -89,96 +106,206 @@ export class API {
|
|
|
89
106
|
getNewLine() {
|
|
90
107
|
return "\n";
|
|
91
108
|
}
|
|
92
|
-
parseConfigFile(
|
|
93
|
-
this
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
this
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
109
|
+
get parseConfigFile() {
|
|
110
|
+
const owner = this;
|
|
111
|
+
return cacheGeneratorMethod(owner, "parseConfigFile", function (file) {
|
|
112
|
+
owner.ensureInitialized();
|
|
113
|
+
return owner.client.apiRequest("parseConfigFile", { file });
|
|
114
|
+
}, function* (file) {
|
|
115
|
+
yield* owner.ensureInitialized.gen();
|
|
116
|
+
return yield* apiRequest("parseConfigFile", { file });
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
get parseCommandLine() {
|
|
120
|
+
const owner = this;
|
|
121
|
+
return cacheGeneratorMethod(owner, "parseCommandLine", function (commandLine) {
|
|
122
|
+
owner.ensureInitialized();
|
|
123
|
+
return owner.client.apiRequest("parseCommandLine", { commandLine });
|
|
124
|
+
}, function* (commandLine) {
|
|
125
|
+
yield* owner.ensureInitialized.gen();
|
|
126
|
+
return yield* apiRequest("parseCommandLine", { commandLine });
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
get readConfigFile() {
|
|
130
|
+
const owner = this;
|
|
131
|
+
return cacheGeneratorMethod(owner, "readConfigFile", function (file) {
|
|
132
|
+
owner.ensureInitialized();
|
|
133
|
+
return owner.client.apiRequest("readConfigFile", { file });
|
|
134
|
+
}, function* (file) {
|
|
135
|
+
yield* owner.ensureInitialized.gen();
|
|
136
|
+
return yield* apiRequest("readConfigFile", { file });
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
get parseJsonConfigFileContent() {
|
|
140
|
+
const owner = this;
|
|
141
|
+
return cacheGeneratorMethod(owner, "parseJsonConfigFileContent", function (json, options) {
|
|
142
|
+
owner.ensureInitialized();
|
|
143
|
+
return owner.client.apiRequest("parseJsonConfigFileContent", { json, ...options });
|
|
144
|
+
}, function* (json, options) {
|
|
145
|
+
yield* owner.ensureInitialized.gen();
|
|
146
|
+
return yield* apiRequest("parseJsonConfigFileContent", { json, ...options });
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
get transpileModule() {
|
|
150
|
+
const owner = this;
|
|
151
|
+
return cacheGeneratorMethod(owner, "transpileModule", function (input, options = {}) {
|
|
152
|
+
owner.ensureInitialized();
|
|
153
|
+
return owner.client.apiRequest("transpileModule", { input, options });
|
|
154
|
+
}, function* (input, options = {}) {
|
|
155
|
+
yield* owner.ensureInitialized.gen();
|
|
156
|
+
return yield* apiRequest("transpileModule", { input, options });
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
get transpileModuleFromFile() {
|
|
160
|
+
const owner = this;
|
|
161
|
+
return cacheGeneratorMethod(owner, "transpileModuleFromFile", function (fileName, options = {}) {
|
|
162
|
+
owner.ensureInitialized();
|
|
163
|
+
return owner.client.apiRequest("transpileModuleFromFile", { fileName, options });
|
|
164
|
+
}, function* (fileName, options = {}) {
|
|
165
|
+
yield* owner.ensureInitialized.gen();
|
|
166
|
+
return yield* apiRequest("transpileModuleFromFile", { fileName, options });
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
get transpileDeclaration() {
|
|
170
|
+
const owner = this;
|
|
171
|
+
return cacheGeneratorMethod(owner, "transpileDeclaration", function (input, options = {}) {
|
|
172
|
+
owner.ensureInitialized();
|
|
173
|
+
return owner.client.apiRequest("transpileDeclaration", { input, options });
|
|
174
|
+
}, function* (input, options = {}) {
|
|
175
|
+
yield* owner.ensureInitialized.gen();
|
|
176
|
+
return yield* apiRequest("transpileDeclaration", { input, options });
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
get transpileDeclarationFromFile() {
|
|
180
|
+
const owner = this;
|
|
181
|
+
return cacheGeneratorMethod(owner, "transpileDeclarationFromFile", function (fileName, options = {}) {
|
|
182
|
+
owner.ensureInitialized();
|
|
183
|
+
return owner.client.apiRequest("transpileDeclarationFromFile", { fileName, options });
|
|
184
|
+
}, function* (fileName, options = {}) {
|
|
185
|
+
yield* owner.ensureInitialized.gen();
|
|
186
|
+
return yield* apiRequest("transpileDeclarationFromFile", { fileName, options });
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
get updateSnapshot() {
|
|
190
|
+
const owner = this;
|
|
191
|
+
return cacheGeneratorMethod(owner, "updateSnapshot", function (params) {
|
|
192
|
+
owner.ensureInitialized();
|
|
193
|
+
const requestParams = toUpdateSnapshotRequest(params);
|
|
194
|
+
const data = owner.client.apiRequest("updateSnapshot", requestParams);
|
|
195
|
+
// Retain cached source files from previous snapshot for unchanged files
|
|
196
|
+
if (owner.latestSnapshot) {
|
|
197
|
+
owner.sourceFileCache.retainForSnapshot(data.snapshot, owner.latestSnapshot.id, data.changes);
|
|
198
|
+
if (owner.latestSnapshot.isDisposed()) {
|
|
199
|
+
owner.sourceFileCache.releaseSnapshot(owner.latestSnapshot.id);
|
|
200
|
+
}
|
|
133
201
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
202
|
+
const snapshot = new Snapshot(data, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
203
|
+
owner.activeSnapshots.delete(snapshot);
|
|
204
|
+
if (snapshot !== owner.latestSnapshot) {
|
|
205
|
+
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
owner.latestSnapshot = snapshot;
|
|
209
|
+
owner.activeSnapshots.add(snapshot);
|
|
210
|
+
return snapshot;
|
|
211
|
+
}, function* (params) {
|
|
212
|
+
yield* owner.ensureInitialized.gen();
|
|
213
|
+
const requestParams = toUpdateSnapshotRequest(params);
|
|
214
|
+
const data = yield* apiRequest("updateSnapshot", requestParams);
|
|
215
|
+
// Retain cached source files from previous snapshot for unchanged files
|
|
216
|
+
if (owner.latestSnapshot) {
|
|
217
|
+
owner.sourceFileCache.retainForSnapshot(data.snapshot, owner.latestSnapshot.id, data.changes);
|
|
218
|
+
if (owner.latestSnapshot.isDisposed()) {
|
|
219
|
+
owner.sourceFileCache.releaseSnapshot(owner.latestSnapshot.id);
|
|
220
|
+
}
|
|
139
221
|
}
|
|
222
|
+
const snapshot = new Snapshot(data, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
223
|
+
owner.activeSnapshots.delete(snapshot);
|
|
224
|
+
if (snapshot !== owner.latestSnapshot) {
|
|
225
|
+
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
owner.latestSnapshot = snapshot;
|
|
229
|
+
owner.activeSnapshots.add(snapshot);
|
|
230
|
+
return snapshot;
|
|
140
231
|
});
|
|
141
|
-
this.latestSnapshot = snapshot;
|
|
142
|
-
this.activeSnapshots.add(snapshot);
|
|
143
|
-
return snapshot;
|
|
144
232
|
}
|
|
145
|
-
close() {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
233
|
+
get close() {
|
|
234
|
+
const owner = this;
|
|
235
|
+
return cacheGeneratorMethod(owner, "close", function () {
|
|
236
|
+
// Dispose all active snapshots
|
|
237
|
+
for (const snapshot of [...owner.activeSnapshots]) {
|
|
238
|
+
snapshot.dispose();
|
|
239
|
+
}
|
|
240
|
+
// Release the latest snapshot's cache refs if still held
|
|
241
|
+
if (owner.latestSnapshot) {
|
|
242
|
+
owner.sourceFileCache.releaseSnapshot(owner.latestSnapshot.id);
|
|
243
|
+
owner.latestSnapshot = undefined;
|
|
244
|
+
}
|
|
245
|
+
owner.client.close();
|
|
246
|
+
owner.sourceFileCache.clear();
|
|
247
|
+
}, function* () {
|
|
248
|
+
// Dispose all active snapshots
|
|
249
|
+
for (const snapshot of [...owner.activeSnapshots]) {
|
|
250
|
+
yield* snapshot.dispose.gen();
|
|
251
|
+
}
|
|
252
|
+
// Release the latest snapshot's cache refs if still held
|
|
253
|
+
if (owner.latestSnapshot) {
|
|
254
|
+
owner.sourceFileCache.releaseSnapshot(owner.latestSnapshot.id);
|
|
255
|
+
owner.latestSnapshot = undefined;
|
|
256
|
+
}
|
|
257
|
+
owner.client.close();
|
|
258
|
+
owner.sourceFileCache.clear();
|
|
259
|
+
});
|
|
157
260
|
}
|
|
158
261
|
clearSourceFileCache() {
|
|
159
262
|
this.sourceFileCache.clear();
|
|
160
263
|
}
|
|
161
|
-
runWithTemporaryFileUpdate(
|
|
162
|
-
this
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
264
|
+
get runWithTemporaryFileUpdate() {
|
|
265
|
+
const owner = this;
|
|
266
|
+
return cacheGeneratorMethod(owner, "runWithTemporaryFileUpdate", function (baseSnapshot, file, newText, cb) {
|
|
267
|
+
owner.ensureInitialized();
|
|
268
|
+
if (!owner.activeSnapshots.has(baseSnapshot) || baseSnapshot.isDisposed()) {
|
|
269
|
+
throw new Error("Cannot run a temporary file update on an inactive snapshot");
|
|
270
|
+
}
|
|
271
|
+
const data = owner.client.apiRequest("updateTemporarySnapshot", { snapshot: baseSnapshot.id, file, newText });
|
|
272
|
+
// Retain cached source files from the base snapshot for files unchanged by
|
|
273
|
+
// the temporary update. The temporary snapshot is not the latest snapshot, so
|
|
274
|
+
// we never release the latest snapshot's cache here.
|
|
275
|
+
owner.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
276
|
+
const snapshot = new Snapshot(data, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
277
|
+
owner.activeSnapshots.delete(snapshot);
|
|
278
|
+
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
279
|
+
});
|
|
280
|
+
owner.activeSnapshots.add(snapshot);
|
|
281
|
+
try {
|
|
282
|
+
cb(snapshot);
|
|
283
|
+
}
|
|
284
|
+
finally {
|
|
285
|
+
snapshot.dispose();
|
|
286
|
+
}
|
|
287
|
+
}, function* (baseSnapshot, file, newText, cb) {
|
|
288
|
+
yield* owner.ensureInitialized.gen();
|
|
289
|
+
if (!owner.activeSnapshots.has(baseSnapshot) || baseSnapshot.isDisposed()) {
|
|
290
|
+
throw new Error("Cannot run a temporary file update on an inactive snapshot");
|
|
291
|
+
}
|
|
292
|
+
const data = yield* apiRequest("updateTemporarySnapshot", { snapshot: baseSnapshot.id, file, newText });
|
|
293
|
+
// Retain cached source files from the base snapshot for files unchanged by
|
|
294
|
+
// the temporary update. The temporary snapshot is not the latest snapshot, so
|
|
295
|
+
// we never release the latest snapshot's cache here.
|
|
296
|
+
owner.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
|
|
297
|
+
const snapshot = new Snapshot(data, owner.client, owner.sourceFileCache, owner.toPath, owner, () => {
|
|
298
|
+
owner.activeSnapshots.delete(snapshot);
|
|
299
|
+
owner.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
300
|
+
});
|
|
301
|
+
owner.activeSnapshots.add(snapshot);
|
|
302
|
+
try {
|
|
303
|
+
yield* (cb(snapshot) ?? []);
|
|
304
|
+
}
|
|
305
|
+
finally {
|
|
306
|
+
yield* snapshot.dispose.gen();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
182
309
|
}
|
|
183
310
|
/**
|
|
184
311
|
* Returns a snapshot of collected timing information for requests made
|
|
@@ -191,12 +318,22 @@ export class API {
|
|
|
191
318
|
* `collectTiming` option; when it is not, the returned snapshot has
|
|
192
319
|
* `enabled: false` and zeroed totals.
|
|
193
320
|
*/
|
|
194
|
-
getTimingInfo() {
|
|
195
|
-
|
|
321
|
+
get getTimingInfo() {
|
|
322
|
+
const owner = this;
|
|
323
|
+
return cacheGeneratorMethod(owner, "getTimingInfo", function () {
|
|
324
|
+
return owner.client.getTimingInfo();
|
|
325
|
+
}, function* () {
|
|
326
|
+
return owner.client.getTimingInfo();
|
|
327
|
+
});
|
|
196
328
|
}
|
|
197
329
|
/** Clears all accumulated timing totals and recent-request history, on both the client and the server. */
|
|
198
|
-
resetTimingInfo() {
|
|
199
|
-
|
|
330
|
+
get resetTimingInfo() {
|
|
331
|
+
const owner = this;
|
|
332
|
+
return cacheGeneratorMethod(owner, "resetTimingInfo", function () {
|
|
333
|
+
return owner.client.resetTimingInfo();
|
|
334
|
+
}, function* () {
|
|
335
|
+
return owner.client.resetTimingInfo();
|
|
336
|
+
});
|
|
200
337
|
}
|
|
201
338
|
}
|
|
202
339
|
export class InternalAPI {
|
|
@@ -207,19 +344,39 @@ export class InternalAPI {
|
|
|
207
344
|
this.client = client;
|
|
208
345
|
this.ensureInitialized = ensureInitialized;
|
|
209
346
|
}
|
|
210
|
-
startCPUProfile(
|
|
211
|
-
this
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
return
|
|
347
|
+
get startCPUProfile() {
|
|
348
|
+
const owner = this;
|
|
349
|
+
return cacheGeneratorMethod(owner, "startCPUProfile", function (dir) {
|
|
350
|
+
owner.ensureInitialized();
|
|
351
|
+
owner.client.apiRequest("startCPUProfile", { dir });
|
|
352
|
+
}, function* (dir) {
|
|
353
|
+
yield* owner.ensureInitialized.gen();
|
|
354
|
+
yield* apiRequest("startCPUProfile", { dir });
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
get stopCPUProfile() {
|
|
358
|
+
const owner = this;
|
|
359
|
+
return cacheGeneratorMethod(owner, "stopCPUProfile", function () {
|
|
360
|
+
owner.ensureInitialized();
|
|
361
|
+
const result = owner.client.apiRequest("stopCPUProfile", null);
|
|
362
|
+
return result.file;
|
|
363
|
+
}, function* () {
|
|
364
|
+
yield* owner.ensureInitialized.gen();
|
|
365
|
+
const result = yield* apiRequest("stopCPUProfile", null);
|
|
366
|
+
return result.file;
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
get saveHeapProfile() {
|
|
370
|
+
const owner = this;
|
|
371
|
+
return cacheGeneratorMethod(owner, "saveHeapProfile", function (dir) {
|
|
372
|
+
owner.ensureInitialized();
|
|
373
|
+
const result = owner.client.apiRequest("saveHeapProfile", { dir });
|
|
374
|
+
return result.file;
|
|
375
|
+
}, function* (dir) {
|
|
376
|
+
yield* owner.ensureInitialized.gen();
|
|
377
|
+
const result = yield* apiRequest("saveHeapProfile", { dir });
|
|
378
|
+
return result.file;
|
|
379
|
+
});
|
|
223
380
|
}
|
|
224
381
|
}
|
|
225
382
|
export class Snapshot {
|
|
@@ -252,30 +409,56 @@ export class Snapshot {
|
|
|
252
409
|
this.ensureNotDisposed();
|
|
253
410
|
return this.projectMap.get(this.toPath(configFileName));
|
|
254
411
|
}
|
|
255
|
-
getDefaultProjectForFile(
|
|
256
|
-
this
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
412
|
+
get getDefaultProjectForFile() {
|
|
413
|
+
const owner = this;
|
|
414
|
+
return cacheGeneratorMethod(owner, "getDefaultProjectForFile", function (file) {
|
|
415
|
+
owner.ensureNotDisposed();
|
|
416
|
+
const data = owner.client.apiRequest("getDefaultProjectForFile", {
|
|
417
|
+
snapshot: owner.id,
|
|
418
|
+
file,
|
|
419
|
+
});
|
|
420
|
+
if (!data)
|
|
421
|
+
return undefined;
|
|
422
|
+
return owner.projectMap.get(owner.toPath(data.configFileName));
|
|
423
|
+
}, function* (file) {
|
|
424
|
+
owner.ensureNotDisposed();
|
|
425
|
+
const data = yield* apiRequest("getDefaultProjectForFile", {
|
|
426
|
+
snapshot: owner.id,
|
|
427
|
+
file,
|
|
428
|
+
});
|
|
429
|
+
if (!data)
|
|
430
|
+
return undefined;
|
|
431
|
+
return owner.projectMap.get(owner.toPath(data.configFileName));
|
|
260
432
|
});
|
|
261
|
-
if (!data)
|
|
262
|
-
return undefined;
|
|
263
|
-
return this.projectMap.get(this.toPath(data.configFileName));
|
|
264
433
|
}
|
|
265
434
|
[globalThis.Symbol.dispose]() {
|
|
266
435
|
this.dispose();
|
|
267
436
|
}
|
|
268
|
-
dispose() {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
437
|
+
get dispose() {
|
|
438
|
+
const owner = this;
|
|
439
|
+
return cacheGeneratorMethod(owner, "dispose", function () {
|
|
440
|
+
if (owner.disposed)
|
|
441
|
+
return;
|
|
442
|
+
owner.disposed = true;
|
|
443
|
+
for (const project of owner.projectMap.values()) {
|
|
444
|
+
project.dispose();
|
|
445
|
+
}
|
|
446
|
+
owner.projectMap.clear();
|
|
447
|
+
owner.snapshotRegistry.clear();
|
|
448
|
+
owner.onDispose();
|
|
449
|
+
owner.client.apiRequest("release", { snapshot: owner.id });
|
|
450
|
+
}, function* () {
|
|
451
|
+
if (owner.disposed)
|
|
452
|
+
return;
|
|
453
|
+
owner.disposed = true;
|
|
454
|
+
for (const project of owner.projectMap.values()) {
|
|
455
|
+
project.dispose();
|
|
456
|
+
}
|
|
457
|
+
owner.projectMap.clear();
|
|
458
|
+
owner.snapshotRegistry.clear();
|
|
459
|
+
owner.onDispose();
|
|
460
|
+
yield* apiRequest("release", { snapshot: owner.id });
|
|
461
|
+
});
|
|
279
462
|
}
|
|
280
463
|
isDisposed() {
|
|
281
464
|
return this.disposed;
|
|
@@ -314,45 +497,89 @@ class SnapshotObjectRegistry {
|
|
|
314
497
|
clear() {
|
|
315
498
|
this.symbols.clear();
|
|
316
499
|
}
|
|
317
|
-
fetchSymbol(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
500
|
+
get fetchSymbol() {
|
|
501
|
+
const owner = this;
|
|
502
|
+
return cacheGeneratorMethod(owner, "fetchSymbol", function (source, method, handle, projectId) {
|
|
503
|
+
if (!handle)
|
|
504
|
+
return undefined;
|
|
505
|
+
const cached = owner.getSymbol(handle);
|
|
506
|
+
if (cached)
|
|
507
|
+
return cached;
|
|
508
|
+
const data = owner.client.apiRequest(method, {
|
|
509
|
+
snapshot: owner.snapshotId,
|
|
510
|
+
project: projectId,
|
|
511
|
+
objectId: source.id,
|
|
512
|
+
});
|
|
513
|
+
if (!data)
|
|
514
|
+
throw new Error(`${method} returned null symbol for ${source.constructor.name} ${source.id}`);
|
|
515
|
+
return owner.getOrCreateSymbol(data);
|
|
516
|
+
}, function* (source, method, handle, projectId) {
|
|
517
|
+
if (!handle)
|
|
518
|
+
return undefined;
|
|
519
|
+
const cached = owner.getSymbol(handle);
|
|
520
|
+
if (cached)
|
|
521
|
+
return cached;
|
|
522
|
+
const data = yield* apiRequest(method, {
|
|
523
|
+
snapshot: owner.snapshotId,
|
|
524
|
+
project: projectId,
|
|
525
|
+
objectId: source.id,
|
|
526
|
+
});
|
|
527
|
+
if (!data)
|
|
528
|
+
throw new Error(`${method} returned null symbol for ${source.constructor.name} ${source.id}`);
|
|
529
|
+
return owner.getOrCreateSymbol(data);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
get fetchSymbols() {
|
|
533
|
+
const owner = this;
|
|
534
|
+
return cacheGeneratorMethod(owner, "fetchSymbols", function (source, method, handles, projectId) {
|
|
535
|
+
if (handles) {
|
|
536
|
+
const result = new Array(handles.length);
|
|
537
|
+
let allCached = true;
|
|
538
|
+
for (let i = 0; i < handles.length; i++) {
|
|
539
|
+
const cached = owner.getSymbol(handles[i]);
|
|
540
|
+
if (!cached) {
|
|
541
|
+
allCached = false;
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
result[i] = cached;
|
|
341
545
|
}
|
|
342
|
-
|
|
546
|
+
if (allCached)
|
|
547
|
+
return result;
|
|
343
548
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
549
|
+
const symbolData = owner.client.apiRequest(method, {
|
|
550
|
+
snapshot: owner.snapshotId,
|
|
551
|
+
project: projectId,
|
|
552
|
+
objectId: source.id,
|
|
553
|
+
});
|
|
554
|
+
if (symbolData == null)
|
|
555
|
+
return [];
|
|
556
|
+
else
|
|
557
|
+
return symbolData.map(data => owner.getOrCreateSymbol(data));
|
|
558
|
+
}, function* (source, method, handles, projectId) {
|
|
559
|
+
if (handles) {
|
|
560
|
+
const result = new Array(handles.length);
|
|
561
|
+
let allCached = true;
|
|
562
|
+
for (let i = 0; i < handles.length; i++) {
|
|
563
|
+
const cached = owner.getSymbol(handles[i]);
|
|
564
|
+
if (!cached) {
|
|
565
|
+
allCached = false;
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
result[i] = cached;
|
|
569
|
+
}
|
|
570
|
+
if (allCached)
|
|
571
|
+
return result;
|
|
572
|
+
}
|
|
573
|
+
const symbolData = yield* apiRequest(method, {
|
|
574
|
+
snapshot: owner.snapshotId,
|
|
575
|
+
project: projectId,
|
|
576
|
+
objectId: source.id,
|
|
577
|
+
});
|
|
578
|
+
if (symbolData == null)
|
|
579
|
+
return [];
|
|
580
|
+
else
|
|
581
|
+
return symbolData.map(data => owner.getOrCreateSymbol(data));
|
|
351
582
|
});
|
|
352
|
-
if (symbolData == null)
|
|
353
|
-
return [];
|
|
354
|
-
else
|
|
355
|
-
return symbolData.map(data => this.getOrCreateSymbol(data));
|
|
356
583
|
}
|
|
357
584
|
}
|
|
358
585
|
class ProjectObjectRegistry {
|
|
@@ -400,144 +627,307 @@ class ProjectObjectRegistry {
|
|
|
400
627
|
this.types.clear();
|
|
401
628
|
this.signatures.clear();
|
|
402
629
|
}
|
|
403
|
-
fetchOptionalType(
|
|
404
|
-
|
|
630
|
+
get fetchOptionalType() {
|
|
631
|
+
const owner = this;
|
|
632
|
+
return cacheGeneratorMethod(owner, "fetchOptionalType", function (source, method, handle) {
|
|
633
|
+
if (handle !== false) {
|
|
634
|
+
if (!handle)
|
|
635
|
+
return undefined;
|
|
636
|
+
const cached = owner.getType(handle);
|
|
637
|
+
if (cached)
|
|
638
|
+
return cached;
|
|
639
|
+
}
|
|
640
|
+
const data = owner.client.apiRequest(method, {
|
|
641
|
+
snapshot: owner.snapshotId,
|
|
642
|
+
project: owner.project.id,
|
|
643
|
+
objectId: source.id,
|
|
644
|
+
});
|
|
645
|
+
if (!data)
|
|
646
|
+
return undefined;
|
|
647
|
+
return owner.getOrCreateType(data);
|
|
648
|
+
}, function* (source, method, handle) {
|
|
649
|
+
if (handle !== false) {
|
|
650
|
+
if (!handle)
|
|
651
|
+
return undefined;
|
|
652
|
+
const cached = owner.getType(handle);
|
|
653
|
+
if (cached)
|
|
654
|
+
return cached;
|
|
655
|
+
}
|
|
656
|
+
const data = yield* apiRequest(method, {
|
|
657
|
+
snapshot: owner.snapshotId,
|
|
658
|
+
project: owner.project.id,
|
|
659
|
+
objectId: source.id,
|
|
660
|
+
});
|
|
661
|
+
if (!data)
|
|
662
|
+
return undefined;
|
|
663
|
+
return owner.getOrCreateType(data);
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
get fetchType() {
|
|
667
|
+
const owner = this;
|
|
668
|
+
return cacheGeneratorMethod(owner, "fetchType", function (source, method, handle) {
|
|
669
|
+
const result = owner.fetchOptionalType(source, method, handle);
|
|
670
|
+
if (result === undefined)
|
|
671
|
+
throw new Error(`${method} returned no type for ${source.constructor.name} ${source.id}`);
|
|
672
|
+
return result;
|
|
673
|
+
}, function* (source, method, handle) {
|
|
674
|
+
const result = yield* owner.fetchOptionalType.gen(source, method, handle);
|
|
675
|
+
if (result === undefined)
|
|
676
|
+
throw new Error(`${method} returned no type for ${source.constructor.name} ${source.id}`);
|
|
677
|
+
return result;
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
get fetchSymbol() {
|
|
681
|
+
const owner = this;
|
|
682
|
+
return cacheGeneratorMethod(owner, "fetchSymbol", function (source, method, handle) {
|
|
683
|
+
return owner.snapshotRegistry.fetchSymbol(source, method, handle, owner.project.id);
|
|
684
|
+
}, function* (source, method, handle) {
|
|
685
|
+
return yield* owner.snapshotRegistry.fetchSymbol.gen(source, method, handle, owner.project.id);
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
get fetchSignature() {
|
|
689
|
+
const owner = this;
|
|
690
|
+
return cacheGeneratorMethod(owner, "fetchSignature", function (source, method, handle) {
|
|
405
691
|
if (!handle)
|
|
406
692
|
return undefined;
|
|
407
|
-
const cached =
|
|
693
|
+
const cached = owner.getSignature(handle);
|
|
408
694
|
if (cached)
|
|
409
695
|
return cached;
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
return
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
let allCached = true;
|
|
448
|
-
for (let i = 0; i < handles.length; i++) {
|
|
449
|
-
const cached = this.getType(handles[i]);
|
|
450
|
-
if (!cached) {
|
|
451
|
-
allCached = false;
|
|
452
|
-
break;
|
|
696
|
+
const data = owner.client.apiRequest(method, {
|
|
697
|
+
snapshot: owner.snapshotId,
|
|
698
|
+
project: owner.project.id,
|
|
699
|
+
objectId: source.id,
|
|
700
|
+
});
|
|
701
|
+
if (!data)
|
|
702
|
+
throw new Error(`${method} returned null signature for ${source.constructor.name} ${source.id}`);
|
|
703
|
+
return owner.getOrCreateSignature(data);
|
|
704
|
+
}, function* (source, method, handle) {
|
|
705
|
+
if (!handle)
|
|
706
|
+
return undefined;
|
|
707
|
+
const cached = owner.getSignature(handle);
|
|
708
|
+
if (cached)
|
|
709
|
+
return cached;
|
|
710
|
+
const data = yield* apiRequest(method, {
|
|
711
|
+
snapshot: owner.snapshotId,
|
|
712
|
+
project: owner.project.id,
|
|
713
|
+
objectId: source.id,
|
|
714
|
+
});
|
|
715
|
+
if (!data)
|
|
716
|
+
throw new Error(`${method} returned null signature for ${source.constructor.name} ${source.id}`);
|
|
717
|
+
return owner.getOrCreateSignature(data);
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
get fetchTypes() {
|
|
721
|
+
const owner = this;
|
|
722
|
+
return cacheGeneratorMethod(owner, "fetchTypes", function (source, method, handles) {
|
|
723
|
+
if (handles) {
|
|
724
|
+
const result = new Array(handles.length);
|
|
725
|
+
let allCached = true;
|
|
726
|
+
for (let i = 0; i < handles.length; i++) {
|
|
727
|
+
const cached = owner.getType(handles[i]);
|
|
728
|
+
if (!cached) {
|
|
729
|
+
allCached = false;
|
|
730
|
+
break;
|
|
731
|
+
}
|
|
732
|
+
result[i] = cached;
|
|
453
733
|
}
|
|
454
|
-
|
|
734
|
+
if (allCached)
|
|
735
|
+
return result;
|
|
455
736
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
737
|
+
const typesData = owner.client.apiRequest(method, {
|
|
738
|
+
snapshot: owner.snapshotId,
|
|
739
|
+
project: owner.project.id,
|
|
740
|
+
objectId: source.id,
|
|
741
|
+
});
|
|
742
|
+
if (typesData == null)
|
|
743
|
+
return [];
|
|
744
|
+
else
|
|
745
|
+
return typesData.map(data => owner.getOrCreateType(data));
|
|
746
|
+
}, function* (source, method, handles) {
|
|
747
|
+
if (handles) {
|
|
748
|
+
const result = new Array(handles.length);
|
|
749
|
+
let allCached = true;
|
|
750
|
+
for (let i = 0; i < handles.length; i++) {
|
|
751
|
+
const cached = owner.getType(handles[i]);
|
|
752
|
+
if (!cached) {
|
|
753
|
+
allCached = false;
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
result[i] = cached;
|
|
757
|
+
}
|
|
758
|
+
if (allCached)
|
|
759
|
+
return result;
|
|
760
|
+
}
|
|
761
|
+
const typesData = yield* apiRequest(method, {
|
|
762
|
+
snapshot: owner.snapshotId,
|
|
763
|
+
project: owner.project.id,
|
|
764
|
+
objectId: source.id,
|
|
765
|
+
});
|
|
766
|
+
if (typesData == null)
|
|
767
|
+
return [];
|
|
768
|
+
else
|
|
769
|
+
return typesData.map(data => owner.getOrCreateType(data));
|
|
463
770
|
});
|
|
464
|
-
if (typesData == null)
|
|
465
|
-
return [];
|
|
466
|
-
else
|
|
467
|
-
return typesData.map(data => this.getOrCreateType(data));
|
|
468
771
|
}
|
|
469
|
-
fetchSymbols(
|
|
470
|
-
|
|
772
|
+
get fetchSymbols() {
|
|
773
|
+
const owner = this;
|
|
774
|
+
return cacheGeneratorMethod(owner, "fetchSymbols", function (source, method, handles) {
|
|
775
|
+
return owner.snapshotRegistry.fetchSymbols(source, method, handles, owner.project.id);
|
|
776
|
+
}, function* (source, method, handles) {
|
|
777
|
+
return yield* owner.snapshotRegistry.fetchSymbols.gen(source, method, handles, owner.project.id);
|
|
778
|
+
});
|
|
471
779
|
}
|
|
472
780
|
// getBaseTypes is a checker-level endpoint keyed by `type` (not `objectId`),
|
|
473
781
|
// so it cannot go through fetchTypes. This helper reuses that server method.
|
|
474
|
-
fetchBaseTypes(
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
return
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
return
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
})
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
782
|
+
get fetchBaseTypes() {
|
|
783
|
+
const owner = this;
|
|
784
|
+
return cacheGeneratorMethod(owner, "fetchBaseTypes", function (source) {
|
|
785
|
+
const typesData = owner.client.apiRequest("getBaseTypes", {
|
|
786
|
+
snapshot: owner.snapshotId,
|
|
787
|
+
project: owner.project.id,
|
|
788
|
+
type: source.id,
|
|
789
|
+
});
|
|
790
|
+
if (typesData == null)
|
|
791
|
+
return [];
|
|
792
|
+
return typesData.map(data => owner.getOrCreateType(data));
|
|
793
|
+
}, function* (source) {
|
|
794
|
+
const typesData = yield* apiRequest("getBaseTypes", {
|
|
795
|
+
snapshot: owner.snapshotId,
|
|
796
|
+
project: owner.project.id,
|
|
797
|
+
type: source.id,
|
|
798
|
+
});
|
|
799
|
+
if (typesData == null)
|
|
800
|
+
return [];
|
|
801
|
+
return typesData.map(data => owner.getOrCreateType(data));
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
get fetchPropertiesOfType() {
|
|
805
|
+
const owner = this;
|
|
806
|
+
return cacheGeneratorMethod(owner, "fetchPropertiesOfType", function (source) {
|
|
807
|
+
const data = owner.client.apiRequest("getPropertiesOfType", {
|
|
808
|
+
snapshot: owner.snapshotId,
|
|
809
|
+
project: owner.project.id,
|
|
810
|
+
type: source.id,
|
|
811
|
+
});
|
|
812
|
+
return data ? data.map(symbol => owner.getOrCreateSymbol(symbol)) : [];
|
|
813
|
+
}, function* (source) {
|
|
814
|
+
const data = yield* apiRequest("getPropertiesOfType", {
|
|
815
|
+
snapshot: owner.snapshotId,
|
|
816
|
+
project: owner.project.id,
|
|
817
|
+
type: source.id,
|
|
818
|
+
});
|
|
819
|
+
return data ? data.map(symbol => owner.getOrCreateSymbol(symbol)) : [];
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
get fetchApparentPropertiesOfType() {
|
|
823
|
+
const owner = this;
|
|
824
|
+
return cacheGeneratorMethod(owner, "fetchApparentPropertiesOfType", function (source) {
|
|
825
|
+
const data = owner.client.apiRequest("getApparentPropertiesOfType", {
|
|
826
|
+
snapshot: owner.snapshotId,
|
|
827
|
+
project: owner.project.id,
|
|
828
|
+
objectId: source.id,
|
|
829
|
+
});
|
|
830
|
+
return data ? data.map(symbol => owner.getOrCreateSymbol(symbol)) : [];
|
|
831
|
+
}, function* (source) {
|
|
832
|
+
const data = yield* apiRequest("getApparentPropertiesOfType", {
|
|
833
|
+
snapshot: owner.snapshotId,
|
|
834
|
+
project: owner.project.id,
|
|
835
|
+
objectId: source.id,
|
|
836
|
+
});
|
|
837
|
+
return data ? data.map(symbol => owner.getOrCreateSymbol(symbol)) : [];
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
get fetchPropertyOfType() {
|
|
841
|
+
const owner = this;
|
|
842
|
+
return cacheGeneratorMethod(owner, "fetchPropertyOfType", function (source, name) {
|
|
843
|
+
const data = owner.client.apiRequest("getPropertyOfType", {
|
|
844
|
+
snapshot: owner.snapshotId,
|
|
845
|
+
project: owner.project.id,
|
|
846
|
+
type: source.id,
|
|
847
|
+
name,
|
|
848
|
+
});
|
|
849
|
+
return data ? owner.getOrCreateSymbol(data) : undefined;
|
|
850
|
+
}, function* (source, name) {
|
|
851
|
+
const data = yield* apiRequest("getPropertyOfType", {
|
|
852
|
+
snapshot: owner.snapshotId,
|
|
853
|
+
project: owner.project.id,
|
|
854
|
+
type: source.id,
|
|
855
|
+
name,
|
|
856
|
+
});
|
|
857
|
+
return data ? owner.getOrCreateSymbol(data) : undefined;
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
get fetchSignaturesOfType() {
|
|
861
|
+
const owner = this;
|
|
862
|
+
return cacheGeneratorMethod(owner, "fetchSignaturesOfType", function (source, kind) {
|
|
863
|
+
const data = owner.client.apiRequest("getSignaturesOfType", {
|
|
864
|
+
snapshot: owner.snapshotId,
|
|
865
|
+
project: owner.project.id,
|
|
866
|
+
type: source.id,
|
|
867
|
+
kind,
|
|
868
|
+
});
|
|
869
|
+
return data.map(signature => owner.getOrCreateSignature(signature));
|
|
870
|
+
}, function* (source, kind) {
|
|
871
|
+
const data = yield* apiRequest("getSignaturesOfType", {
|
|
872
|
+
snapshot: owner.snapshotId,
|
|
873
|
+
project: owner.project.id,
|
|
874
|
+
type: source.id,
|
|
875
|
+
kind,
|
|
876
|
+
});
|
|
877
|
+
return data.map(signature => owner.getOrCreateSignature(signature));
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
get fetchIndexInfosOfType() {
|
|
881
|
+
const owner = this;
|
|
882
|
+
return cacheGeneratorMethod(owner, "fetchIndexInfosOfType", function (source) {
|
|
883
|
+
const data = owner.client.apiRequest("getIndexInfosOfType", {
|
|
884
|
+
snapshot: owner.snapshotId,
|
|
885
|
+
project: owner.project.id,
|
|
886
|
+
type: source.id,
|
|
887
|
+
});
|
|
888
|
+
if (!data)
|
|
889
|
+
return [];
|
|
890
|
+
return data.map(info => ({
|
|
891
|
+
keyType: owner.getOrCreateType(info.keyType),
|
|
892
|
+
valueType: owner.getOrCreateType(info.valueType),
|
|
893
|
+
isReadonly: info.isReadonly ?? false,
|
|
894
|
+
declaration: info.declaration ? new NodeHandle(info.declaration, owner.project) : undefined,
|
|
895
|
+
}));
|
|
896
|
+
}, function* (source) {
|
|
897
|
+
const data = yield* apiRequest("getIndexInfosOfType", {
|
|
898
|
+
snapshot: owner.snapshotId,
|
|
899
|
+
project: owner.project.id,
|
|
900
|
+
type: source.id,
|
|
901
|
+
});
|
|
902
|
+
if (!data)
|
|
903
|
+
return [];
|
|
904
|
+
return data.map(info => ({
|
|
905
|
+
keyType: owner.getOrCreateType(info.keyType),
|
|
906
|
+
valueType: owner.getOrCreateType(info.valueType),
|
|
907
|
+
isReadonly: info.isReadonly ?? false,
|
|
908
|
+
declaration: info.declaration ? new NodeHandle(info.declaration, owner.project) : undefined,
|
|
909
|
+
}));
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
get fetchTypeParameterAtPosition() {
|
|
913
|
+
const owner = this;
|
|
914
|
+
return cacheGeneratorMethod(owner, "fetchTypeParameterAtPosition", function (source, pos) {
|
|
915
|
+
const data = owner.client.apiRequest("getTypeParameterAtPosition", {
|
|
916
|
+
snapshot: owner.snapshotId,
|
|
917
|
+
project: owner.project.id,
|
|
918
|
+
signature: source.id,
|
|
919
|
+
index: pos,
|
|
920
|
+
});
|
|
921
|
+
return owner.getOrCreateType(data);
|
|
922
|
+
}, function* (source, pos) {
|
|
923
|
+
const data = yield* apiRequest("getTypeParameterAtPosition", {
|
|
924
|
+
snapshot: owner.snapshotId,
|
|
925
|
+
project: owner.project.id,
|
|
926
|
+
signature: source.id,
|
|
927
|
+
index: pos,
|
|
928
|
+
});
|
|
929
|
+
return owner.getOrCreateType(data);
|
|
930
|
+
});
|
|
541
931
|
}
|
|
542
932
|
}
|
|
543
933
|
export class Project {
|
|
@@ -574,12 +964,22 @@ export class Project {
|
|
|
574
964
|
this.languageService = new LanguageService(snapshotId, this, client, objectRegistry);
|
|
575
965
|
}
|
|
576
966
|
/** @deprecated Use `languageService.getImportAdderEdits`. */
|
|
577
|
-
getImportAdderEdits(
|
|
578
|
-
|
|
967
|
+
get getImportAdderEdits() {
|
|
968
|
+
const owner = this;
|
|
969
|
+
return cacheGeneratorMethod(owner, "getImportAdderEdits", function (file, actions) {
|
|
970
|
+
return owner.languageService.getImportAdderEdits(file, actions);
|
|
971
|
+
}, function* (file, actions) {
|
|
972
|
+
return yield* owner.languageService.getImportAdderEdits.gen(file, actions);
|
|
973
|
+
});
|
|
579
974
|
}
|
|
580
975
|
/** @deprecated Use `languageService.getImportEditsForSymbols`. */
|
|
581
|
-
getImportEditsForSymbols(
|
|
582
|
-
|
|
976
|
+
get getImportEditsForSymbols() {
|
|
977
|
+
const owner = this;
|
|
978
|
+
return cacheGeneratorMethod(owner, "getImportEditsForSymbols", function (file, symbols, options = {}) {
|
|
979
|
+
return owner.languageService.getImportEditsForSymbols(file, symbols, options);
|
|
980
|
+
}, function* (file, symbols, options = {}) {
|
|
981
|
+
return yield* owner.languageService.getImportEditsForSymbols.gen(file, symbols, options);
|
|
982
|
+
});
|
|
583
983
|
}
|
|
584
984
|
dispose() {
|
|
585
985
|
this.checker.dispose();
|
|
@@ -596,87 +996,179 @@ export class LanguageService {
|
|
|
596
996
|
this.client = client;
|
|
597
997
|
this.objectRegistry = objectRegistry;
|
|
598
998
|
}
|
|
599
|
-
getImportAdderEdits(
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
999
|
+
get getImportAdderEdits() {
|
|
1000
|
+
const owner = this;
|
|
1001
|
+
return cacheGeneratorMethod(owner, "getImportAdderEdits", function (file, actions) {
|
|
1002
|
+
const requestActions = actions.map(action => {
|
|
1003
|
+
switch (action.kind) {
|
|
1004
|
+
case "importSymbol":
|
|
1005
|
+
const importSymbolAction = {
|
|
1006
|
+
kind: "importSymbol",
|
|
1007
|
+
symbol: action.symbol.id,
|
|
1008
|
+
};
|
|
1009
|
+
if (action.isValidTypeOnlyUseSite !== undefined) {
|
|
1010
|
+
importSymbolAction.isValidTypeOnlyUseSite = action.isValidTypeOnlyUseSite;
|
|
1011
|
+
}
|
|
1012
|
+
return importSymbolAction;
|
|
1013
|
+
default:
|
|
1014
|
+
return assertNever(action.kind);
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
const data = owner.client.apiRequest("getImportAdderEdits", {
|
|
1018
|
+
snapshot: owner.snapshotId,
|
|
1019
|
+
project: owner.project.id,
|
|
1020
|
+
file,
|
|
1021
|
+
actions: requestActions,
|
|
1022
|
+
});
|
|
1023
|
+
return data ?? [];
|
|
1024
|
+
}, function* (file, actions) {
|
|
1025
|
+
const requestActions = actions.map(action => {
|
|
1026
|
+
switch (action.kind) {
|
|
1027
|
+
case "importSymbol":
|
|
1028
|
+
const importSymbolAction = {
|
|
1029
|
+
kind: "importSymbol",
|
|
1030
|
+
symbol: action.symbol.id,
|
|
1031
|
+
};
|
|
1032
|
+
if (action.isValidTypeOnlyUseSite !== undefined) {
|
|
1033
|
+
importSymbolAction.isValidTypeOnlyUseSite = action.isValidTypeOnlyUseSite;
|
|
1034
|
+
}
|
|
1035
|
+
return importSymbolAction;
|
|
1036
|
+
default:
|
|
1037
|
+
return assertNever(action.kind);
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
const data = yield* apiRequest("getImportAdderEdits", {
|
|
1041
|
+
snapshot: owner.snapshotId,
|
|
1042
|
+
project: owner.project.id,
|
|
1043
|
+
file,
|
|
1044
|
+
actions: requestActions,
|
|
1045
|
+
});
|
|
1046
|
+
return data ?? [];
|
|
620
1047
|
});
|
|
621
|
-
return data ?? [];
|
|
622
1048
|
}
|
|
623
|
-
getImportEditsForSymbols(
|
|
624
|
-
|
|
625
|
-
|
|
1049
|
+
get getImportEditsForSymbols() {
|
|
1050
|
+
const owner = this;
|
|
1051
|
+
return cacheGeneratorMethod(owner, "getImportEditsForSymbols", function (file, symbols, options = {}) {
|
|
1052
|
+
return owner.getImportAdderEdits(file, symbols.map((symbol) => {
|
|
1053
|
+
if (options.isValidTypeOnlyUseSite !== undefined) {
|
|
1054
|
+
return {
|
|
1055
|
+
kind: "importSymbol",
|
|
1056
|
+
symbol,
|
|
1057
|
+
isValidTypeOnlyUseSite: options.isValidTypeOnlyUseSite,
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
626
1060
|
return {
|
|
627
1061
|
kind: "importSymbol",
|
|
628
1062
|
symbol,
|
|
629
|
-
isValidTypeOnlyUseSite: options.isValidTypeOnlyUseSite,
|
|
630
1063
|
};
|
|
631
|
-
}
|
|
1064
|
+
}));
|
|
1065
|
+
}, function* (file, symbols, options = {}) {
|
|
1066
|
+
return yield* owner.getImportAdderEdits.gen(file, symbols.map((symbol) => {
|
|
1067
|
+
if (options.isValidTypeOnlyUseSite !== undefined) {
|
|
1068
|
+
return {
|
|
1069
|
+
kind: "importSymbol",
|
|
1070
|
+
symbol,
|
|
1071
|
+
isValidTypeOnlyUseSite: options.isValidTypeOnlyUseSite,
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
return {
|
|
1075
|
+
kind: "importSymbol",
|
|
1076
|
+
symbol,
|
|
1077
|
+
};
|
|
1078
|
+
}));
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
get getReferencedSymbolsForNode() {
|
|
1082
|
+
const owner = this;
|
|
1083
|
+
return cacheGeneratorMethod(owner, "getReferencedSymbolsForNode", function (node, position) {
|
|
1084
|
+
const data = owner.client.apiRequest("getReferencedSymbolsForNode", {
|
|
1085
|
+
snapshot: owner.snapshotId,
|
|
1086
|
+
project: owner.project.id,
|
|
1087
|
+
node: getNodeId(node),
|
|
1088
|
+
position,
|
|
1089
|
+
});
|
|
1090
|
+
return (data ?? []).map(entry => ({
|
|
1091
|
+
definition: new NodeHandle(entry.definition, owner.project),
|
|
1092
|
+
symbol: entry.symbol ? owner.objectRegistry.getOrCreateSymbol(entry.symbol) : undefined,
|
|
1093
|
+
references: (entry.references ?? []).map(h => new NodeHandle(h, owner.project)),
|
|
1094
|
+
}));
|
|
1095
|
+
}, function* (node, position) {
|
|
1096
|
+
const data = yield* apiRequest("getReferencedSymbolsForNode", {
|
|
1097
|
+
snapshot: owner.snapshotId,
|
|
1098
|
+
project: owner.project.id,
|
|
1099
|
+
node: getNodeId(node),
|
|
1100
|
+
position,
|
|
1101
|
+
});
|
|
1102
|
+
return (data ?? []).map(entry => ({
|
|
1103
|
+
definition: new NodeHandle(entry.definition, owner.project),
|
|
1104
|
+
symbol: entry.symbol ? owner.objectRegistry.getOrCreateSymbol(entry.symbol) : undefined,
|
|
1105
|
+
references: (entry.references ?? []).map(h => new NodeHandle(h, owner.project)),
|
|
1106
|
+
}));
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
get getSignatureUsage() {
|
|
1110
|
+
const owner = this;
|
|
1111
|
+
return cacheGeneratorMethod(owner, "getSignatureUsage", function (signatureDecl) {
|
|
1112
|
+
const data = owner.client.apiRequest("getSignatureUsages", {
|
|
1113
|
+
snapshot: owner.snapshotId,
|
|
1114
|
+
project: owner.project.id,
|
|
1115
|
+
signatureDecl: getNodeId(signatureDecl),
|
|
1116
|
+
});
|
|
1117
|
+
return (data ?? []).map(entry => ({
|
|
1118
|
+
name: new NodeHandle(entry.name, owner.project),
|
|
1119
|
+
call: entry.call ? new NodeHandle(entry.call, owner.project) : undefined,
|
|
1120
|
+
}));
|
|
1121
|
+
}, function* (signatureDecl) {
|
|
1122
|
+
const data = yield* apiRequest("getSignatureUsages", {
|
|
1123
|
+
snapshot: owner.snapshotId,
|
|
1124
|
+
project: owner.project.id,
|
|
1125
|
+
signatureDecl: getNodeId(signatureDecl),
|
|
1126
|
+
});
|
|
1127
|
+
return (data ?? []).map(entry => ({
|
|
1128
|
+
name: new NodeHandle(entry.name, owner.project),
|
|
1129
|
+
call: entry.call ? new NodeHandle(entry.call, owner.project) : undefined,
|
|
1130
|
+
}));
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
get getCompletionsAtPosition() {
|
|
1134
|
+
const owner = this;
|
|
1135
|
+
return cacheGeneratorMethod(owner, "getCompletionsAtPosition", function (document, position, options) {
|
|
1136
|
+
const data = owner.client.apiRequest("getCompletionsAtPosition", {
|
|
1137
|
+
snapshot: owner.snapshotId,
|
|
1138
|
+
project: owner.project.id,
|
|
1139
|
+
file: document,
|
|
1140
|
+
position,
|
|
1141
|
+
...(options?.triggerCharacter !== undefined ? { triggerCharacter: options.triggerCharacter } : {}),
|
|
1142
|
+
...(options?.includeSymbol !== undefined ? { includeSymbol: options.includeSymbol } : {}),
|
|
1143
|
+
});
|
|
1144
|
+
if (!data)
|
|
1145
|
+
return undefined;
|
|
632
1146
|
return {
|
|
633
|
-
|
|
634
|
-
|
|
1147
|
+
isIncomplete: data.isIncomplete,
|
|
1148
|
+
entries: data.entries.map(e => ({
|
|
1149
|
+
...e,
|
|
1150
|
+
symbol: e.symbol ? owner.objectRegistry.getOrCreateSymbol(e.symbol) : undefined,
|
|
1151
|
+
})),
|
|
635
1152
|
};
|
|
636
|
-
})
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
signatureDecl: getNodeId(signatureDecl),
|
|
656
|
-
});
|
|
657
|
-
return (data ?? []).map(entry => ({
|
|
658
|
-
name: new NodeHandle(entry.name, this.project),
|
|
659
|
-
call: entry.call ? new NodeHandle(entry.call, this.project) : undefined,
|
|
660
|
-
}));
|
|
661
|
-
}
|
|
662
|
-
getCompletionsAtPosition(document, position, options) {
|
|
663
|
-
const data = this.client.apiRequest("getCompletionsAtPosition", {
|
|
664
|
-
snapshot: this.snapshotId,
|
|
665
|
-
project: this.project.id,
|
|
666
|
-
file: document,
|
|
667
|
-
position,
|
|
668
|
-
...(options?.triggerCharacter !== undefined ? { triggerCharacter: options.triggerCharacter } : {}),
|
|
669
|
-
...(options?.includeSymbol !== undefined ? { includeSymbol: options.includeSymbol } : {}),
|
|
670
|
-
});
|
|
671
|
-
if (!data)
|
|
672
|
-
return undefined;
|
|
673
|
-
return {
|
|
674
|
-
isIncomplete: data.isIncomplete,
|
|
675
|
-
entries: data.entries.map(e => ({
|
|
676
|
-
...e,
|
|
677
|
-
symbol: e.symbol ? this.objectRegistry.getOrCreateSymbol(e.symbol) : undefined,
|
|
678
|
-
})),
|
|
679
|
-
};
|
|
1153
|
+
}, function* (document, position, options) {
|
|
1154
|
+
const data = yield* apiRequest("getCompletionsAtPosition", {
|
|
1155
|
+
snapshot: owner.snapshotId,
|
|
1156
|
+
project: owner.project.id,
|
|
1157
|
+
file: document,
|
|
1158
|
+
position,
|
|
1159
|
+
...(options?.triggerCharacter !== undefined ? { triggerCharacter: options.triggerCharacter } : {}),
|
|
1160
|
+
...(options?.includeSymbol !== undefined ? { includeSymbol: options.includeSymbol } : {}),
|
|
1161
|
+
});
|
|
1162
|
+
if (!data)
|
|
1163
|
+
return undefined;
|
|
1164
|
+
return {
|
|
1165
|
+
isIncomplete: data.isIncomplete,
|
|
1166
|
+
entries: data.entries.map(e => ({
|
|
1167
|
+
...e,
|
|
1168
|
+
symbol: e.symbol ? owner.objectRegistry.getOrCreateSymbol(e.symbol) : undefined,
|
|
1169
|
+
})),
|
|
1170
|
+
};
|
|
1171
|
+
});
|
|
680
1172
|
}
|
|
681
1173
|
}
|
|
682
1174
|
export class Program {
|
|
@@ -708,44 +1200,84 @@ export class Program {
|
|
|
708
1200
|
getCompilerOptions() {
|
|
709
1201
|
return this.project.compilerOptions;
|
|
710
1202
|
}
|
|
711
|
-
getSourceFile(
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
1203
|
+
get getSourceFile() {
|
|
1204
|
+
const owner = this;
|
|
1205
|
+
return cacheGeneratorMethod(owner, "getSourceFile", function (file) {
|
|
1206
|
+
const fileName = resolveFileName(file);
|
|
1207
|
+
const path = owner.toPath(fileName);
|
|
1208
|
+
// Check if we already have a retained cache entry for this (snapshot, project) pair
|
|
1209
|
+
const retained = owner.sourceFileCache.getRetained(path, owner.snapshotId, owner.project.id);
|
|
1210
|
+
if (retained) {
|
|
1211
|
+
return retained;
|
|
1212
|
+
}
|
|
1213
|
+
// Fetch from server
|
|
1214
|
+
const binaryData = owner.client.apiRequestBinary("getSourceFile", {
|
|
1215
|
+
snapshot: owner.snapshotId,
|
|
1216
|
+
project: owner.project.id,
|
|
1217
|
+
file,
|
|
1218
|
+
});
|
|
1219
|
+
if (!binaryData) {
|
|
1220
|
+
return undefined;
|
|
1221
|
+
}
|
|
1222
|
+
const view = new DataView(binaryData.buffer, binaryData.byteOffset, binaryData.byteLength);
|
|
1223
|
+
const contentHash = readSourceFileHash(view);
|
|
1224
|
+
const parseOptionsKey = readParseOptionsKey(view);
|
|
1225
|
+
// Create a new RemoteSourceFile and cache it (set returns existing if hash matches)
|
|
1226
|
+
const sourceFile = new RemoteSourceFile(binaryData, owner.decoder, owner.client.getTimingCollector());
|
|
1227
|
+
return owner.sourceFileCache.set(path, sourceFile, parseOptionsKey, contentHash, owner.snapshotId, owner.project.id);
|
|
1228
|
+
}, function* (file) {
|
|
1229
|
+
const fileName = resolveFileName(file);
|
|
1230
|
+
const path = owner.toPath(fileName);
|
|
1231
|
+
// Check if we already have a retained cache entry for this (snapshot, project) pair
|
|
1232
|
+
const retained = owner.sourceFileCache.getRetained(path, owner.snapshotId, owner.project.id);
|
|
1233
|
+
if (retained) {
|
|
1234
|
+
return retained;
|
|
1235
|
+
}
|
|
1236
|
+
// Fetch from server
|
|
1237
|
+
const binaryData = owner.client.apiRequestBinary("getSourceFile", {
|
|
1238
|
+
snapshot: owner.snapshotId,
|
|
1239
|
+
project: owner.project.id,
|
|
1240
|
+
file,
|
|
1241
|
+
});
|
|
1242
|
+
if (!binaryData) {
|
|
1243
|
+
return undefined;
|
|
1244
|
+
}
|
|
1245
|
+
const view = new DataView(binaryData.buffer, binaryData.byteOffset, binaryData.byteLength);
|
|
1246
|
+
const contentHash = readSourceFileHash(view);
|
|
1247
|
+
const parseOptionsKey = readParseOptionsKey(view);
|
|
1248
|
+
// Create a new RemoteSourceFile and cache it (set returns existing if hash matches)
|
|
1249
|
+
const sourceFile = new RemoteSourceFile(binaryData, owner.decoder, owner.client.getTimingCollector());
|
|
1250
|
+
return owner.sourceFileCache.set(path, sourceFile, parseOptionsKey, contentHash, owner.snapshotId, owner.project.id);
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
get getSourceFileNames() {
|
|
1254
|
+
const owner = this;
|
|
1255
|
+
return cacheGeneratorMethod(owner, "getSourceFileNames", function () {
|
|
1256
|
+
const data = owner.client.apiRequest("getSourceFileNames", {
|
|
1257
|
+
snapshot: owner.snapshotId,
|
|
1258
|
+
project: owner.project.id,
|
|
1259
|
+
});
|
|
1260
|
+
return data ?? [];
|
|
1261
|
+
}, function* () {
|
|
1262
|
+
const data = yield* apiRequest("getSourceFileNames", {
|
|
1263
|
+
snapshot: owner.snapshotId,
|
|
1264
|
+
project: owner.project.id,
|
|
1265
|
+
});
|
|
1266
|
+
return data ?? [];
|
|
739
1267
|
});
|
|
740
|
-
return data ?? [];
|
|
741
1268
|
}
|
|
742
1269
|
/**
|
|
743
1270
|
* Returns program-stored metadata for the given source file, or `undefined` if the file
|
|
744
1271
|
* is not part of the program. Metadata is fetched lazily per file and cached on this
|
|
745
1272
|
* `Program` instance.
|
|
746
1273
|
*/
|
|
747
|
-
getSourceFileMetadata(
|
|
748
|
-
|
|
1274
|
+
get getSourceFileMetadata() {
|
|
1275
|
+
const owner = this;
|
|
1276
|
+
return cacheGeneratorMethod(owner, "getSourceFileMetadata", function (fileName) {
|
|
1277
|
+
return owner.getSourceFileMetadataByPath(owner.toPath(fileName));
|
|
1278
|
+
}, function* (fileName) {
|
|
1279
|
+
return yield* owner.getSourceFileMetadataByPath.gen(owner.toPath(fileName));
|
|
1280
|
+
});
|
|
749
1281
|
}
|
|
750
1282
|
/**
|
|
751
1283
|
* Returns program-stored metadata for the source file at the given path, or `undefined`
|
|
@@ -753,170 +1285,316 @@ export class Program {
|
|
|
753
1285
|
* the file name to path conversion. Metadata is fetched lazily per file and cached on
|
|
754
1286
|
* this `Program` instance.
|
|
755
1287
|
*/
|
|
756
|
-
getSourceFileMetadataByPath(
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
metadata =
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
1288
|
+
get getSourceFileMetadataByPath() {
|
|
1289
|
+
const owner = this;
|
|
1290
|
+
return cacheGeneratorMethod(owner, "getSourceFileMetadataByPath", function (path) {
|
|
1291
|
+
let metadata = owner.sourceFileMetadataCache.get(path);
|
|
1292
|
+
if (metadata === undefined) {
|
|
1293
|
+
metadata = owner.fetchSourceFileMetadata(path);
|
|
1294
|
+
owner.sourceFileMetadataCache.set(path, metadata);
|
|
1295
|
+
}
|
|
1296
|
+
return metadata;
|
|
1297
|
+
}, function* (path) {
|
|
1298
|
+
let metadata = owner.sourceFileMetadataCache.get(path);
|
|
1299
|
+
if (metadata === undefined) {
|
|
1300
|
+
metadata = yield* owner.fetchSourceFileMetadata.gen(path);
|
|
1301
|
+
owner.sourceFileMetadataCache.set(path, metadata);
|
|
1302
|
+
}
|
|
1303
|
+
return metadata;
|
|
1304
|
+
});
|
|
763
1305
|
}
|
|
764
|
-
fetchSourceFileMetadata(
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
1306
|
+
get fetchSourceFileMetadata() {
|
|
1307
|
+
const owner = this;
|
|
1308
|
+
return cacheGeneratorMethod(owner, "fetchSourceFileMetadata", function (path) {
|
|
1309
|
+
const data = owner.client.apiRequest("getSourceFileMetadata", {
|
|
1310
|
+
snapshot: owner.snapshotId,
|
|
1311
|
+
project: owner.project.id,
|
|
1312
|
+
file: path,
|
|
1313
|
+
});
|
|
1314
|
+
return data ?? undefined;
|
|
1315
|
+
}, function* (path) {
|
|
1316
|
+
const data = yield* apiRequest("getSourceFileMetadata", {
|
|
1317
|
+
snapshot: owner.snapshotId,
|
|
1318
|
+
project: owner.project.id,
|
|
1319
|
+
file: path,
|
|
1320
|
+
});
|
|
1321
|
+
return data ?? undefined;
|
|
769
1322
|
});
|
|
770
|
-
return data ?? undefined;
|
|
771
1323
|
}
|
|
772
1324
|
/**
|
|
773
1325
|
* Returns whether the given source file was loaded as part of an external library
|
|
774
1326
|
* (e.g. a dependency resolved from `node_modules`). The underlying program metadata is
|
|
775
1327
|
* fetched lazily per file and cached on this `Program` instance.
|
|
776
1328
|
*/
|
|
777
|
-
isSourceFileFromExternalLibrary(
|
|
778
|
-
const
|
|
779
|
-
return
|
|
1329
|
+
get isSourceFileFromExternalLibrary() {
|
|
1330
|
+
const owner = this;
|
|
1331
|
+
return cacheGeneratorMethod(owner, "isSourceFileFromExternalLibrary", function (file) {
|
|
1332
|
+
const metadata = owner.getSourceFileMetadataByPath(file.path);
|
|
1333
|
+
return metadata?.isFromExternalLibrary ?? false;
|
|
1334
|
+
}, function* (file) {
|
|
1335
|
+
const metadata = yield* owner.getSourceFileMetadataByPath.gen(file.path);
|
|
1336
|
+
return metadata?.isFromExternalLibrary ?? false;
|
|
1337
|
+
});
|
|
780
1338
|
}
|
|
781
1339
|
/**
|
|
782
1340
|
* Returns whether the given source file is a default library file (e.g. `lib.d.ts`).
|
|
783
1341
|
* The underlying program metadata is fetched lazily per file and cached on this
|
|
784
1342
|
* `Program` instance.
|
|
785
1343
|
*/
|
|
786
|
-
isSourceFileDefaultLibrary(
|
|
787
|
-
const
|
|
788
|
-
return
|
|
1344
|
+
get isSourceFileDefaultLibrary() {
|
|
1345
|
+
const owner = this;
|
|
1346
|
+
return cacheGeneratorMethod(owner, "isSourceFileDefaultLibrary", function (file) {
|
|
1347
|
+
const metadata = owner.getSourceFileMetadataByPath(file.path);
|
|
1348
|
+
return metadata?.isDefaultLibrary ?? false;
|
|
1349
|
+
}, function* (file) {
|
|
1350
|
+
const metadata = yield* owner.getSourceFileMetadataByPath.gen(file.path);
|
|
1351
|
+
return metadata?.isDefaultLibrary ?? false;
|
|
1352
|
+
});
|
|
789
1353
|
}
|
|
790
1354
|
/**
|
|
791
1355
|
* Get all config source file names associated with this program's project config.
|
|
792
1356
|
* Includes the root config file and any extended config files.
|
|
793
1357
|
*/
|
|
794
|
-
getConfigFileNames() {
|
|
795
|
-
const
|
|
796
|
-
|
|
797
|
-
|
|
1358
|
+
get getConfigFileNames() {
|
|
1359
|
+
const owner = this;
|
|
1360
|
+
return cacheGeneratorMethod(owner, "getConfigFileNames", function () {
|
|
1361
|
+
const data = owner.client.apiRequest("getConfigFileNames", {
|
|
1362
|
+
snapshot: owner.snapshotId,
|
|
1363
|
+
project: owner.project.id,
|
|
1364
|
+
});
|
|
1365
|
+
return data ?? [];
|
|
1366
|
+
}, function* () {
|
|
1367
|
+
const data = yield* apiRequest("getConfigFileNames", {
|
|
1368
|
+
snapshot: owner.snapshotId,
|
|
1369
|
+
project: owner.project.id,
|
|
1370
|
+
});
|
|
1371
|
+
return data ?? [];
|
|
798
1372
|
});
|
|
799
|
-
return data ?? [];
|
|
800
1373
|
}
|
|
801
1374
|
/**
|
|
802
1375
|
* Get a config source file by file name/URI.
|
|
803
1376
|
* This can return the project's root tsconfig file or one of its extended config files.
|
|
804
1377
|
*/
|
|
805
|
-
getConfigSourceFile(
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
1378
|
+
get getConfigSourceFile() {
|
|
1379
|
+
const owner = this;
|
|
1380
|
+
return cacheGeneratorMethod(owner, "getConfigSourceFile", function (file) {
|
|
1381
|
+
const binaryData = owner.client.apiRequestBinary("getConfigSourceFile", {
|
|
1382
|
+
snapshot: owner.snapshotId,
|
|
1383
|
+
project: owner.project.id,
|
|
1384
|
+
file,
|
|
1385
|
+
});
|
|
1386
|
+
if (!binaryData) {
|
|
1387
|
+
return undefined;
|
|
1388
|
+
}
|
|
1389
|
+
return new RemoteSourceFile(binaryData, owner.decoder);
|
|
1390
|
+
}, function* (file) {
|
|
1391
|
+
const binaryData = owner.client.apiRequestBinary("getConfigSourceFile", {
|
|
1392
|
+
snapshot: owner.snapshotId,
|
|
1393
|
+
project: owner.project.id,
|
|
1394
|
+
file,
|
|
1395
|
+
});
|
|
1396
|
+
if (!binaryData) {
|
|
1397
|
+
return undefined;
|
|
1398
|
+
}
|
|
1399
|
+
return new RemoteSourceFile(binaryData, owner.decoder);
|
|
1400
|
+
});
|
|
815
1401
|
}
|
|
816
1402
|
/**
|
|
817
1403
|
* Get syntactic (parse) diagnostics for specific files or all files.
|
|
818
1404
|
* @param file - Optional file(s) to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
819
1405
|
*/
|
|
820
|
-
getSyntacticDiagnostics(
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
1406
|
+
get getSyntacticDiagnostics() {
|
|
1407
|
+
const owner = this;
|
|
1408
|
+
return cacheGeneratorMethod(owner, "getSyntacticDiagnostics", function (file) {
|
|
1409
|
+
const files = file === undefined ? undefined
|
|
1410
|
+
: Array.isArray(file) ? file
|
|
1411
|
+
: [file];
|
|
1412
|
+
const data = owner.client.apiRequest("getSyntacticDiagnostics", {
|
|
1413
|
+
snapshot: owner.snapshotId,
|
|
1414
|
+
project: owner.project.id,
|
|
1415
|
+
...(files !== undefined ? { files } : {}),
|
|
1416
|
+
});
|
|
1417
|
+
return data ?? [];
|
|
1418
|
+
}, function* (file) {
|
|
1419
|
+
const files = file === undefined ? undefined
|
|
1420
|
+
: Array.isArray(file) ? file
|
|
1421
|
+
: [file];
|
|
1422
|
+
const data = yield* apiRequest("getSyntacticDiagnostics", {
|
|
1423
|
+
snapshot: owner.snapshotId,
|
|
1424
|
+
project: owner.project.id,
|
|
1425
|
+
...(files !== undefined ? { files } : {}),
|
|
1426
|
+
});
|
|
1427
|
+
return data ?? [];
|
|
828
1428
|
});
|
|
829
|
-
return data ?? [];
|
|
830
1429
|
}
|
|
831
1430
|
/**
|
|
832
1431
|
* Get binder diagnostics for specific files or all files.
|
|
833
1432
|
* @param file - Optional file(s) to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
834
1433
|
*/
|
|
835
|
-
getBindDiagnostics(
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
1434
|
+
get getBindDiagnostics() {
|
|
1435
|
+
const owner = this;
|
|
1436
|
+
return cacheGeneratorMethod(owner, "getBindDiagnostics", function (file) {
|
|
1437
|
+
const files = file === undefined ? undefined
|
|
1438
|
+
: Array.isArray(file) ? file
|
|
1439
|
+
: [file];
|
|
1440
|
+
const data = owner.client.apiRequest("getBindDiagnostics", {
|
|
1441
|
+
snapshot: owner.snapshotId,
|
|
1442
|
+
project: owner.project.id,
|
|
1443
|
+
...(files !== undefined ? { files } : {}),
|
|
1444
|
+
});
|
|
1445
|
+
return data ?? [];
|
|
1446
|
+
}, function* (file) {
|
|
1447
|
+
const files = file === undefined ? undefined
|
|
1448
|
+
: Array.isArray(file) ? file
|
|
1449
|
+
: [file];
|
|
1450
|
+
const data = yield* apiRequest("getBindDiagnostics", {
|
|
1451
|
+
snapshot: owner.snapshotId,
|
|
1452
|
+
project: owner.project.id,
|
|
1453
|
+
...(files !== undefined ? { files } : {}),
|
|
1454
|
+
});
|
|
1455
|
+
return data ?? [];
|
|
843
1456
|
});
|
|
844
|
-
return data ?? [];
|
|
845
1457
|
}
|
|
846
1458
|
/**
|
|
847
1459
|
* Get semantic (type-check) diagnostics for specific files or all files.
|
|
848
1460
|
* @param file - Optional file(s) to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
849
1461
|
*/
|
|
850
|
-
getSemanticDiagnostics(
|
|
851
|
-
const
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1462
|
+
get getSemanticDiagnostics() {
|
|
1463
|
+
const owner = this;
|
|
1464
|
+
return cacheGeneratorMethod(owner, "getSemanticDiagnostics", function (file) {
|
|
1465
|
+
const files = file === undefined ? undefined
|
|
1466
|
+
: Array.isArray(file) ? file
|
|
1467
|
+
: [file];
|
|
1468
|
+
const data = owner.client.apiRequest("getSemanticDiagnostics", {
|
|
1469
|
+
snapshot: owner.snapshotId,
|
|
1470
|
+
project: owner.project.id,
|
|
1471
|
+
...(files !== undefined ? { files } : {}),
|
|
1472
|
+
});
|
|
1473
|
+
return data ?? [];
|
|
1474
|
+
}, function* (file) {
|
|
1475
|
+
const files = file === undefined ? undefined
|
|
1476
|
+
: Array.isArray(file) ? file
|
|
1477
|
+
: [file];
|
|
1478
|
+
const data = yield* apiRequest("getSemanticDiagnostics", {
|
|
1479
|
+
snapshot: owner.snapshotId,
|
|
1480
|
+
project: owner.project.id,
|
|
1481
|
+
...(files !== undefined ? { files } : {}),
|
|
1482
|
+
});
|
|
1483
|
+
return data ?? [];
|
|
858
1484
|
});
|
|
859
|
-
return data ?? [];
|
|
860
1485
|
}
|
|
861
1486
|
/**
|
|
862
1487
|
* Get suggestion diagnostics for specific files or all files.
|
|
863
1488
|
* @param file - Optional file(s) to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
864
1489
|
*/
|
|
865
|
-
getSuggestionDiagnostics(
|
|
866
|
-
const
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
1490
|
+
get getSuggestionDiagnostics() {
|
|
1491
|
+
const owner = this;
|
|
1492
|
+
return cacheGeneratorMethod(owner, "getSuggestionDiagnostics", function (file) {
|
|
1493
|
+
const files = file === undefined ? undefined
|
|
1494
|
+
: Array.isArray(file) ? file
|
|
1495
|
+
: [file];
|
|
1496
|
+
const data = owner.client.apiRequest("getSuggestionDiagnostics", {
|
|
1497
|
+
snapshot: owner.snapshotId,
|
|
1498
|
+
project: owner.project.id,
|
|
1499
|
+
...(files !== undefined ? { files } : {}),
|
|
1500
|
+
});
|
|
1501
|
+
return data ?? [];
|
|
1502
|
+
}, function* (file) {
|
|
1503
|
+
const files = file === undefined ? undefined
|
|
1504
|
+
: Array.isArray(file) ? file
|
|
1505
|
+
: [file];
|
|
1506
|
+
const data = yield* apiRequest("getSuggestionDiagnostics", {
|
|
1507
|
+
snapshot: owner.snapshotId,
|
|
1508
|
+
project: owner.project.id,
|
|
1509
|
+
...(files !== undefined ? { files } : {}),
|
|
1510
|
+
});
|
|
1511
|
+
return data ?? [];
|
|
873
1512
|
});
|
|
874
|
-
return data ?? [];
|
|
875
1513
|
}
|
|
876
1514
|
/**
|
|
877
1515
|
* Get declaration emit diagnostics for specific files or all files.
|
|
878
1516
|
* @param file - Optional file(s) to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
879
1517
|
*/
|
|
880
|
-
getDeclarationDiagnostics(
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
1518
|
+
get getDeclarationDiagnostics() {
|
|
1519
|
+
const owner = this;
|
|
1520
|
+
return cacheGeneratorMethod(owner, "getDeclarationDiagnostics", function (file) {
|
|
1521
|
+
const files = file === undefined ? undefined
|
|
1522
|
+
: Array.isArray(file) ? file
|
|
1523
|
+
: [file];
|
|
1524
|
+
const data = owner.client.apiRequest("getDeclarationDiagnostics", {
|
|
1525
|
+
snapshot: owner.snapshotId,
|
|
1526
|
+
project: owner.project.id,
|
|
1527
|
+
...(files !== undefined ? { files } : {}),
|
|
1528
|
+
});
|
|
1529
|
+
return data ?? [];
|
|
1530
|
+
}, function* (file) {
|
|
1531
|
+
const files = file === undefined ? undefined
|
|
1532
|
+
: Array.isArray(file) ? file
|
|
1533
|
+
: [file];
|
|
1534
|
+
const data = yield* apiRequest("getDeclarationDiagnostics", {
|
|
1535
|
+
snapshot: owner.snapshotId,
|
|
1536
|
+
project: owner.project.id,
|
|
1537
|
+
...(files !== undefined ? { files } : {}),
|
|
1538
|
+
});
|
|
1539
|
+
return data ?? [];
|
|
888
1540
|
});
|
|
889
|
-
return data ?? [];
|
|
890
1541
|
}
|
|
891
1542
|
/**
|
|
892
1543
|
* Get program-wide diagnostics for the project, including compiler options diagnostics.
|
|
893
1544
|
*/
|
|
894
|
-
getProgramDiagnostics() {
|
|
895
|
-
const
|
|
896
|
-
|
|
897
|
-
|
|
1545
|
+
get getProgramDiagnostics() {
|
|
1546
|
+
const owner = this;
|
|
1547
|
+
return cacheGeneratorMethod(owner, "getProgramDiagnostics", function () {
|
|
1548
|
+
const data = owner.client.apiRequest("getProgramDiagnostics", {
|
|
1549
|
+
snapshot: owner.snapshotId,
|
|
1550
|
+
project: owner.project.id,
|
|
1551
|
+
});
|
|
1552
|
+
return data ?? [];
|
|
1553
|
+
}, function* () {
|
|
1554
|
+
const data = yield* apiRequest("getProgramDiagnostics", {
|
|
1555
|
+
snapshot: owner.snapshotId,
|
|
1556
|
+
project: owner.project.id,
|
|
1557
|
+
});
|
|
1558
|
+
return data ?? [];
|
|
898
1559
|
});
|
|
899
|
-
return data ?? [];
|
|
900
1560
|
}
|
|
901
1561
|
/**
|
|
902
1562
|
* Get global (non-file-specific) semantic diagnostics for the project.
|
|
903
1563
|
*/
|
|
904
|
-
getGlobalDiagnostics() {
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
|
|
1564
|
+
get getGlobalDiagnostics() {
|
|
1565
|
+
const owner = this;
|
|
1566
|
+
return cacheGeneratorMethod(owner, "getGlobalDiagnostics", function () {
|
|
1567
|
+
const data = owner.client.apiRequest("getGlobalDiagnostics", {
|
|
1568
|
+
snapshot: owner.snapshotId,
|
|
1569
|
+
project: owner.project.id,
|
|
1570
|
+
});
|
|
1571
|
+
return data ?? [];
|
|
1572
|
+
}, function* () {
|
|
1573
|
+
const data = yield* apiRequest("getGlobalDiagnostics", {
|
|
1574
|
+
snapshot: owner.snapshotId,
|
|
1575
|
+
project: owner.project.id,
|
|
1576
|
+
});
|
|
1577
|
+
return data ?? [];
|
|
908
1578
|
});
|
|
909
|
-
return data ?? [];
|
|
910
1579
|
}
|
|
911
1580
|
/**
|
|
912
1581
|
* Get config file parsing diagnostics for the project.
|
|
913
1582
|
*/
|
|
914
|
-
getConfigFileParsingDiagnostics() {
|
|
915
|
-
const
|
|
916
|
-
|
|
917
|
-
|
|
1583
|
+
get getConfigFileParsingDiagnostics() {
|
|
1584
|
+
const owner = this;
|
|
1585
|
+
return cacheGeneratorMethod(owner, "getConfigFileParsingDiagnostics", function () {
|
|
1586
|
+
const data = owner.client.apiRequest("getConfigFileParsingDiagnostics", {
|
|
1587
|
+
snapshot: owner.snapshotId,
|
|
1588
|
+
project: owner.project.id,
|
|
1589
|
+
});
|
|
1590
|
+
return data ?? [];
|
|
1591
|
+
}, function* () {
|
|
1592
|
+
const data = yield* apiRequest("getConfigFileParsingDiagnostics", {
|
|
1593
|
+
snapshot: owner.snapshotId,
|
|
1594
|
+
project: owner.project.id,
|
|
1595
|
+
});
|
|
1596
|
+
return data ?? [];
|
|
918
1597
|
});
|
|
919
|
-
return data ?? [];
|
|
920
1598
|
}
|
|
921
1599
|
/**
|
|
922
1600
|
* Emits files to the configured filesystem.
|
|
@@ -924,50 +1602,94 @@ export class Program {
|
|
|
924
1602
|
* When the API has a virtual filesystem with a `writeFile` callback, output
|
|
925
1603
|
* is written there. Otherwise, the server writes directly to the host filesystem.
|
|
926
1604
|
*/
|
|
927
|
-
emit(
|
|
928
|
-
const
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1605
|
+
get emit() {
|
|
1606
|
+
const owner = this;
|
|
1607
|
+
return cacheGeneratorMethod(owner, "emit", function (emitOnly) {
|
|
1608
|
+
const response = owner.client.apiRequest("emit", {
|
|
1609
|
+
snapshot: owner.snapshotId,
|
|
1610
|
+
project: owner.project.id,
|
|
1611
|
+
...(emitOnly !== undefined ? { emitOnly } : {}),
|
|
1612
|
+
});
|
|
1613
|
+
return {
|
|
1614
|
+
emitSkipped: response.emitSkipped,
|
|
1615
|
+
diagnostics: response.diagnostics,
|
|
1616
|
+
emittedFiles: response.emittedFiles,
|
|
1617
|
+
};
|
|
1618
|
+
}, function* (emitOnly) {
|
|
1619
|
+
const response = yield* apiRequest("emit", {
|
|
1620
|
+
snapshot: owner.snapshotId,
|
|
1621
|
+
project: owner.project.id,
|
|
1622
|
+
...(emitOnly !== undefined ? { emitOnly } : {}),
|
|
1623
|
+
});
|
|
1624
|
+
return {
|
|
1625
|
+
emitSkipped: response.emitSkipped,
|
|
1626
|
+
diagnostics: response.diagnostics,
|
|
1627
|
+
emittedFiles: response.emittedFiles,
|
|
1628
|
+
};
|
|
1629
|
+
});
|
|
938
1630
|
}
|
|
939
1631
|
/**
|
|
940
1632
|
* Emits files and returns their contents without writing to the filesystem.
|
|
941
1633
|
*/
|
|
942
|
-
emitToString(
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1634
|
+
get emitToString() {
|
|
1635
|
+
const owner = this;
|
|
1636
|
+
return cacheGeneratorMethod(owner, "emitToString", function (emitOnly) {
|
|
1637
|
+
const response = owner.client.apiRequest("emitToString", {
|
|
1638
|
+
snapshot: owner.snapshotId,
|
|
1639
|
+
project: owner.project.id,
|
|
1640
|
+
...(emitOnly !== undefined ? { emitOnly } : {}),
|
|
1641
|
+
});
|
|
1642
|
+
return toEmitOutput(response);
|
|
1643
|
+
}, function* (emitOnly) {
|
|
1644
|
+
const response = yield* apiRequest("emitToString", {
|
|
1645
|
+
snapshot: owner.snapshotId,
|
|
1646
|
+
project: owner.project.id,
|
|
1647
|
+
...(emitOnly !== undefined ? { emitOnly } : {}),
|
|
1648
|
+
});
|
|
1649
|
+
return toEmitOutput(response);
|
|
947
1650
|
});
|
|
948
|
-
return toEmitOutput(response);
|
|
949
1651
|
}
|
|
950
1652
|
/**
|
|
951
1653
|
* Gets JavaScript output for selected files regardless of project `noEmit`, `emitDeclarationOnly`, and `noEmitOnError` settings.
|
|
952
1654
|
*/
|
|
953
|
-
getJavaScriptEmit(
|
|
954
|
-
const
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1655
|
+
get getJavaScriptEmit() {
|
|
1656
|
+
const owner = this;
|
|
1657
|
+
return cacheGeneratorMethod(owner, "getJavaScriptEmit", function (files) {
|
|
1658
|
+
const response = owner.client.apiRequest("getJavaScriptEmit", {
|
|
1659
|
+
snapshot: owner.snapshotId,
|
|
1660
|
+
project: owner.project.id,
|
|
1661
|
+
files,
|
|
1662
|
+
});
|
|
1663
|
+
return toEmitOutput(response);
|
|
1664
|
+
}, function* (files) {
|
|
1665
|
+
const response = yield* apiRequest("getJavaScriptEmit", {
|
|
1666
|
+
snapshot: owner.snapshotId,
|
|
1667
|
+
project: owner.project.id,
|
|
1668
|
+
files,
|
|
1669
|
+
});
|
|
1670
|
+
return toEmitOutput(response);
|
|
958
1671
|
});
|
|
959
|
-
return toEmitOutput(response);
|
|
960
1672
|
}
|
|
961
1673
|
/**
|
|
962
1674
|
* Gets declaration output for selected files regardless of project `noEmit`, `declaration`, `emitDeclarationOnly`, and `noEmitOnError` settings.
|
|
963
1675
|
*/
|
|
964
|
-
getDeclarationEmit(
|
|
965
|
-
const
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1676
|
+
get getDeclarationEmit() {
|
|
1677
|
+
const owner = this;
|
|
1678
|
+
return cacheGeneratorMethod(owner, "getDeclarationEmit", function (files) {
|
|
1679
|
+
const response = owner.client.apiRequest("getDeclarationEmit", {
|
|
1680
|
+
snapshot: owner.snapshotId,
|
|
1681
|
+
project: owner.project.id,
|
|
1682
|
+
files,
|
|
1683
|
+
});
|
|
1684
|
+
return toEmitOutput(response);
|
|
1685
|
+
}, function* (files) {
|
|
1686
|
+
const response = yield* apiRequest("getDeclarationEmit", {
|
|
1687
|
+
snapshot: owner.snapshotId,
|
|
1688
|
+
project: owner.project.id,
|
|
1689
|
+
files,
|
|
1690
|
+
});
|
|
1691
|
+
return toEmitOutput(response);
|
|
969
1692
|
});
|
|
970
|
-
return toEmitOutput(response);
|
|
971
1693
|
}
|
|
972
1694
|
}
|
|
973
1695
|
function toEmitOutput(response) {
|
|
@@ -997,529 +1719,1219 @@ export class Checker {
|
|
|
997
1719
|
dispose() {
|
|
998
1720
|
this.objectRegistry.clear();
|
|
999
1721
|
}
|
|
1000
|
-
getSymbolAtLocation(
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1722
|
+
get getSymbolAtLocation() {
|
|
1723
|
+
const owner = this;
|
|
1724
|
+
function getSymbolAtLocation(nodeOrNodes) {
|
|
1725
|
+
if (Array.isArray(nodeOrNodes)) {
|
|
1726
|
+
const data = owner.client.apiRequest("getSymbolsAtLocations", {
|
|
1727
|
+
snapshot: owner.snapshotId,
|
|
1728
|
+
project: owner.project.id,
|
|
1729
|
+
locations: nodeOrNodes.map(node => getNodeId(node)),
|
|
1730
|
+
});
|
|
1731
|
+
return data.map(d => d ? owner.objectRegistry.getOrCreateSymbol(d) : undefined);
|
|
1732
|
+
}
|
|
1733
|
+
const data = owner.client.apiRequest("getSymbolAtLocation", {
|
|
1734
|
+
snapshot: owner.snapshotId,
|
|
1735
|
+
project: owner.project.id,
|
|
1736
|
+
location: getNodeId(nodeOrNodes),
|
|
1006
1737
|
});
|
|
1007
|
-
return data
|
|
1738
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1008
1739
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
const data =
|
|
1019
|
-
snapshot:
|
|
1020
|
-
project:
|
|
1740
|
+
function* gen(nodeOrNodes) {
|
|
1741
|
+
if (Array.isArray(nodeOrNodes)) {
|
|
1742
|
+
const data = yield* apiRequest("getSymbolsAtLocations", {
|
|
1743
|
+
snapshot: owner.snapshotId,
|
|
1744
|
+
project: owner.project.id,
|
|
1745
|
+
locations: nodeOrNodes.map(node => getNodeId(node)),
|
|
1746
|
+
});
|
|
1747
|
+
return data.map(d => d ? owner.objectRegistry.getOrCreateSymbol(d) : undefined);
|
|
1748
|
+
}
|
|
1749
|
+
const data = yield* apiRequest("getSymbolAtLocation", {
|
|
1750
|
+
snapshot: owner.snapshotId,
|
|
1751
|
+
project: owner.project.id,
|
|
1752
|
+
location: getNodeId(nodeOrNodes),
|
|
1753
|
+
});
|
|
1754
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1755
|
+
}
|
|
1756
|
+
return cacheGeneratorMethod(owner, "getSymbolAtLocation", getSymbolAtLocation, gen);
|
|
1757
|
+
}
|
|
1758
|
+
get getSymbolAtPosition() {
|
|
1759
|
+
const owner = this;
|
|
1760
|
+
function getSymbolAtPosition(file, positionOrPositions) {
|
|
1761
|
+
if (typeof positionOrPositions === "number") {
|
|
1762
|
+
const data = owner.client.apiRequest("getSymbolAtPosition", {
|
|
1763
|
+
snapshot: owner.snapshotId,
|
|
1764
|
+
project: owner.project.id,
|
|
1765
|
+
file,
|
|
1766
|
+
position: positionOrPositions,
|
|
1767
|
+
});
|
|
1768
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1769
|
+
}
|
|
1770
|
+
const data = owner.client.apiRequest("getSymbolsAtPositions", {
|
|
1771
|
+
snapshot: owner.snapshotId,
|
|
1772
|
+
project: owner.project.id,
|
|
1021
1773
|
file,
|
|
1022
|
-
|
|
1774
|
+
positions: positionOrPositions,
|
|
1023
1775
|
});
|
|
1024
|
-
return data ?
|
|
1776
|
+
return data.map(d => d ? owner.objectRegistry.getOrCreateSymbol(d) : undefined);
|
|
1025
1777
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
const data =
|
|
1037
|
-
snapshot:
|
|
1038
|
-
project:
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1778
|
+
function* gen(file, positionOrPositions) {
|
|
1779
|
+
if (typeof positionOrPositions === "number") {
|
|
1780
|
+
const data = yield* apiRequest("getSymbolAtPosition", {
|
|
1781
|
+
snapshot: owner.snapshotId,
|
|
1782
|
+
project: owner.project.id,
|
|
1783
|
+
file,
|
|
1784
|
+
position: positionOrPositions,
|
|
1785
|
+
});
|
|
1786
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1787
|
+
}
|
|
1788
|
+
const data = yield* apiRequest("getSymbolsAtPositions", {
|
|
1789
|
+
snapshot: owner.snapshotId,
|
|
1790
|
+
project: owner.project.id,
|
|
1791
|
+
file,
|
|
1792
|
+
positions: positionOrPositions,
|
|
1793
|
+
});
|
|
1794
|
+
return data.map(d => d ? owner.objectRegistry.getOrCreateSymbol(d) : undefined);
|
|
1042
1795
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1796
|
+
return cacheGeneratorMethod(owner, "getSymbolAtPosition", getSymbolAtPosition, gen);
|
|
1797
|
+
}
|
|
1798
|
+
get getSymbolOfSourceFile() {
|
|
1799
|
+
const owner = this;
|
|
1800
|
+
function getSymbolOfSourceFile(fileOrFiles) {
|
|
1801
|
+
if (Array.isArray(fileOrFiles)) {
|
|
1802
|
+
const data = owner.client.apiRequest("getSymbolsOfSourceFiles", {
|
|
1803
|
+
snapshot: owner.snapshotId,
|
|
1804
|
+
project: owner.project.id,
|
|
1805
|
+
files: fileOrFiles,
|
|
1806
|
+
});
|
|
1807
|
+
return data.map(d => d ? owner.objectRegistry.getOrCreateSymbol(d) : undefined);
|
|
1808
|
+
}
|
|
1809
|
+
const data = owner.client.apiRequest("getSymbolOfSourceFile", {
|
|
1810
|
+
snapshot: owner.snapshotId,
|
|
1811
|
+
project: owner.project.id,
|
|
1812
|
+
file: fileOrFiles,
|
|
1813
|
+
});
|
|
1814
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1815
|
+
}
|
|
1816
|
+
function* gen(fileOrFiles) {
|
|
1817
|
+
if (Array.isArray(fileOrFiles)) {
|
|
1818
|
+
const data = yield* apiRequest("getSymbolsOfSourceFiles", {
|
|
1819
|
+
snapshot: owner.snapshotId,
|
|
1820
|
+
project: owner.project.id,
|
|
1821
|
+
files: fileOrFiles,
|
|
1822
|
+
});
|
|
1823
|
+
return data.map(d => d ? owner.objectRegistry.getOrCreateSymbol(d) : undefined);
|
|
1824
|
+
}
|
|
1825
|
+
const data = yield* apiRequest("getSymbolOfSourceFile", {
|
|
1826
|
+
snapshot: owner.snapshotId,
|
|
1827
|
+
project: owner.project.id,
|
|
1828
|
+
file: fileOrFiles,
|
|
1829
|
+
});
|
|
1830
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1831
|
+
}
|
|
1832
|
+
return cacheGeneratorMethod(owner, "getSymbolOfSourceFile", getSymbolOfSourceFile, gen);
|
|
1049
1833
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1834
|
+
/**
|
|
1835
|
+
* Get the type of a symbol. Always returns a type; for symbols whose type
|
|
1836
|
+
* cannot be determined the checker yields the error type (use
|
|
1837
|
+
* {@link Type.isErrorType} to detect it).
|
|
1838
|
+
*/
|
|
1839
|
+
get getTypeOfSymbol() {
|
|
1840
|
+
const owner = this;
|
|
1841
|
+
function getTypeOfSymbol(symbolOrSymbols) {
|
|
1842
|
+
if (Array.isArray(symbolOrSymbols)) {
|
|
1843
|
+
const data = owner.client.apiRequest("getTypesOfSymbols", {
|
|
1844
|
+
snapshot: owner.snapshotId,
|
|
1845
|
+
project: owner.project.id,
|
|
1846
|
+
symbols: symbolOrSymbols.map(s => s.id),
|
|
1847
|
+
});
|
|
1848
|
+
return data.map(d => owner.objectRegistry.getOrCreateType(d));
|
|
1849
|
+
}
|
|
1850
|
+
const data = owner.client.apiRequest("getTypeOfSymbol", {
|
|
1851
|
+
snapshot: owner.snapshotId,
|
|
1852
|
+
project: owner.project.id,
|
|
1853
|
+
symbol: symbolOrSymbols.id,
|
|
1056
1854
|
});
|
|
1057
|
-
return
|
|
1855
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1058
1856
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1857
|
+
function* gen(symbolOrSymbols) {
|
|
1858
|
+
if (Array.isArray(symbolOrSymbols)) {
|
|
1859
|
+
const data = yield* apiRequest("getTypesOfSymbols", {
|
|
1860
|
+
snapshot: owner.snapshotId,
|
|
1861
|
+
project: owner.project.id,
|
|
1862
|
+
symbols: symbolOrSymbols.map(s => s.id),
|
|
1863
|
+
});
|
|
1864
|
+
return data.map(d => owner.objectRegistry.getOrCreateType(d));
|
|
1865
|
+
}
|
|
1866
|
+
const data = yield* apiRequest("getTypeOfSymbol", {
|
|
1867
|
+
snapshot: owner.snapshotId,
|
|
1868
|
+
project: owner.project.id,
|
|
1869
|
+
symbol: symbolOrSymbols.id,
|
|
1870
|
+
});
|
|
1871
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1872
|
+
}
|
|
1873
|
+
return cacheGeneratorMethod(owner, "getTypeOfSymbol", getTypeOfSymbol, gen);
|
|
1065
1874
|
}
|
|
1066
1875
|
/**
|
|
1067
1876
|
* Get the declared type of a symbol. Always returns a type; for symbols whose
|
|
1068
1877
|
* declared type cannot be determined the checker yields the error type (use
|
|
1069
1878
|
* {@link Type.isErrorType} to detect it).
|
|
1070
1879
|
*/
|
|
1071
|
-
getDeclaredTypeOfSymbol(
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1880
|
+
get getDeclaredTypeOfSymbol() {
|
|
1881
|
+
const owner = this;
|
|
1882
|
+
return cacheGeneratorMethod(owner, "getDeclaredTypeOfSymbol", function (symbol) {
|
|
1883
|
+
const data = owner.client.apiRequest("getDeclaredTypeOfSymbol", {
|
|
1884
|
+
snapshot: owner.snapshotId,
|
|
1885
|
+
project: owner.project.id,
|
|
1886
|
+
symbol: symbol.id,
|
|
1887
|
+
});
|
|
1888
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1889
|
+
}, function* (symbol) {
|
|
1890
|
+
const data = yield* apiRequest("getDeclaredTypeOfSymbol", {
|
|
1891
|
+
snapshot: owner.snapshotId,
|
|
1892
|
+
project: owner.project.id,
|
|
1893
|
+
symbol: symbol.id,
|
|
1894
|
+
});
|
|
1895
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1899
|
+
* Get the type of a symbol, excluding the missing type when
|
|
1900
|
+
* `exactOptionalPropertyTypes: true` is set; for symbols whose
|
|
1901
|
+
* type cannot be determined the checker yields the error type
|
|
1902
|
+
* (use {@link Type.isErrorType} to detect it).
|
|
1903
|
+
*/
|
|
1904
|
+
get getNonMissingTypeOfSymbol() {
|
|
1905
|
+
const owner = this;
|
|
1906
|
+
return cacheGeneratorMethod(owner, "getNonMissingTypeOfSymbol", function (symbol) {
|
|
1907
|
+
const data = owner.client.apiRequest("getNonMissingTypeOfSymbol", {
|
|
1908
|
+
snapshot: owner.snapshotId,
|
|
1909
|
+
project: owner.project.id,
|
|
1910
|
+
symbol: symbol.id,
|
|
1911
|
+
});
|
|
1912
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1913
|
+
}, function* (symbol) {
|
|
1914
|
+
const data = yield* apiRequest("getNonMissingTypeOfSymbol", {
|
|
1915
|
+
snapshot: owner.snapshotId,
|
|
1916
|
+
project: owner.project.id,
|
|
1917
|
+
symbol: symbol.id,
|
|
1918
|
+
});
|
|
1919
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1076
1920
|
});
|
|
1077
|
-
return this.objectRegistry.getOrCreateType(data);
|
|
1078
1921
|
}
|
|
1079
|
-
getReferencesToSymbolInFile(
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1922
|
+
get getReferencesToSymbolInFile() {
|
|
1923
|
+
const owner = this;
|
|
1924
|
+
return cacheGeneratorMethod(owner, "getReferencesToSymbolInFile", function (file, symbol) {
|
|
1925
|
+
const data = owner.client.apiRequest("getReferencesToSymbolInFile", {
|
|
1926
|
+
snapshot: owner.snapshotId,
|
|
1927
|
+
project: owner.project.id,
|
|
1928
|
+
file,
|
|
1929
|
+
symbol: symbol.id,
|
|
1930
|
+
});
|
|
1931
|
+
return (data ?? []).map(h => new NodeHandle(h, owner.project));
|
|
1932
|
+
}, function* (file, symbol) {
|
|
1933
|
+
const data = yield* apiRequest("getReferencesToSymbolInFile", {
|
|
1934
|
+
snapshot: owner.snapshotId,
|
|
1935
|
+
project: owner.project.id,
|
|
1936
|
+
file,
|
|
1937
|
+
symbol: symbol.id,
|
|
1938
|
+
});
|
|
1939
|
+
return (data ?? []).map(h => new NodeHandle(h, owner.project));
|
|
1085
1940
|
});
|
|
1086
|
-
return (data ?? []).map(h => new NodeHandle(h, this.project));
|
|
1087
1941
|
}
|
|
1088
1942
|
/** @deprecated Use `project.languageService.getReferencedSymbolsForNode`. */
|
|
1089
|
-
getReferencedSymbolsForNode(
|
|
1090
|
-
|
|
1943
|
+
get getReferencedSymbolsForNode() {
|
|
1944
|
+
const owner = this;
|
|
1945
|
+
return cacheGeneratorMethod(owner, "getReferencedSymbolsForNode", function (node, position) {
|
|
1946
|
+
return owner.project.languageService.getReferencedSymbolsForNode(node, position);
|
|
1947
|
+
}, function* (node, position) {
|
|
1948
|
+
return yield* owner.project.languageService.getReferencedSymbolsForNode.gen(node, position);
|
|
1949
|
+
});
|
|
1091
1950
|
}
|
|
1092
1951
|
/** @deprecated Use `project.languageService.getSignatureUsage`. */
|
|
1093
|
-
getSignatureUsage(
|
|
1094
|
-
|
|
1952
|
+
get getSignatureUsage() {
|
|
1953
|
+
const owner = this;
|
|
1954
|
+
return cacheGeneratorMethod(owner, "getSignatureUsage", function (signatureDecl) {
|
|
1955
|
+
return owner.project.languageService.getSignatureUsage(signatureDecl);
|
|
1956
|
+
}, function* (signatureDecl) {
|
|
1957
|
+
return yield* owner.project.languageService.getSignatureUsage.gen(signatureDecl);
|
|
1958
|
+
});
|
|
1095
1959
|
}
|
|
1096
1960
|
/** @deprecated Use `project.languageService.getCompletionsAtPosition`. */
|
|
1097
|
-
getCompletionsAtPosition(
|
|
1098
|
-
|
|
1961
|
+
get getCompletionsAtPosition() {
|
|
1962
|
+
const owner = this;
|
|
1963
|
+
return cacheGeneratorMethod(owner, "getCompletionsAtPosition", function (document, position, options) {
|
|
1964
|
+
return owner.project.languageService.getCompletionsAtPosition(document, position, options);
|
|
1965
|
+
}, function* (document, position, options) {
|
|
1966
|
+
return yield* owner.project.languageService.getCompletionsAtPosition.gen(document, position, options);
|
|
1967
|
+
});
|
|
1099
1968
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1969
|
+
/**
|
|
1970
|
+
* Get the type at a node location. Always returns a type; for nodes whose
|
|
1971
|
+
* type cannot be determined the checker yields the error type (use
|
|
1972
|
+
* {@link Type.isErrorType} to detect it).
|
|
1973
|
+
*/
|
|
1974
|
+
get getTypeAtLocation() {
|
|
1975
|
+
const owner = this;
|
|
1976
|
+
function getTypeAtLocation(nodeOrNodes) {
|
|
1977
|
+
if (Array.isArray(nodeOrNodes)) {
|
|
1978
|
+
const data = owner.client.apiRequest("getTypeAtLocations", {
|
|
1979
|
+
snapshot: owner.snapshotId,
|
|
1980
|
+
project: owner.project.id,
|
|
1981
|
+
locations: nodeOrNodes.map(node => getNodeId(node)),
|
|
1982
|
+
});
|
|
1983
|
+
return data.map(d => owner.objectRegistry.getOrCreateType(d));
|
|
1984
|
+
}
|
|
1985
|
+
const data = owner.client.apiRequest("getTypeAtLocation", {
|
|
1986
|
+
snapshot: owner.snapshotId,
|
|
1987
|
+
project: owner.project.id,
|
|
1988
|
+
location: getNodeId(nodeOrNodes),
|
|
1106
1989
|
});
|
|
1107
|
-
return
|
|
1990
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1108
1991
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1992
|
+
function* gen(nodeOrNodes) {
|
|
1993
|
+
if (Array.isArray(nodeOrNodes)) {
|
|
1994
|
+
const data = yield* apiRequest("getTypeAtLocations", {
|
|
1995
|
+
snapshot: owner.snapshotId,
|
|
1996
|
+
project: owner.project.id,
|
|
1997
|
+
locations: nodeOrNodes.map(node => getNodeId(node)),
|
|
1998
|
+
});
|
|
1999
|
+
return data.map(d => owner.objectRegistry.getOrCreateType(d));
|
|
2000
|
+
}
|
|
2001
|
+
const data = yield* apiRequest("getTypeAtLocation", {
|
|
2002
|
+
snapshot: owner.snapshotId,
|
|
2003
|
+
project: owner.project.id,
|
|
2004
|
+
location: getNodeId(nodeOrNodes),
|
|
2005
|
+
});
|
|
2006
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
2007
|
+
}
|
|
2008
|
+
return cacheGeneratorMethod(owner, "getTypeAtLocation", getTypeAtLocation, gen);
|
|
1115
2009
|
}
|
|
1116
|
-
getSignaturesOfType(
|
|
1117
|
-
|
|
2010
|
+
get getSignaturesOfType() {
|
|
2011
|
+
const owner = this;
|
|
2012
|
+
return cacheGeneratorMethod(owner, "getSignaturesOfType", function (type, kind) {
|
|
2013
|
+
return kind === SignatureKind.Call ? type.getCallSignatures() : type.getConstructSignatures();
|
|
2014
|
+
}, function* (type, kind) {
|
|
2015
|
+
return kind === SignatureKind.Call ? (yield* type.getCallSignatures.gen()) : (yield* type.getConstructSignatures.gen());
|
|
2016
|
+
});
|
|
1118
2017
|
}
|
|
1119
2018
|
/**
|
|
1120
2019
|
* Get the resolved signature of a call-like expression. Always returns a
|
|
1121
2020
|
* signature; when a call cannot be resolved the checker yields the unknown
|
|
1122
2021
|
* signature (use {@link Checker.isUnknownSignature} to detect it).
|
|
1123
2022
|
*/
|
|
1124
|
-
getResolvedSignature(
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
const data =
|
|
1135
|
-
snapshot:
|
|
1136
|
-
project:
|
|
2023
|
+
get getResolvedSignature() {
|
|
2024
|
+
const owner = this;
|
|
2025
|
+
return cacheGeneratorMethod(owner, "getResolvedSignature", function (node) {
|
|
2026
|
+
const data = owner.client.apiRequest("getResolvedSignature", {
|
|
2027
|
+
snapshot: owner.snapshotId,
|
|
2028
|
+
project: owner.project.id,
|
|
2029
|
+
location: getNodeId(node),
|
|
2030
|
+
});
|
|
2031
|
+
return owner.objectRegistry.getOrCreateSignature(data);
|
|
2032
|
+
}, function* (node) {
|
|
2033
|
+
const data = yield* apiRequest("getResolvedSignature", {
|
|
2034
|
+
snapshot: owner.snapshotId,
|
|
2035
|
+
project: owner.project.id,
|
|
2036
|
+
location: getNodeId(node),
|
|
2037
|
+
});
|
|
2038
|
+
return owner.objectRegistry.getOrCreateSignature(data);
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
get getTypeAtPosition() {
|
|
2042
|
+
const owner = this;
|
|
2043
|
+
function getTypeAtPosition(file, positionOrPositions) {
|
|
2044
|
+
if (typeof positionOrPositions === "number") {
|
|
2045
|
+
const data = owner.client.apiRequest("getTypeAtPosition", {
|
|
2046
|
+
snapshot: owner.snapshotId,
|
|
2047
|
+
project: owner.project.id,
|
|
2048
|
+
file,
|
|
2049
|
+
position: positionOrPositions,
|
|
2050
|
+
});
|
|
2051
|
+
return data ? owner.objectRegistry.getOrCreateType(data) : undefined;
|
|
2052
|
+
}
|
|
2053
|
+
const data = owner.client.apiRequest("getTypesAtPositions", {
|
|
2054
|
+
snapshot: owner.snapshotId,
|
|
2055
|
+
project: owner.project.id,
|
|
2056
|
+
file,
|
|
2057
|
+
positions: positionOrPositions,
|
|
2058
|
+
});
|
|
2059
|
+
return data.map(d => d ? owner.objectRegistry.getOrCreateType(d) : undefined);
|
|
2060
|
+
}
|
|
2061
|
+
function* gen(file, positionOrPositions) {
|
|
2062
|
+
if (typeof positionOrPositions === "number") {
|
|
2063
|
+
const data = yield* apiRequest("getTypeAtPosition", {
|
|
2064
|
+
snapshot: owner.snapshotId,
|
|
2065
|
+
project: owner.project.id,
|
|
2066
|
+
file,
|
|
2067
|
+
position: positionOrPositions,
|
|
2068
|
+
});
|
|
2069
|
+
return data ? owner.objectRegistry.getOrCreateType(data) : undefined;
|
|
2070
|
+
}
|
|
2071
|
+
const data = yield* apiRequest("getTypesAtPositions", {
|
|
2072
|
+
snapshot: owner.snapshotId,
|
|
2073
|
+
project: owner.project.id,
|
|
1137
2074
|
file,
|
|
1138
|
-
|
|
2075
|
+
positions: positionOrPositions,
|
|
1139
2076
|
});
|
|
1140
|
-
return data ?
|
|
2077
|
+
return data.map(d => d ? owner.objectRegistry.getOrCreateType(d) : undefined);
|
|
1141
2078
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
2079
|
+
return cacheGeneratorMethod(owner, "getTypeAtPosition", getTypeAtPosition, gen);
|
|
2080
|
+
}
|
|
2081
|
+
get resolveName() {
|
|
2082
|
+
const owner = this;
|
|
2083
|
+
return cacheGeneratorMethod(owner, "resolveName", function (name, meaning, location, excludeGlobals) {
|
|
2084
|
+
// Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
|
|
2085
|
+
const isNode = location && "kind" in location;
|
|
2086
|
+
const data = owner.client.apiRequest("resolveName", {
|
|
2087
|
+
snapshot: owner.snapshotId,
|
|
2088
|
+
project: owner.project.id,
|
|
2089
|
+
name,
|
|
2090
|
+
meaning,
|
|
2091
|
+
...(isNode ? { location: getNodeId(location) } : {}),
|
|
2092
|
+
...(!isNode && location
|
|
2093
|
+
? {
|
|
2094
|
+
file: location.document,
|
|
2095
|
+
position: location.position,
|
|
2096
|
+
}
|
|
2097
|
+
: {}),
|
|
2098
|
+
...(excludeGlobals !== undefined ? { excludeGlobals } : {}),
|
|
2099
|
+
});
|
|
2100
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
2101
|
+
}, function* (name, meaning, location, excludeGlobals) {
|
|
2102
|
+
// Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
|
|
2103
|
+
const isNode = location && "kind" in location;
|
|
2104
|
+
const data = yield* apiRequest("resolveName", {
|
|
2105
|
+
snapshot: owner.snapshotId,
|
|
2106
|
+
project: owner.project.id,
|
|
2107
|
+
name,
|
|
2108
|
+
meaning,
|
|
2109
|
+
...(isNode ? { location: getNodeId(location) } : {}),
|
|
2110
|
+
...(!isNode && location
|
|
2111
|
+
? {
|
|
2112
|
+
file: location.document,
|
|
2113
|
+
position: location.position,
|
|
2114
|
+
}
|
|
2115
|
+
: {}),
|
|
2116
|
+
...(excludeGlobals !== undefined ? { excludeGlobals } : {}),
|
|
2117
|
+
});
|
|
2118
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1166
2119
|
});
|
|
1167
|
-
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1168
2120
|
}
|
|
1169
2121
|
/**
|
|
1170
2122
|
* Returns all symbols with the given meaning that are visible at `location`.
|
|
1171
2123
|
*/
|
|
1172
|
-
getSymbolsInScope(
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
2124
|
+
get getSymbolsInScope() {
|
|
2125
|
+
const owner = this;
|
|
2126
|
+
return cacheGeneratorMethod(owner, "getSymbolsInScope", function (location, meaning) {
|
|
2127
|
+
// Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
|
|
2128
|
+
const isNode = "kind" in location;
|
|
2129
|
+
const data = owner.client.apiRequest("getSymbolsInScope", {
|
|
2130
|
+
snapshot: owner.snapshotId,
|
|
2131
|
+
project: owner.project.id,
|
|
2132
|
+
meaning,
|
|
2133
|
+
...(isNode
|
|
2134
|
+
? { location: getNodeId(location) }
|
|
2135
|
+
: {
|
|
2136
|
+
file: location.document,
|
|
2137
|
+
position: location.position,
|
|
2138
|
+
}),
|
|
2139
|
+
});
|
|
2140
|
+
return data ? data.map(d => owner.objectRegistry.getOrCreateSymbol(d)) : [];
|
|
2141
|
+
}, function* (location, meaning) {
|
|
2142
|
+
// Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
|
|
2143
|
+
const isNode = "kind" in location;
|
|
2144
|
+
const data = yield* apiRequest("getSymbolsInScope", {
|
|
2145
|
+
snapshot: owner.snapshotId,
|
|
2146
|
+
project: owner.project.id,
|
|
2147
|
+
meaning,
|
|
2148
|
+
...(isNode
|
|
2149
|
+
? { location: getNodeId(location) }
|
|
2150
|
+
: {
|
|
2151
|
+
file: location.document,
|
|
2152
|
+
position: location.position,
|
|
2153
|
+
}),
|
|
2154
|
+
});
|
|
2155
|
+
return data ? data.map(d => owner.objectRegistry.getOrCreateSymbol(d)) : [];
|
|
2156
|
+
});
|
|
2157
|
+
}
|
|
2158
|
+
get getResolvedSymbol() {
|
|
2159
|
+
const owner = this;
|
|
2160
|
+
return cacheGeneratorMethod(owner, "getResolvedSymbol", function (node) {
|
|
2161
|
+
const text = node.text;
|
|
2162
|
+
if (!text)
|
|
2163
|
+
return undefined;
|
|
2164
|
+
return owner.resolveName(text, SymbolFlags.Value | SymbolFlags.ExportValue, node);
|
|
2165
|
+
}, function* (node) {
|
|
2166
|
+
const text = node.text;
|
|
2167
|
+
if (!text)
|
|
2168
|
+
return undefined;
|
|
2169
|
+
return yield* owner.resolveName.gen(text, SymbolFlags.Value | SymbolFlags.ExportValue, node);
|
|
2170
|
+
});
|
|
2171
|
+
}
|
|
2172
|
+
get getContextualType() {
|
|
2173
|
+
const owner = this;
|
|
2174
|
+
return cacheGeneratorMethod(owner, "getContextualType", function (node) {
|
|
2175
|
+
const data = owner.client.apiRequest("getContextualType", {
|
|
2176
|
+
snapshot: owner.snapshotId,
|
|
2177
|
+
project: owner.project.id,
|
|
2178
|
+
location: getNodeId(node),
|
|
2179
|
+
});
|
|
2180
|
+
return data ? owner.objectRegistry.getOrCreateType(data) : undefined;
|
|
2181
|
+
}, function* (node) {
|
|
2182
|
+
const data = yield* apiRequest("getContextualType", {
|
|
2183
|
+
snapshot: owner.snapshotId,
|
|
2184
|
+
project: owner.project.id,
|
|
2185
|
+
location: getNodeId(node),
|
|
2186
|
+
});
|
|
2187
|
+
return data ? owner.objectRegistry.getOrCreateType(data) : undefined;
|
|
2188
|
+
});
|
|
1201
2189
|
}
|
|
1202
2190
|
/** Get the base type of a literal type (e.g. `number` for `42`). Always returns a type. */
|
|
1203
|
-
getBaseTypeOfLiteralType(
|
|
1204
|
-
const
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
2191
|
+
get getBaseTypeOfLiteralType() {
|
|
2192
|
+
const owner = this;
|
|
2193
|
+
return cacheGeneratorMethod(owner, "getBaseTypeOfLiteralType", function (type) {
|
|
2194
|
+
const data = owner.client.apiRequest("getBaseTypeOfLiteralType", {
|
|
2195
|
+
snapshot: owner.snapshotId,
|
|
2196
|
+
project: owner.project.id,
|
|
2197
|
+
type: type.id,
|
|
2198
|
+
});
|
|
2199
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
2200
|
+
}, function* (type) {
|
|
2201
|
+
const data = yield* apiRequest("getBaseTypeOfLiteralType", {
|
|
2202
|
+
snapshot: owner.snapshotId,
|
|
2203
|
+
project: owner.project.id,
|
|
2204
|
+
type: type.id,
|
|
2205
|
+
});
|
|
2206
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1208
2207
|
});
|
|
1209
|
-
return this.objectRegistry.getOrCreateType(data);
|
|
1210
2208
|
}
|
|
1211
2209
|
/** Get the type with `null` and `undefined` removed. Always returns a type. */
|
|
1212
|
-
getNonNullableType(
|
|
1213
|
-
|
|
2210
|
+
get getNonNullableType() {
|
|
2211
|
+
const owner = this;
|
|
2212
|
+
return cacheGeneratorMethod(owner, "getNonNullableType", function (type) {
|
|
2213
|
+
return type.getNonNullableType();
|
|
2214
|
+
}, function* (type) {
|
|
2215
|
+
return yield* type.getNonNullableType.gen();
|
|
2216
|
+
});
|
|
1214
2217
|
}
|
|
1215
2218
|
/**
|
|
1216
2219
|
* Get the type for a type node. Always returns a type; for type nodes whose
|
|
1217
2220
|
* type cannot be determined the checker yields the error type (use
|
|
1218
2221
|
* {@link Type.isErrorType} to detect it).
|
|
1219
2222
|
*/
|
|
1220
|
-
getTypeFromTypeNode(
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
2223
|
+
get getTypeFromTypeNode() {
|
|
2224
|
+
const owner = this;
|
|
2225
|
+
return cacheGeneratorMethod(owner, "getTypeFromTypeNode", function (node) {
|
|
2226
|
+
const data = owner.client.apiRequest("getTypeFromTypeNode", {
|
|
2227
|
+
snapshot: owner.snapshotId,
|
|
2228
|
+
project: owner.project.id,
|
|
2229
|
+
location: getNodeId(node),
|
|
2230
|
+
});
|
|
2231
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
2232
|
+
}, function* (node) {
|
|
2233
|
+
const data = yield* apiRequest("getTypeFromTypeNode", {
|
|
2234
|
+
snapshot: owner.snapshotId,
|
|
2235
|
+
project: owner.project.id,
|
|
2236
|
+
location: getNodeId(node),
|
|
2237
|
+
});
|
|
2238
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1225
2239
|
});
|
|
1226
|
-
return this.objectRegistry.getOrCreateType(data);
|
|
1227
2240
|
}
|
|
1228
2241
|
/** Get the widened type. Always returns a type. */
|
|
1229
|
-
getWidenedType(
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
2242
|
+
get getWidenedType() {
|
|
2243
|
+
const owner = this;
|
|
2244
|
+
return cacheGeneratorMethod(owner, "getWidenedType", function (type) {
|
|
2245
|
+
const data = owner.client.apiRequest("getWidenedType", {
|
|
2246
|
+
snapshot: owner.snapshotId,
|
|
2247
|
+
project: owner.project.id,
|
|
2248
|
+
type: type.id,
|
|
2249
|
+
});
|
|
2250
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
2251
|
+
}, function* (type) {
|
|
2252
|
+
const data = yield* apiRequest("getWidenedType", {
|
|
2253
|
+
snapshot: owner.snapshotId,
|
|
2254
|
+
project: owner.project.id,
|
|
2255
|
+
type: type.id,
|
|
2256
|
+
});
|
|
2257
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1234
2258
|
});
|
|
1235
|
-
return this.objectRegistry.getOrCreateType(data);
|
|
1236
2259
|
}
|
|
1237
2260
|
/**
|
|
1238
2261
|
* Get the type of the parameter at the given index in a signature. Always
|
|
1239
2262
|
* returns a type; an out-of-range index yields the `any` type.
|
|
1240
2263
|
*/
|
|
1241
|
-
getParameterType(
|
|
1242
|
-
const
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
2264
|
+
get getParameterType() {
|
|
2265
|
+
const owner = this;
|
|
2266
|
+
return cacheGeneratorMethod(owner, "getParameterType", function (signature, index) {
|
|
2267
|
+
const data = owner.client.apiRequest("getParameterType", {
|
|
2268
|
+
snapshot: owner.snapshotId,
|
|
2269
|
+
project: owner.project.id,
|
|
2270
|
+
signature: signature.id,
|
|
2271
|
+
index,
|
|
2272
|
+
});
|
|
2273
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
2274
|
+
}, function* (signature, index) {
|
|
2275
|
+
const data = yield* apiRequest("getParameterType", {
|
|
2276
|
+
snapshot: owner.snapshotId,
|
|
2277
|
+
project: owner.project.id,
|
|
2278
|
+
signature: signature.id,
|
|
2279
|
+
index,
|
|
2280
|
+
});
|
|
2281
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1247
2282
|
});
|
|
1248
|
-
return this.objectRegistry.getOrCreateType(data);
|
|
1249
2283
|
}
|
|
1250
|
-
isArrayLikeType(
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
2284
|
+
get isArrayLikeType() {
|
|
2285
|
+
const owner = this;
|
|
2286
|
+
return cacheGeneratorMethod(owner, "isArrayLikeType", function (type) {
|
|
2287
|
+
return owner.client.apiRequest("isArrayLikeType", {
|
|
2288
|
+
snapshot: owner.snapshotId,
|
|
2289
|
+
project: owner.project.id,
|
|
2290
|
+
type: type.id,
|
|
2291
|
+
});
|
|
2292
|
+
}, function* (type) {
|
|
2293
|
+
return yield* apiRequest("isArrayLikeType", {
|
|
2294
|
+
snapshot: owner.snapshotId,
|
|
2295
|
+
project: owner.project.id,
|
|
2296
|
+
type: type.id,
|
|
2297
|
+
});
|
|
1255
2298
|
});
|
|
1256
2299
|
}
|
|
1257
|
-
isTypeAssignableTo(
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
2300
|
+
get isTypeAssignableTo() {
|
|
2301
|
+
const owner = this;
|
|
2302
|
+
return cacheGeneratorMethod(owner, "isTypeAssignableTo", function (source, target) {
|
|
2303
|
+
return owner.client.apiRequest("isTypeAssignableTo", {
|
|
2304
|
+
snapshot: owner.snapshotId,
|
|
2305
|
+
project: owner.project.id,
|
|
2306
|
+
source: source.id,
|
|
2307
|
+
target: target.id,
|
|
2308
|
+
});
|
|
2309
|
+
}, function* (source, target) {
|
|
2310
|
+
return yield* apiRequest("isTypeAssignableTo", {
|
|
2311
|
+
snapshot: owner.snapshotId,
|
|
2312
|
+
project: owner.project.id,
|
|
2313
|
+
source: source.id,
|
|
2314
|
+
target: target.id,
|
|
2315
|
+
});
|
|
1263
2316
|
});
|
|
1264
2317
|
}
|
|
1265
|
-
getShorthandAssignmentValueSymbol(
|
|
1266
|
-
const
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
2318
|
+
get getShorthandAssignmentValueSymbol() {
|
|
2319
|
+
const owner = this;
|
|
2320
|
+
return cacheGeneratorMethod(owner, "getShorthandAssignmentValueSymbol", function (node) {
|
|
2321
|
+
const data = owner.client.apiRequest("getShorthandAssignmentValueSymbol", {
|
|
2322
|
+
snapshot: owner.snapshotId,
|
|
2323
|
+
project: owner.project.id,
|
|
2324
|
+
location: getNodeId(node),
|
|
2325
|
+
});
|
|
2326
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
2327
|
+
}, function* (node) {
|
|
2328
|
+
const data = yield* apiRequest("getShorthandAssignmentValueSymbol", {
|
|
2329
|
+
snapshot: owner.snapshotId,
|
|
2330
|
+
project: owner.project.id,
|
|
2331
|
+
location: getNodeId(node),
|
|
2332
|
+
});
|
|
2333
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1270
2334
|
});
|
|
1271
|
-
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1272
2335
|
}
|
|
1273
2336
|
/**
|
|
1274
2337
|
* Get the type of a symbol as narrowed at a specific location. Always returns
|
|
1275
2338
|
* a type; for symbols whose type cannot be determined the checker yields the
|
|
1276
2339
|
* error type (use {@link Type.isErrorType} to detect it).
|
|
1277
2340
|
*/
|
|
1278
|
-
getTypeOfSymbolAtLocation(
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
2341
|
+
get getTypeOfSymbolAtLocation() {
|
|
2342
|
+
const owner = this;
|
|
2343
|
+
return cacheGeneratorMethod(owner, "getTypeOfSymbolAtLocation", function (symbol, location) {
|
|
2344
|
+
const data = owner.client.apiRequest("getTypeOfSymbolAtLocation", {
|
|
2345
|
+
snapshot: owner.snapshotId,
|
|
2346
|
+
project: owner.project.id,
|
|
2347
|
+
symbol: symbol.id,
|
|
2348
|
+
location: getNodeId(location),
|
|
2349
|
+
});
|
|
2350
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
2351
|
+
}, function* (symbol, location) {
|
|
2352
|
+
const data = yield* apiRequest("getTypeOfSymbolAtLocation", {
|
|
2353
|
+
snapshot: owner.snapshotId,
|
|
2354
|
+
project: owner.project.id,
|
|
2355
|
+
symbol: symbol.id,
|
|
2356
|
+
location: getNodeId(location),
|
|
2357
|
+
});
|
|
2358
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1291
2359
|
});
|
|
1292
|
-
return this.objectRegistry.getOrCreateType(data);
|
|
1293
|
-
}
|
|
1294
|
-
getAnyType() {
|
|
1295
|
-
return this.getIntrinsicType("getAnyType");
|
|
1296
|
-
}
|
|
1297
|
-
getStringType() {
|
|
1298
|
-
return this.getIntrinsicType("getStringType");
|
|
1299
|
-
}
|
|
1300
|
-
getNumberType() {
|
|
1301
|
-
return this.getIntrinsicType("getNumberType");
|
|
1302
|
-
}
|
|
1303
|
-
getBooleanType() {
|
|
1304
|
-
return this.getIntrinsicType("getBooleanType");
|
|
1305
|
-
}
|
|
1306
|
-
getVoidType() {
|
|
1307
|
-
return this.getIntrinsicType("getVoidType");
|
|
1308
|
-
}
|
|
1309
|
-
getUndefinedType() {
|
|
1310
|
-
return this.getIntrinsicType("getUndefinedType");
|
|
1311
|
-
}
|
|
1312
|
-
getNullType() {
|
|
1313
|
-
return this.getIntrinsicType("getNullType");
|
|
1314
|
-
}
|
|
1315
|
-
getNeverType() {
|
|
1316
|
-
return this.getIntrinsicType("getNeverType");
|
|
1317
|
-
}
|
|
1318
|
-
getUnknownType() {
|
|
1319
|
-
return this.getIntrinsicType("getUnknownType");
|
|
1320
|
-
}
|
|
1321
|
-
getBigIntType() {
|
|
1322
|
-
return this.getIntrinsicType("getBigIntType");
|
|
1323
|
-
}
|
|
1324
|
-
getESSymbolType() {
|
|
1325
|
-
return this.getIntrinsicType("getESSymbolType");
|
|
1326
2360
|
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
2361
|
+
get getIntrinsicType() {
|
|
2362
|
+
const owner = this;
|
|
2363
|
+
return cacheGeneratorMethod(owner, "getIntrinsicType", function (method) {
|
|
2364
|
+
const data = owner.client.apiRequest(method, {
|
|
2365
|
+
snapshot: owner.snapshotId,
|
|
2366
|
+
project: owner.project.id,
|
|
2367
|
+
});
|
|
2368
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
2369
|
+
}, function* (method) {
|
|
2370
|
+
const data = yield* apiRequest(method, {
|
|
2371
|
+
snapshot: owner.snapshotId,
|
|
2372
|
+
project: owner.project.id,
|
|
2373
|
+
});
|
|
2374
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
1337
2375
|
});
|
|
1338
|
-
if (!binaryData)
|
|
1339
|
-
return undefined;
|
|
1340
|
-
return decodeNode(binaryData);
|
|
1341
2376
|
}
|
|
1342
|
-
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
2377
|
+
get getAnyType() {
|
|
2378
|
+
const owner = this;
|
|
2379
|
+
return cacheGeneratorMethod(owner, "getAnyType", function () {
|
|
2380
|
+
return owner.getIntrinsicType("getAnyType");
|
|
2381
|
+
}, function* () {
|
|
2382
|
+
return yield* owner.getIntrinsicType.gen("getAnyType");
|
|
2383
|
+
});
|
|
2384
|
+
}
|
|
2385
|
+
get getStringType() {
|
|
2386
|
+
const owner = this;
|
|
2387
|
+
return cacheGeneratorMethod(owner, "getStringType", function () {
|
|
2388
|
+
return owner.getIntrinsicType("getStringType");
|
|
2389
|
+
}, function* () {
|
|
2390
|
+
return yield* owner.getIntrinsicType.gen("getStringType");
|
|
2391
|
+
});
|
|
2392
|
+
}
|
|
2393
|
+
get getNumberType() {
|
|
2394
|
+
const owner = this;
|
|
2395
|
+
return cacheGeneratorMethod(owner, "getNumberType", function () {
|
|
2396
|
+
return owner.getIntrinsicType("getNumberType");
|
|
2397
|
+
}, function* () {
|
|
2398
|
+
return yield* owner.getIntrinsicType.gen("getNumberType");
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2401
|
+
get getBooleanType() {
|
|
2402
|
+
const owner = this;
|
|
2403
|
+
return cacheGeneratorMethod(owner, "getBooleanType", function () {
|
|
2404
|
+
return owner.getIntrinsicType("getBooleanType");
|
|
2405
|
+
}, function* () {
|
|
2406
|
+
return yield* owner.getIntrinsicType.gen("getBooleanType");
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
get getVoidType() {
|
|
2410
|
+
const owner = this;
|
|
2411
|
+
return cacheGeneratorMethod(owner, "getVoidType", function () {
|
|
2412
|
+
return owner.getIntrinsicType("getVoidType");
|
|
2413
|
+
}, function* () {
|
|
2414
|
+
return yield* owner.getIntrinsicType.gen("getVoidType");
|
|
2415
|
+
});
|
|
2416
|
+
}
|
|
2417
|
+
get getUndefinedType() {
|
|
2418
|
+
const owner = this;
|
|
2419
|
+
return cacheGeneratorMethod(owner, "getUndefinedType", function () {
|
|
2420
|
+
return owner.getIntrinsicType("getUndefinedType");
|
|
2421
|
+
}, function* () {
|
|
2422
|
+
return yield* owner.getIntrinsicType.gen("getUndefinedType");
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
get getNullType() {
|
|
2426
|
+
const owner = this;
|
|
2427
|
+
return cacheGeneratorMethod(owner, "getNullType", function () {
|
|
2428
|
+
return owner.getIntrinsicType("getNullType");
|
|
2429
|
+
}, function* () {
|
|
2430
|
+
return yield* owner.getIntrinsicType.gen("getNullType");
|
|
2431
|
+
});
|
|
2432
|
+
}
|
|
2433
|
+
get getNeverType() {
|
|
2434
|
+
const owner = this;
|
|
2435
|
+
return cacheGeneratorMethod(owner, "getNeverType", function () {
|
|
2436
|
+
return owner.getIntrinsicType("getNeverType");
|
|
2437
|
+
}, function* () {
|
|
2438
|
+
return yield* owner.getIntrinsicType.gen("getNeverType");
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
get getUnknownType() {
|
|
2442
|
+
const owner = this;
|
|
2443
|
+
return cacheGeneratorMethod(owner, "getUnknownType", function () {
|
|
2444
|
+
return owner.getIntrinsicType("getUnknownType");
|
|
2445
|
+
}, function* () {
|
|
2446
|
+
return yield* owner.getIntrinsicType.gen("getUnknownType");
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
get getBigIntType() {
|
|
2450
|
+
const owner = this;
|
|
2451
|
+
return cacheGeneratorMethod(owner, "getBigIntType", function () {
|
|
2452
|
+
return owner.getIntrinsicType("getBigIntType");
|
|
2453
|
+
}, function* () {
|
|
2454
|
+
return yield* owner.getIntrinsicType.gen("getBigIntType");
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2457
|
+
get getESSymbolType() {
|
|
2458
|
+
const owner = this;
|
|
2459
|
+
return cacheGeneratorMethod(owner, "getESSymbolType", function () {
|
|
2460
|
+
return owner.getIntrinsicType("getESSymbolType");
|
|
2461
|
+
}, function* () {
|
|
2462
|
+
return yield* owner.getIntrinsicType.gen("getESSymbolType");
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
get getNonPrimitiveType() {
|
|
2466
|
+
const owner = this;
|
|
2467
|
+
return cacheGeneratorMethod(owner, "getNonPrimitiveType", function () {
|
|
2468
|
+
return owner.getIntrinsicType("getNonPrimitiveType");
|
|
2469
|
+
}, function* () {
|
|
2470
|
+
return yield* owner.getIntrinsicType.gen("getNonPrimitiveType");
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
get typeToTypeNode() {
|
|
2474
|
+
const owner = this;
|
|
2475
|
+
return cacheGeneratorMethod(owner, "typeToTypeNode", function (type, enclosingDeclaration, flags) {
|
|
2476
|
+
const binaryData = owner.client.apiRequestBinary("typeToTypeNode", {
|
|
2477
|
+
snapshot: owner.snapshotId,
|
|
2478
|
+
project: owner.project.id,
|
|
2479
|
+
type: type.id,
|
|
2480
|
+
...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
|
|
2481
|
+
...(flags !== undefined ? { flags } : {}),
|
|
2482
|
+
});
|
|
2483
|
+
if (!binaryData)
|
|
2484
|
+
return undefined;
|
|
2485
|
+
return decodeNode(binaryData);
|
|
2486
|
+
}, function* (type, enclosingDeclaration, flags) {
|
|
2487
|
+
const binaryData = owner.client.apiRequestBinary("typeToTypeNode", {
|
|
2488
|
+
snapshot: owner.snapshotId,
|
|
2489
|
+
project: owner.project.id,
|
|
2490
|
+
type: type.id,
|
|
2491
|
+
...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
|
|
2492
|
+
...(flags !== undefined ? { flags } : {}),
|
|
2493
|
+
});
|
|
2494
|
+
if (!binaryData)
|
|
2495
|
+
return undefined;
|
|
2496
|
+
return decodeNode(binaryData);
|
|
2497
|
+
});
|
|
2498
|
+
}
|
|
2499
|
+
get signatureToSignatureDeclaration() {
|
|
2500
|
+
const owner = this;
|
|
2501
|
+
return cacheGeneratorMethod(owner, "signatureToSignatureDeclaration", function (signature, kind, enclosingDeclaration, flags) {
|
|
2502
|
+
const binaryData = owner.client.apiRequestBinary("signatureToSignatureDeclaration", {
|
|
2503
|
+
snapshot: owner.snapshotId,
|
|
2504
|
+
project: owner.project.id,
|
|
2505
|
+
signature: signature.id,
|
|
2506
|
+
kind,
|
|
2507
|
+
...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
|
|
2508
|
+
...(flags !== undefined ? { flags } : {}),
|
|
2509
|
+
});
|
|
2510
|
+
if (!binaryData)
|
|
2511
|
+
return undefined;
|
|
2512
|
+
return decodeNode(binaryData);
|
|
2513
|
+
}, function* (signature, kind, enclosingDeclaration, flags) {
|
|
2514
|
+
const binaryData = owner.client.apiRequestBinary("signatureToSignatureDeclaration", {
|
|
2515
|
+
snapshot: owner.snapshotId,
|
|
2516
|
+
project: owner.project.id,
|
|
2517
|
+
signature: signature.id,
|
|
2518
|
+
kind,
|
|
2519
|
+
...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
|
|
2520
|
+
...(flags !== undefined ? { flags } : {}),
|
|
2521
|
+
});
|
|
2522
|
+
if (!binaryData)
|
|
2523
|
+
return undefined;
|
|
2524
|
+
return decodeNode(binaryData);
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
get typeToString() {
|
|
2528
|
+
const owner = this;
|
|
2529
|
+
return cacheGeneratorMethod(owner, "typeToString", function (type, enclosingDeclaration, flags) {
|
|
2530
|
+
const result = owner.client.apiRequest("typeToString", {
|
|
2531
|
+
snapshot: owner.snapshotId,
|
|
2532
|
+
project: owner.project.id,
|
|
2533
|
+
type: type.id,
|
|
2534
|
+
...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
|
|
2535
|
+
...(flags !== undefined ? { flags } : {}),
|
|
2536
|
+
});
|
|
2537
|
+
if (typeof result !== "string")
|
|
2538
|
+
throw new TypeError("typeToString returned a non-string result");
|
|
2539
|
+
return result;
|
|
2540
|
+
}, function* (type, enclosingDeclaration, flags) {
|
|
2541
|
+
const result = yield* apiRequest("typeToString", {
|
|
2542
|
+
snapshot: owner.snapshotId,
|
|
2543
|
+
project: owner.project.id,
|
|
2544
|
+
type: type.id,
|
|
2545
|
+
...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
|
|
2546
|
+
...(flags !== undefined ? { flags } : {}),
|
|
2547
|
+
});
|
|
2548
|
+
if (typeof result !== "string")
|
|
2549
|
+
throw new TypeError("typeToString returned a non-string result");
|
|
2550
|
+
return result;
|
|
1350
2551
|
});
|
|
1351
|
-
if (!binaryData)
|
|
1352
|
-
return undefined;
|
|
1353
|
-
return decodeNode(binaryData);
|
|
1354
2552
|
}
|
|
1355
|
-
|
|
1356
|
-
const
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
2553
|
+
get isContextSensitive() {
|
|
2554
|
+
const owner = this;
|
|
2555
|
+
return cacheGeneratorMethod(owner, "isContextSensitive", function (node) {
|
|
2556
|
+
return owner.client.apiRequest("isContextSensitive", {
|
|
2557
|
+
snapshot: owner.snapshotId,
|
|
2558
|
+
project: owner.project.id,
|
|
2559
|
+
location: getNodeId(node),
|
|
2560
|
+
});
|
|
2561
|
+
}, function* (node) {
|
|
2562
|
+
return yield* apiRequest("isContextSensitive", {
|
|
2563
|
+
snapshot: owner.snapshotId,
|
|
2564
|
+
project: owner.project.id,
|
|
2565
|
+
location: getNodeId(node),
|
|
2566
|
+
});
|
|
1362
2567
|
});
|
|
1363
|
-
if (typeof result !== "string")
|
|
1364
|
-
throw new TypeError("typeToString returned a non-string result");
|
|
1365
|
-
return result;
|
|
1366
2568
|
}
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
2569
|
+
get isArrayType() {
|
|
2570
|
+
const owner = this;
|
|
2571
|
+
return cacheGeneratorMethod(owner, "isArrayType", function (type) {
|
|
2572
|
+
return owner.client.apiRequest("isArrayType", {
|
|
2573
|
+
snapshot: owner.snapshotId,
|
|
2574
|
+
project: owner.project.id,
|
|
2575
|
+
type: type.id,
|
|
2576
|
+
});
|
|
2577
|
+
}, function* (type) {
|
|
2578
|
+
return yield* apiRequest("isArrayType", {
|
|
2579
|
+
snapshot: owner.snapshotId,
|
|
2580
|
+
project: owner.project.id,
|
|
2581
|
+
type: type.id,
|
|
2582
|
+
});
|
|
1372
2583
|
});
|
|
1373
2584
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
2585
|
+
get isTupleType() {
|
|
2586
|
+
const owner = this;
|
|
2587
|
+
return cacheGeneratorMethod(owner, "isTupleType", function (type) {
|
|
2588
|
+
return owner.client.apiRequest("isTupleType", {
|
|
2589
|
+
snapshot: owner.snapshotId,
|
|
2590
|
+
project: owner.project.id,
|
|
2591
|
+
type: type.id,
|
|
2592
|
+
});
|
|
2593
|
+
}, function* (type) {
|
|
2594
|
+
return yield* apiRequest("isTupleType", {
|
|
2595
|
+
snapshot: owner.snapshotId,
|
|
2596
|
+
project: owner.project.id,
|
|
2597
|
+
type: type.id,
|
|
2598
|
+
});
|
|
1379
2599
|
});
|
|
1380
2600
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
2601
|
+
/**
|
|
2602
|
+
* The following symbols are considered read-only:
|
|
2603
|
+
* - Properties with a `readonly` modifier
|
|
2604
|
+
* - Variables declared with `const`
|
|
2605
|
+
* - Get accessors without matching set accessors
|
|
2606
|
+
* - Enum members
|
|
2607
|
+
* - `Object.defineProperty` assignments with `writable: false` or no setter
|
|
2608
|
+
* - Unions and intersections of the above
|
|
2609
|
+
*/
|
|
2610
|
+
get isReadonlySymbol() {
|
|
2611
|
+
const owner = this;
|
|
2612
|
+
return cacheGeneratorMethod(owner, "isReadonlySymbol", function (symbol) {
|
|
2613
|
+
return owner.client.apiRequest("isReadonlySymbol", {
|
|
2614
|
+
snapshot: owner.snapshotId,
|
|
2615
|
+
project: owner.project.id,
|
|
2616
|
+
symbol: symbol.id,
|
|
2617
|
+
});
|
|
2618
|
+
}, function* (symbol) {
|
|
2619
|
+
return yield* apiRequest("isReadonlySymbol", {
|
|
2620
|
+
snapshot: owner.snapshotId,
|
|
2621
|
+
project: owner.project.id,
|
|
2622
|
+
symbol: symbol.id,
|
|
2623
|
+
});
|
|
1386
2624
|
});
|
|
1387
2625
|
}
|
|
1388
2626
|
/** Get the return type of a signature. Always returns a type. */
|
|
1389
|
-
getReturnTypeOfSignature(
|
|
1390
|
-
|
|
2627
|
+
get getReturnTypeOfSignature() {
|
|
2628
|
+
const owner = this;
|
|
2629
|
+
return cacheGeneratorMethod(owner, "getReturnTypeOfSignature", function (signature) {
|
|
2630
|
+
return signature.getReturnType();
|
|
2631
|
+
}, function* (signature) {
|
|
2632
|
+
return yield* signature.getReturnType.gen();
|
|
2633
|
+
});
|
|
1391
2634
|
}
|
|
1392
2635
|
/**
|
|
1393
2636
|
* Get the rest type of a signature. Always returns a type; a signature with
|
|
1394
2637
|
* no rest parameter yields the `any` type.
|
|
1395
2638
|
*/
|
|
1396
|
-
getRestTypeOfSignature(
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
return
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
2639
|
+
get getRestTypeOfSignature() {
|
|
2640
|
+
const owner = this;
|
|
2641
|
+
return cacheGeneratorMethod(owner, "getRestTypeOfSignature", function (signature) {
|
|
2642
|
+
const data = owner.client.apiRequest("getRestTypeOfSignature", {
|
|
2643
|
+
snapshot: owner.snapshotId,
|
|
2644
|
+
project: owner.project.id,
|
|
2645
|
+
signature: signature.id,
|
|
2646
|
+
});
|
|
2647
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
2648
|
+
}, function* (signature) {
|
|
2649
|
+
const data = yield* apiRequest("getRestTypeOfSignature", {
|
|
2650
|
+
snapshot: owner.snapshotId,
|
|
2651
|
+
project: owner.project.id,
|
|
2652
|
+
signature: signature.id,
|
|
2653
|
+
});
|
|
2654
|
+
return owner.objectRegistry.getOrCreateType(data);
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
get getTypePredicateOfSignature() {
|
|
2658
|
+
const owner = this;
|
|
2659
|
+
return cacheGeneratorMethod(owner, "getTypePredicateOfSignature", function (signature) {
|
|
2660
|
+
const data = owner.client.apiRequest("getTypePredicateOfSignature", {
|
|
2661
|
+
snapshot: owner.snapshotId,
|
|
2662
|
+
project: owner.project.id,
|
|
2663
|
+
signature: signature.id,
|
|
2664
|
+
});
|
|
2665
|
+
if (!data)
|
|
2666
|
+
return undefined;
|
|
2667
|
+
return {
|
|
2668
|
+
kind: data.kind,
|
|
2669
|
+
parameterIndex: data.parameterIndex,
|
|
2670
|
+
parameterName: data.parameterName,
|
|
2671
|
+
type: data.type ? owner.objectRegistry.getOrCreateType(data.type) : undefined,
|
|
2672
|
+
};
|
|
2673
|
+
}, function* (signature) {
|
|
2674
|
+
const data = yield* apiRequest("getTypePredicateOfSignature", {
|
|
2675
|
+
snapshot: owner.snapshotId,
|
|
2676
|
+
project: owner.project.id,
|
|
2677
|
+
signature: signature.id,
|
|
2678
|
+
});
|
|
2679
|
+
if (!data)
|
|
2680
|
+
return undefined;
|
|
2681
|
+
return {
|
|
2682
|
+
kind: data.kind,
|
|
2683
|
+
parameterIndex: data.parameterIndex,
|
|
2684
|
+
parameterName: data.parameterName,
|
|
2685
|
+
type: data.type ? owner.objectRegistry.getOrCreateType(data.type) : undefined,
|
|
2686
|
+
};
|
|
2687
|
+
});
|
|
1418
2688
|
}
|
|
1419
2689
|
/**
|
|
1420
2690
|
* Get the base types of a class or interface type. A type with no base types
|
|
1421
2691
|
* yields an empty array.
|
|
1422
2692
|
*/
|
|
1423
|
-
getBaseTypes(
|
|
1424
|
-
|
|
2693
|
+
get getBaseTypes() {
|
|
2694
|
+
const owner = this;
|
|
2695
|
+
return cacheGeneratorMethod(owner, "getBaseTypes", function (type) {
|
|
2696
|
+
return type.getBaseTypes() ?? [];
|
|
2697
|
+
}, function* (type) {
|
|
2698
|
+
return (yield* type.getBaseTypes.gen()) ?? [];
|
|
2699
|
+
});
|
|
1425
2700
|
}
|
|
1426
2701
|
/** Get the apparent type of a type. Always returns a type. */
|
|
1427
|
-
getApparentType(
|
|
1428
|
-
|
|
2702
|
+
get getApparentType() {
|
|
2703
|
+
const owner = this;
|
|
2704
|
+
return cacheGeneratorMethod(owner, "getApparentType", function (type) {
|
|
2705
|
+
return type.getApparentType();
|
|
2706
|
+
}, function* (type) {
|
|
2707
|
+
return yield* type.getApparentType.gen();
|
|
2708
|
+
});
|
|
1429
2709
|
}
|
|
1430
2710
|
/** Get the reduced type of a type. Always returns a type. */
|
|
1431
|
-
getReducedType(
|
|
1432
|
-
|
|
2711
|
+
get getReducedType() {
|
|
2712
|
+
const owner = this;
|
|
2713
|
+
return cacheGeneratorMethod(owner, "getReducedType", function (type) {
|
|
2714
|
+
return type.getReducedType();
|
|
2715
|
+
}, function* (type) {
|
|
2716
|
+
return yield* type.getReducedType.gen();
|
|
2717
|
+
});
|
|
1433
2718
|
}
|
|
1434
|
-
getPropertiesOfType(
|
|
1435
|
-
|
|
2719
|
+
get getPropertiesOfType() {
|
|
2720
|
+
const owner = this;
|
|
2721
|
+
return cacheGeneratorMethod(owner, "getPropertiesOfType", function (type) {
|
|
2722
|
+
return type.getProperties();
|
|
2723
|
+
}, function* (type) {
|
|
2724
|
+
return yield* type.getProperties.gen();
|
|
2725
|
+
});
|
|
1436
2726
|
}
|
|
1437
|
-
getIndexInfosOfType(
|
|
1438
|
-
|
|
2727
|
+
get getIndexInfosOfType() {
|
|
2728
|
+
const owner = this;
|
|
2729
|
+
return cacheGeneratorMethod(owner, "getIndexInfosOfType", function (type) {
|
|
2730
|
+
return type.getIndexInfos();
|
|
2731
|
+
}, function* (type) {
|
|
2732
|
+
return yield* type.getIndexInfos.gen();
|
|
2733
|
+
});
|
|
1439
2734
|
}
|
|
1440
2735
|
/**
|
|
1441
2736
|
* Get the constraint of a type parameter (the `T` in `<U extends T>`), or
|
|
1442
2737
|
* undefined if it has none.
|
|
1443
2738
|
*/
|
|
1444
|
-
getConstraintOfTypeParameter(
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
2739
|
+
get getConstraintOfTypeParameter() {
|
|
2740
|
+
const owner = this;
|
|
2741
|
+
return cacheGeneratorMethod(owner, "getConstraintOfTypeParameter", function (type) {
|
|
2742
|
+
return type.getConstraint();
|
|
2743
|
+
}, function* (type) {
|
|
2744
|
+
return yield* type.getConstraint.gen();
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
get getDefaultFromTypeParameter() {
|
|
2748
|
+
const owner = this;
|
|
2749
|
+
return cacheGeneratorMethod(owner, "getDefaultFromTypeParameter", function (type) {
|
|
2750
|
+
return type.getDefault();
|
|
2751
|
+
}, function* (type) {
|
|
2752
|
+
return yield* type.getDefault.gen();
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2755
|
+
get getBaseConstraintOfType() {
|
|
2756
|
+
const owner = this;
|
|
2757
|
+
return cacheGeneratorMethod(owner, "getBaseConstraintOfType", function (type) {
|
|
2758
|
+
const data = owner.client.apiRequest("getBaseConstraintOfType", {
|
|
2759
|
+
snapshot: owner.snapshotId,
|
|
2760
|
+
project: owner.project.id,
|
|
2761
|
+
type: type.id,
|
|
2762
|
+
});
|
|
2763
|
+
return data ? owner.objectRegistry.getOrCreateType(data) : undefined;
|
|
2764
|
+
}, function* (type) {
|
|
2765
|
+
const data = yield* apiRequest("getBaseConstraintOfType", {
|
|
2766
|
+
snapshot: owner.snapshotId,
|
|
2767
|
+
project: owner.project.id,
|
|
2768
|
+
type: type.id,
|
|
2769
|
+
});
|
|
2770
|
+
return data ? owner.objectRegistry.getOrCreateType(data) : undefined;
|
|
1455
2771
|
});
|
|
1456
|
-
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
1457
2772
|
}
|
|
1458
|
-
getPropertyOfType(
|
|
1459
|
-
const
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
2773
|
+
get getPropertyOfType() {
|
|
2774
|
+
const owner = this;
|
|
2775
|
+
return cacheGeneratorMethod(owner, "getPropertyOfType", function (type, name) {
|
|
2776
|
+
const data = owner.client.apiRequest("getPropertyOfType", {
|
|
2777
|
+
snapshot: owner.snapshotId,
|
|
2778
|
+
project: owner.project.id,
|
|
2779
|
+
type: type.id,
|
|
2780
|
+
name,
|
|
2781
|
+
});
|
|
2782
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
2783
|
+
}, function* (type, name) {
|
|
2784
|
+
const data = yield* apiRequest("getPropertyOfType", {
|
|
2785
|
+
snapshot: owner.snapshotId,
|
|
2786
|
+
project: owner.project.id,
|
|
2787
|
+
type: type.id,
|
|
2788
|
+
name,
|
|
2789
|
+
});
|
|
2790
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1464
2791
|
});
|
|
1465
|
-
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1466
2792
|
}
|
|
1467
|
-
getConstantValue(
|
|
1468
|
-
const
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
2793
|
+
get getConstantValue() {
|
|
2794
|
+
const owner = this;
|
|
2795
|
+
return cacheGeneratorMethod(owner, "getConstantValue", function (node) {
|
|
2796
|
+
const data = owner.client.apiRequest("getConstantValue", {
|
|
2797
|
+
snapshot: owner.snapshotId,
|
|
2798
|
+
project: owner.project.id,
|
|
2799
|
+
location: getNodeId(node),
|
|
2800
|
+
});
|
|
2801
|
+
return typeof data === "string" || typeof data === "number" ? data : undefined;
|
|
2802
|
+
}, function* (node) {
|
|
2803
|
+
const data = yield* apiRequest("getConstantValue", {
|
|
2804
|
+
snapshot: owner.snapshotId,
|
|
2805
|
+
project: owner.project.id,
|
|
2806
|
+
location: getNodeId(node),
|
|
2807
|
+
});
|
|
2808
|
+
return typeof data === "string" || typeof data === "number" ? data : undefined;
|
|
1472
2809
|
});
|
|
1473
|
-
return typeof data === "string" || typeof data === "number" ? data : undefined;
|
|
1474
2810
|
}
|
|
1475
2811
|
/** Get the signature of a function-like declaration. Always returns a signature. */
|
|
1476
|
-
getSignatureFromDeclaration(
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
2812
|
+
get getSignatureFromDeclaration() {
|
|
2813
|
+
const owner = this;
|
|
2814
|
+
return cacheGeneratorMethod(owner, "getSignatureFromDeclaration", function (node) {
|
|
2815
|
+
const data = owner.client.apiRequest("getSignatureFromDeclaration", {
|
|
2816
|
+
snapshot: owner.snapshotId,
|
|
2817
|
+
project: owner.project.id,
|
|
2818
|
+
location: getNodeId(node),
|
|
2819
|
+
});
|
|
2820
|
+
return owner.objectRegistry.getOrCreateSignature(data);
|
|
2821
|
+
}, function* (node) {
|
|
2822
|
+
const data = yield* apiRequest("getSignatureFromDeclaration", {
|
|
2823
|
+
snapshot: owner.snapshotId,
|
|
2824
|
+
project: owner.project.id,
|
|
2825
|
+
location: getNodeId(node),
|
|
2826
|
+
});
|
|
2827
|
+
return owner.objectRegistry.getOrCreateSignature(data);
|
|
1481
2828
|
});
|
|
1482
|
-
return this.objectRegistry.getOrCreateSignature(data);
|
|
1483
2829
|
}
|
|
1484
|
-
getExportSpecifierLocalTargetSymbol(
|
|
1485
|
-
const
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
2830
|
+
get getExportSpecifierLocalTargetSymbol() {
|
|
2831
|
+
const owner = this;
|
|
2832
|
+
return cacheGeneratorMethod(owner, "getExportSpecifierLocalTargetSymbol", function (node) {
|
|
2833
|
+
const data = owner.client.apiRequest("getExportSpecifierLocalTargetSymbol", {
|
|
2834
|
+
snapshot: owner.snapshotId,
|
|
2835
|
+
project: owner.project.id,
|
|
2836
|
+
location: getNodeId(node),
|
|
2837
|
+
});
|
|
2838
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
2839
|
+
}, function* (node) {
|
|
2840
|
+
const data = yield* apiRequest("getExportSpecifierLocalTargetSymbol", {
|
|
2841
|
+
snapshot: owner.snapshotId,
|
|
2842
|
+
project: owner.project.id,
|
|
2843
|
+
location: getNodeId(node),
|
|
2844
|
+
});
|
|
2845
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1489
2846
|
});
|
|
1490
|
-
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1491
2847
|
}
|
|
1492
2848
|
/**
|
|
1493
2849
|
* Follow all aliases to get the original symbol. Always returns a symbol; for
|
|
1494
2850
|
* an unresolved alias the checker yields the unknown symbol (use
|
|
1495
2851
|
* {@link Checker.isUnknownSymbol} to detect it).
|
|
1496
2852
|
*/
|
|
1497
|
-
getAliasedSymbol(
|
|
1498
|
-
const
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
2853
|
+
get getAliasedSymbol() {
|
|
2854
|
+
const owner = this;
|
|
2855
|
+
return cacheGeneratorMethod(owner, "getAliasedSymbol", function (symbol) {
|
|
2856
|
+
const data = owner.client.apiRequest("getAliasedSymbol", {
|
|
2857
|
+
snapshot: owner.snapshotId,
|
|
2858
|
+
project: owner.project.id,
|
|
2859
|
+
symbol: symbol.id,
|
|
2860
|
+
});
|
|
2861
|
+
return owner.objectRegistry.getOrCreateSymbol(data);
|
|
2862
|
+
}, function* (symbol) {
|
|
2863
|
+
const data = yield* apiRequest("getAliasedSymbol", {
|
|
2864
|
+
snapshot: owner.snapshotId,
|
|
2865
|
+
project: owner.project.id,
|
|
2866
|
+
symbol: symbol.id,
|
|
2867
|
+
});
|
|
2868
|
+
return owner.objectRegistry.getOrCreateSymbol(data);
|
|
1502
2869
|
});
|
|
1503
|
-
return this.objectRegistry.getOrCreateSymbol(data);
|
|
1504
2870
|
}
|
|
1505
2871
|
/**
|
|
1506
2872
|
* Get the fully qualified name of a symbol, walking up its parent chain
|
|
1507
2873
|
* (e.g. `"/path/to/module".Namespace.Name`).
|
|
1508
2874
|
*/
|
|
1509
|
-
getFullyQualifiedName(
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
2875
|
+
get getFullyQualifiedName() {
|
|
2876
|
+
const owner = this;
|
|
2877
|
+
return cacheGeneratorMethod(owner, "getFullyQualifiedName", function (symbol) {
|
|
2878
|
+
return owner.client.apiRequest("getFullyQualifiedName", {
|
|
2879
|
+
snapshot: owner.snapshotId,
|
|
2880
|
+
project: owner.project.id,
|
|
2881
|
+
symbol: symbol.id,
|
|
2882
|
+
});
|
|
2883
|
+
}, function* (symbol) {
|
|
2884
|
+
return yield* apiRequest("getFullyQualifiedName", {
|
|
2885
|
+
snapshot: owner.snapshotId,
|
|
2886
|
+
project: owner.project.id,
|
|
2887
|
+
symbol: symbol.id,
|
|
2888
|
+
});
|
|
2889
|
+
});
|
|
2890
|
+
}
|
|
2891
|
+
get getImmediateAliasedSymbol() {
|
|
2892
|
+
const owner = this;
|
|
2893
|
+
return cacheGeneratorMethod(owner, "getImmediateAliasedSymbol", function (symbol) {
|
|
2894
|
+
const data = owner.client.apiRequest("getImmediateAliasedSymbol", {
|
|
2895
|
+
snapshot: owner.snapshotId,
|
|
2896
|
+
project: owner.project.id,
|
|
2897
|
+
symbol: symbol.id,
|
|
2898
|
+
});
|
|
2899
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
2900
|
+
}, function* (symbol) {
|
|
2901
|
+
const data = yield* apiRequest("getImmediateAliasedSymbol", {
|
|
2902
|
+
snapshot: owner.snapshotId,
|
|
2903
|
+
project: owner.project.id,
|
|
2904
|
+
symbol: symbol.id,
|
|
2905
|
+
});
|
|
2906
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1514
2907
|
});
|
|
1515
2908
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
2909
|
+
/**
|
|
2910
|
+
* Get the target symbol if instantiated, or the provided symbol otherwise.
|
|
2911
|
+
*/
|
|
2912
|
+
get getTargetSymbol() {
|
|
2913
|
+
const owner = this;
|
|
2914
|
+
return cacheGeneratorMethod(owner, "getTargetSymbol", function (symbol) {
|
|
2915
|
+
if (symbol.checkFlags & CheckFlags.Instantiated) {
|
|
2916
|
+
const data = owner.client.apiRequest("getTargetSymbol", {
|
|
2917
|
+
snapshot: owner.snapshotId,
|
|
2918
|
+
project: owner.project.id,
|
|
2919
|
+
symbol: symbol.id,
|
|
2920
|
+
});
|
|
2921
|
+
return owner.objectRegistry.getOrCreateSymbol(data);
|
|
2922
|
+
}
|
|
2923
|
+
return symbol;
|
|
2924
|
+
}, function* (symbol) {
|
|
2925
|
+
if (symbol.checkFlags & CheckFlags.Instantiated) {
|
|
2926
|
+
const data = yield* apiRequest("getTargetSymbol", {
|
|
2927
|
+
snapshot: owner.snapshotId,
|
|
2928
|
+
project: owner.project.id,
|
|
2929
|
+
symbol: symbol.id,
|
|
2930
|
+
});
|
|
2931
|
+
return owner.objectRegistry.getOrCreateSymbol(data);
|
|
2932
|
+
}
|
|
2933
|
+
return symbol;
|
|
1521
2934
|
});
|
|
1522
|
-
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1523
2935
|
}
|
|
1524
2936
|
/**
|
|
1525
2937
|
* Fetch (once, then cache) the handle ids of the per-checker singleton
|
|
@@ -1527,40 +2939,71 @@ export class Checker {
|
|
|
1527
2939
|
* of the project's checker, so identity checks against them are local after
|
|
1528
2940
|
* the first call.
|
|
1529
2941
|
*/
|
|
1530
|
-
getWellKnownSymbols() {
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
2942
|
+
get getWellKnownSymbols() {
|
|
2943
|
+
const owner = this;
|
|
2944
|
+
return cacheGeneratorMethod(owner, "getWellKnownSymbols", function () {
|
|
2945
|
+
return owner.wellKnownSymbols ??= owner.client.apiRequest("getWellKnownSymbols", {
|
|
2946
|
+
snapshot: owner.snapshotId,
|
|
2947
|
+
project: owner.project.id,
|
|
2948
|
+
});
|
|
2949
|
+
}, function* () {
|
|
2950
|
+
return owner.wellKnownSymbols ??= yield* apiRequest("getWellKnownSymbols", {
|
|
2951
|
+
snapshot: owner.snapshotId,
|
|
2952
|
+
project: owner.project.id,
|
|
2953
|
+
});
|
|
1534
2954
|
});
|
|
1535
2955
|
}
|
|
1536
2956
|
/**
|
|
1537
2957
|
* Returns `true` if the symbol is the checker's "unknown" symbol (e.g. the
|
|
1538
2958
|
* result of {@link Checker.getAliasedSymbol} on an unresolved alias).
|
|
1539
2959
|
*/
|
|
1540
|
-
isUnknownSymbol(
|
|
1541
|
-
|
|
2960
|
+
get isUnknownSymbol() {
|
|
2961
|
+
const owner = this;
|
|
2962
|
+
return cacheGeneratorMethod(owner, "isUnknownSymbol", function (symbol) {
|
|
2963
|
+
return symbol.id === (owner.getWellKnownSymbols()).unknown;
|
|
2964
|
+
}, function* (symbol) {
|
|
2965
|
+
return symbol.id === (yield* owner.getWellKnownSymbols.gen()).unknown;
|
|
2966
|
+
});
|
|
1542
2967
|
}
|
|
1543
2968
|
/**
|
|
1544
2969
|
* Returns `true` if the symbol is the checker's "undefined" symbol.
|
|
1545
2970
|
*/
|
|
1546
|
-
isUndefinedSymbol(
|
|
1547
|
-
|
|
2971
|
+
get isUndefinedSymbol() {
|
|
2972
|
+
const owner = this;
|
|
2973
|
+
return cacheGeneratorMethod(owner, "isUndefinedSymbol", function (symbol) {
|
|
2974
|
+
return symbol.id === (owner.getWellKnownSymbols()).undefined;
|
|
2975
|
+
}, function* (symbol) {
|
|
2976
|
+
return symbol.id === (yield* owner.getWellKnownSymbols.gen()).undefined;
|
|
2977
|
+
});
|
|
1548
2978
|
}
|
|
1549
2979
|
/**
|
|
1550
2980
|
* Returns `true` if the symbol is the checker's "arguments" symbol.
|
|
1551
2981
|
*/
|
|
1552
|
-
isArgumentsSymbol(
|
|
1553
|
-
|
|
2982
|
+
get isArgumentsSymbol() {
|
|
2983
|
+
const owner = this;
|
|
2984
|
+
return cacheGeneratorMethod(owner, "isArgumentsSymbol", function (symbol) {
|
|
2985
|
+
return symbol.id === (owner.getWellKnownSymbols()).arguments;
|
|
2986
|
+
}, function* (symbol) {
|
|
2987
|
+
return symbol.id === (yield* owner.getWellKnownSymbols.gen()).arguments;
|
|
2988
|
+
});
|
|
1554
2989
|
}
|
|
1555
2990
|
/**
|
|
1556
2991
|
* Fetch (once, then cache) the handle id of the per-checker unknown
|
|
1557
2992
|
* signature. This id is stable for the life of the project's checker, so
|
|
1558
2993
|
* identity checks against it are local after the first call.
|
|
1559
2994
|
*/
|
|
1560
|
-
getWellKnownSignatures() {
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
2995
|
+
get getWellKnownSignatures() {
|
|
2996
|
+
const owner = this;
|
|
2997
|
+
return cacheGeneratorMethod(owner, "getWellKnownSignatures", function () {
|
|
2998
|
+
return owner.wellKnownSignatures ??= owner.client.apiRequest("getWellKnownSignatures", {
|
|
2999
|
+
snapshot: owner.snapshotId,
|
|
3000
|
+
project: owner.project.id,
|
|
3001
|
+
});
|
|
3002
|
+
}, function* () {
|
|
3003
|
+
return owner.wellKnownSignatures ??= yield* apiRequest("getWellKnownSignatures", {
|
|
3004
|
+
snapshot: owner.snapshotId,
|
|
3005
|
+
project: owner.project.id,
|
|
3006
|
+
});
|
|
1564
3007
|
});
|
|
1565
3008
|
}
|
|
1566
3009
|
/**
|
|
@@ -1568,51 +3011,106 @@ export class Checker {
|
|
|
1568
3011
|
* the result of {@link Checker.getResolvedSignature} on a call that cannot be
|
|
1569
3012
|
* resolved).
|
|
1570
3013
|
*/
|
|
1571
|
-
isUnknownSignature(
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
3014
|
+
get isUnknownSignature() {
|
|
3015
|
+
const owner = this;
|
|
3016
|
+
return cacheGeneratorMethod(owner, "isUnknownSignature", function (signature) {
|
|
3017
|
+
return signature.id === (owner.getWellKnownSignatures()).unknown;
|
|
3018
|
+
}, function* (signature) {
|
|
3019
|
+
return signature.id === (yield* owner.getWellKnownSignatures.gen()).unknown;
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
3022
|
+
get getExportsOfModule() {
|
|
3023
|
+
const owner = this;
|
|
3024
|
+
return cacheGeneratorMethod(owner, "getExportsOfModule", function (symbol) {
|
|
3025
|
+
const data = owner.client.apiRequest("getExportsOfModule", {
|
|
3026
|
+
snapshot: owner.snapshotId,
|
|
3027
|
+
project: owner.project.id,
|
|
3028
|
+
symbol: symbol.id,
|
|
3029
|
+
});
|
|
3030
|
+
return data ? data.map(d => owner.objectRegistry.getOrCreateSymbol(d)) : [];
|
|
3031
|
+
}, function* (symbol) {
|
|
3032
|
+
const data = yield* apiRequest("getExportsOfModule", {
|
|
3033
|
+
snapshot: owner.snapshotId,
|
|
3034
|
+
project: owner.project.id,
|
|
3035
|
+
symbol: symbol.id,
|
|
3036
|
+
});
|
|
3037
|
+
return data ? data.map(d => owner.objectRegistry.getOrCreateSymbol(d)) : [];
|
|
1579
3038
|
});
|
|
1580
|
-
return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
|
|
1581
3039
|
}
|
|
1582
|
-
getMemberInModuleExports(
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
3040
|
+
get getMemberInModuleExports() {
|
|
3041
|
+
const owner = this;
|
|
3042
|
+
return cacheGeneratorMethod(owner, "getMemberInModuleExports", function (symbol, name) {
|
|
3043
|
+
const data = owner.client.apiRequest("getMemberInModuleExports", {
|
|
3044
|
+
snapshot: owner.snapshotId,
|
|
3045
|
+
project: owner.project.id,
|
|
3046
|
+
symbol: symbol.id,
|
|
3047
|
+
name,
|
|
3048
|
+
});
|
|
3049
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
3050
|
+
}, function* (symbol, name) {
|
|
3051
|
+
const data = yield* apiRequest("getMemberInModuleExports", {
|
|
3052
|
+
snapshot: owner.snapshotId,
|
|
3053
|
+
project: owner.project.id,
|
|
3054
|
+
symbol: symbol.id,
|
|
3055
|
+
name,
|
|
3056
|
+
});
|
|
3057
|
+
return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1588
3058
|
});
|
|
1589
|
-
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
1590
3059
|
}
|
|
1591
|
-
getJsDocTagsOfSymbol(
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
3060
|
+
get getJsDocTagsOfSymbol() {
|
|
3061
|
+
const owner = this;
|
|
3062
|
+
return cacheGeneratorMethod(owner, "getJsDocTagsOfSymbol", function (symbol) {
|
|
3063
|
+
const data = owner.client.apiRequest("getJsDocTags", {
|
|
3064
|
+
snapshot: owner.snapshotId,
|
|
3065
|
+
project: owner.project.id,
|
|
3066
|
+
symbol: symbol.id,
|
|
3067
|
+
});
|
|
3068
|
+
return data ?? [];
|
|
3069
|
+
}, function* (symbol) {
|
|
3070
|
+
const data = yield* apiRequest("getJsDocTags", {
|
|
3071
|
+
snapshot: owner.snapshotId,
|
|
3072
|
+
project: owner.project.id,
|
|
3073
|
+
symbol: symbol.id,
|
|
3074
|
+
});
|
|
3075
|
+
return data ?? [];
|
|
1596
3076
|
});
|
|
1597
|
-
return data ?? [];
|
|
1598
3077
|
}
|
|
1599
|
-
getDocumentationCommentOfSymbol(
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
3078
|
+
get getDocumentationCommentOfSymbol() {
|
|
3079
|
+
const owner = this;
|
|
3080
|
+
return cacheGeneratorMethod(owner, "getDocumentationCommentOfSymbol", function (symbol) {
|
|
3081
|
+
return owner.client.apiRequest("getDocumentationComment", {
|
|
3082
|
+
snapshot: owner.snapshotId,
|
|
3083
|
+
project: owner.project.id,
|
|
3084
|
+
symbol: symbol.id,
|
|
3085
|
+
});
|
|
3086
|
+
}, function* (symbol) {
|
|
3087
|
+
return yield* apiRequest("getDocumentationComment", {
|
|
3088
|
+
snapshot: owner.snapshotId,
|
|
3089
|
+
project: owner.project.id,
|
|
3090
|
+
symbol: symbol.id,
|
|
3091
|
+
});
|
|
1604
3092
|
});
|
|
1605
3093
|
}
|
|
1606
3094
|
/**
|
|
1607
3095
|
* Get the type arguments of a type reference (e.g. the `string` in `Array<string>`).
|
|
1608
3096
|
*/
|
|
1609
|
-
getTypeArguments(
|
|
1610
|
-
const
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
3097
|
+
get getTypeArguments() {
|
|
3098
|
+
const owner = this;
|
|
3099
|
+
return cacheGeneratorMethod(owner, "getTypeArguments", function (type) {
|
|
3100
|
+
const data = owner.client.apiRequest("getTypeArguments", {
|
|
3101
|
+
snapshot: owner.snapshotId,
|
|
3102
|
+
project: owner.project.id,
|
|
3103
|
+
type: type.id,
|
|
3104
|
+
});
|
|
3105
|
+
return data ? data.map(d => owner.objectRegistry.getOrCreateType(d)) : [];
|
|
3106
|
+
}, function* (type) {
|
|
3107
|
+
const data = yield* apiRequest("getTypeArguments", {
|
|
3108
|
+
snapshot: owner.snapshotId,
|
|
3109
|
+
project: owner.project.id,
|
|
3110
|
+
type: type.id,
|
|
3111
|
+
});
|
|
3112
|
+
return data ? data.map(d => owner.objectRegistry.getOrCreateType(d)) : [];
|
|
1614
3113
|
});
|
|
1615
|
-
return data ? data.map(d => this.objectRegistry.getOrCreateType(d)) : [];
|
|
1616
3114
|
}
|
|
1617
3115
|
}
|
|
1618
3116
|
export class Emitter {
|
|
@@ -1620,14 +3118,26 @@ export class Emitter {
|
|
|
1620
3118
|
constructor(client) {
|
|
1621
3119
|
this.client = client;
|
|
1622
3120
|
}
|
|
1623
|
-
printNode(
|
|
1624
|
-
const
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
3121
|
+
get printNode() {
|
|
3122
|
+
const owner = this;
|
|
3123
|
+
return cacheGeneratorMethod(owner, "printNode", function (node, options = {}) {
|
|
3124
|
+
const encoded = encodeNode(node);
|
|
3125
|
+
const base64 = uint8ArrayToBase64(encoded);
|
|
3126
|
+
return owner.client.apiRequest("printNode", {
|
|
3127
|
+
data: base64,
|
|
3128
|
+
...(options.preserveSourceNewlines !== undefined ? { preserveSourceNewlines: options.preserveSourceNewlines } : {}),
|
|
3129
|
+
...(options.neverAsciiEscape !== undefined ? { neverAsciiEscape: options.neverAsciiEscape } : {}),
|
|
3130
|
+
...(options.terminateUnterminatedLiterals !== undefined ? { terminateUnterminatedLiterals: options.terminateUnterminatedLiterals } : {}),
|
|
3131
|
+
});
|
|
3132
|
+
}, function* (node, options = {}) {
|
|
3133
|
+
const encoded = encodeNode(node);
|
|
3134
|
+
const base64 = uint8ArrayToBase64(encoded);
|
|
3135
|
+
return yield* apiRequest("printNode", {
|
|
3136
|
+
data: base64,
|
|
3137
|
+
...(options.preserveSourceNewlines !== undefined ? { preserveSourceNewlines: options.preserveSourceNewlines } : {}),
|
|
3138
|
+
...(options.neverAsciiEscape !== undefined ? { neverAsciiEscape: options.neverAsciiEscape } : {}),
|
|
3139
|
+
...(options.terminateUnterminatedLiterals !== undefined ? { terminateUnterminatedLiterals: options.terminateUnterminatedLiterals } : {}),
|
|
3140
|
+
});
|
|
1631
3141
|
});
|
|
1632
3142
|
}
|
|
1633
3143
|
}
|
|
@@ -1647,22 +3157,42 @@ export class SnapshotInternalAPI {
|
|
|
1647
3157
|
* @param position The UTF-16 code-unit offset in the target file for insertion.
|
|
1648
3158
|
* @returns The formatted text of the node, indented for the insertion position.
|
|
1649
3159
|
*/
|
|
1650
|
-
formatNodeForInsertion(
|
|
1651
|
-
const
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
3160
|
+
get formatNodeForInsertion() {
|
|
3161
|
+
const owner = this;
|
|
3162
|
+
return cacheGeneratorMethod(owner, "formatNodeForInsertion", function (node, file, position) {
|
|
3163
|
+
const data = owner.client.apiRequest("getDefaultProjectForFile", {
|
|
3164
|
+
snapshot: owner.snapshotId,
|
|
3165
|
+
file,
|
|
3166
|
+
});
|
|
3167
|
+
if (!data) {
|
|
3168
|
+
throw new Error(`No project found for file: ${typeof file === "string" ? file : file.uri}`);
|
|
3169
|
+
}
|
|
3170
|
+
const encoded = encodeNode(node);
|
|
3171
|
+
const base64 = uint8ArrayToBase64(encoded);
|
|
3172
|
+
return owner.client.apiRequest("formatNodeForInsertion", {
|
|
3173
|
+
snapshot: owner.snapshotId,
|
|
3174
|
+
project: data.id,
|
|
3175
|
+
file,
|
|
3176
|
+
position,
|
|
3177
|
+
data: base64,
|
|
3178
|
+
});
|
|
3179
|
+
}, function* (node, file, position) {
|
|
3180
|
+
const data = yield* apiRequest("getDefaultProjectForFile", {
|
|
3181
|
+
snapshot: owner.snapshotId,
|
|
3182
|
+
file,
|
|
3183
|
+
});
|
|
3184
|
+
if (!data) {
|
|
3185
|
+
throw new Error(`No project found for file: ${typeof file === "string" ? file : file.uri}`);
|
|
3186
|
+
}
|
|
3187
|
+
const encoded = encodeNode(node);
|
|
3188
|
+
const base64 = uint8ArrayToBase64(encoded);
|
|
3189
|
+
return yield* apiRequest("formatNodeForInsertion", {
|
|
3190
|
+
snapshot: owner.snapshotId,
|
|
3191
|
+
project: data.id,
|
|
3192
|
+
file,
|
|
3193
|
+
position,
|
|
3194
|
+
data: base64,
|
|
3195
|
+
});
|
|
1666
3196
|
});
|
|
1667
3197
|
}
|
|
1668
3198
|
}
|
|
@@ -1688,12 +3218,21 @@ export class NodeHandle {
|
|
|
1688
3218
|
* and looking up the node by index. If no project is passed, the project that produced
|
|
1689
3219
|
* the handle is used.
|
|
1690
3220
|
*/
|
|
1691
|
-
resolve(
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
3221
|
+
get resolve() {
|
|
3222
|
+
const owner = this;
|
|
3223
|
+
return cacheGeneratorMethod(owner, "resolve", function (project = owner.canonicalProject) {
|
|
3224
|
+
const sourceFile = project.program.getSourceFile(owner.path);
|
|
3225
|
+
if (!sourceFile) {
|
|
3226
|
+
return undefined;
|
|
3227
|
+
}
|
|
3228
|
+
return sourceFile.getOrCreateNodeAtIndex(owner.index);
|
|
3229
|
+
}, function* (project = owner.canonicalProject) {
|
|
3230
|
+
const sourceFile = yield* project.program.getSourceFile.gen(owner.path);
|
|
3231
|
+
if (!sourceFile) {
|
|
3232
|
+
return undefined;
|
|
3233
|
+
}
|
|
3234
|
+
return sourceFile.getOrCreateNodeAtIndex(owner.index);
|
|
3235
|
+
});
|
|
1697
3236
|
}
|
|
1698
3237
|
}
|
|
1699
3238
|
export class Symbol {
|
|
@@ -1736,41 +3275,83 @@ export class Symbol {
|
|
|
1736
3275
|
if (data.exportSymbol !== undefined)
|
|
1737
3276
|
this.exportSymbol = data.exportSymbol;
|
|
1738
3277
|
}
|
|
1739
|
-
getParent() {
|
|
1740
|
-
|
|
3278
|
+
get getParent() {
|
|
3279
|
+
const owner = this;
|
|
3280
|
+
return cacheGeneratorMethod(owner, "getParent", function () {
|
|
3281
|
+
return owner.objectRegistry.fetchSymbol(owner, "getParentOfSymbol", owner.parent, owner.canonicalProject.id);
|
|
3282
|
+
}, function* () {
|
|
3283
|
+
return yield* owner.objectRegistry.fetchSymbol.gen(owner, "getParentOfSymbol", owner.parent, owner.canonicalProject.id);
|
|
3284
|
+
});
|
|
1741
3285
|
}
|
|
1742
3286
|
/**
|
|
1743
3287
|
* Get this symbol's members keyed by escaped name. The result is cached on
|
|
1744
3288
|
* the symbol, so repeated calls do not round-trip to the server.
|
|
1745
3289
|
*/
|
|
1746
|
-
getMembers() {
|
|
1747
|
-
|
|
3290
|
+
get getMembers() {
|
|
3291
|
+
const owner = this;
|
|
3292
|
+
return cacheGeneratorMethod(owner, "getMembers", function () {
|
|
3293
|
+
return owner.membersCache ??= owner.fetchSymbolTable("getMembersOfSymbol");
|
|
3294
|
+
}, function* () {
|
|
3295
|
+
return owner.membersCache ??= yield* owner.fetchSymbolTable.gen("getMembersOfSymbol");
|
|
3296
|
+
});
|
|
1748
3297
|
}
|
|
1749
3298
|
/**
|
|
1750
3299
|
* Get this symbol's exports keyed by escaped name. The result is cached on
|
|
1751
3300
|
* the symbol, so repeated calls do not round-trip to the server.
|
|
1752
3301
|
*/
|
|
1753
|
-
getExports() {
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
3302
|
+
get getExports() {
|
|
3303
|
+
const owner = this;
|
|
3304
|
+
return cacheGeneratorMethod(owner, "getExports", function () {
|
|
3305
|
+
return owner.exportsCache ??= owner.fetchSymbolTable("getExportsOfSymbol");
|
|
3306
|
+
}, function* () {
|
|
3307
|
+
return owner.exportsCache ??= yield* owner.fetchSymbolTable.gen("getExportsOfSymbol");
|
|
3308
|
+
});
|
|
3309
|
+
}
|
|
3310
|
+
get fetchSymbolTable() {
|
|
3311
|
+
const owner = this;
|
|
3312
|
+
return cacheGeneratorMethod(owner, "fetchSymbolTable", function (method) {
|
|
3313
|
+
const symbols = owner.objectRegistry.fetchSymbols(owner, method, undefined, owner.canonicalProject.id);
|
|
3314
|
+
const table = new Map();
|
|
3315
|
+
for (const symbol of symbols) {
|
|
3316
|
+
table.set(symbol.escapedName, symbol);
|
|
3317
|
+
}
|
|
3318
|
+
return table;
|
|
3319
|
+
}, function* (method) {
|
|
3320
|
+
const symbols = yield* owner.objectRegistry.fetchSymbols.gen(owner, method, undefined, owner.canonicalProject.id);
|
|
3321
|
+
const table = new Map();
|
|
3322
|
+
for (const symbol of symbols) {
|
|
3323
|
+
table.set(symbol.escapedName, symbol);
|
|
3324
|
+
}
|
|
3325
|
+
return table;
|
|
3326
|
+
});
|
|
1763
3327
|
}
|
|
1764
|
-
getExportSymbol() {
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
3328
|
+
get getExportSymbol() {
|
|
3329
|
+
const owner = this;
|
|
3330
|
+
return cacheGeneratorMethod(owner, "getExportSymbol", function () {
|
|
3331
|
+
if (!owner.exportSymbol)
|
|
3332
|
+
return owner;
|
|
3333
|
+
return owner.objectRegistry.fetchSymbol(owner, "getExportSymbolOfSymbol", owner.exportSymbol, owner.canonicalProject.id);
|
|
3334
|
+
}, function* () {
|
|
3335
|
+
if (!owner.exportSymbol)
|
|
3336
|
+
return owner;
|
|
3337
|
+
return yield* owner.objectRegistry.fetchSymbol.gen(owner, "getExportSymbolOfSymbol", owner.exportSymbol, owner.canonicalProject.id);
|
|
3338
|
+
});
|
|
1768
3339
|
}
|
|
1769
|
-
getJsDocTags(
|
|
1770
|
-
|
|
3340
|
+
get getJsDocTags() {
|
|
3341
|
+
const owner = this;
|
|
3342
|
+
return cacheGeneratorMethod(owner, "getJsDocTags", function (checker) {
|
|
3343
|
+
return checker.getJsDocTagsOfSymbol(owner);
|
|
3344
|
+
}, function* (checker) {
|
|
3345
|
+
return yield* checker.getJsDocTagsOfSymbol.gen(owner);
|
|
3346
|
+
});
|
|
1771
3347
|
}
|
|
1772
|
-
getDocumentationComment(
|
|
1773
|
-
|
|
3348
|
+
get getDocumentationComment() {
|
|
3349
|
+
const owner = this;
|
|
3350
|
+
return cacheGeneratorMethod(owner, "getDocumentationComment", function (checker) {
|
|
3351
|
+
return checker.getDocumentationCommentOfSymbol(owner);
|
|
3352
|
+
}, function* (checker) {
|
|
3353
|
+
return yield* checker.getDocumentationCommentOfSymbol.gen(owner);
|
|
3354
|
+
});
|
|
1774
3355
|
}
|
|
1775
3356
|
}
|
|
1776
3357
|
class TypeObject {
|
|
@@ -1888,162 +3469,381 @@ class TypeObject {
|
|
|
1888
3469
|
this.stringIndexType = false;
|
|
1889
3470
|
this.numberIndexType = false;
|
|
1890
3471
|
}
|
|
1891
|
-
getSymbol() {
|
|
1892
|
-
|
|
3472
|
+
get getSymbol() {
|
|
3473
|
+
const owner = this;
|
|
3474
|
+
return cacheGeneratorMethod(owner, "getSymbol", function () {
|
|
3475
|
+
return owner.objectRegistry.fetchSymbol(owner, "getSymbolOfType", owner.symbol);
|
|
3476
|
+
}, function* () {
|
|
3477
|
+
return yield* owner.objectRegistry.fetchSymbol.gen(owner, "getSymbolOfType", owner.symbol);
|
|
3478
|
+
});
|
|
1893
3479
|
}
|
|
1894
|
-
getProperties() {
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
3480
|
+
get getProperties() {
|
|
3481
|
+
const owner = this;
|
|
3482
|
+
return cacheGeneratorMethod(owner, "getProperties", function () {
|
|
3483
|
+
if (owner.properties === false) {
|
|
3484
|
+
owner.properties = owner.objectRegistry.fetchPropertiesOfType(owner);
|
|
3485
|
+
}
|
|
3486
|
+
return owner.properties;
|
|
3487
|
+
}, function* () {
|
|
3488
|
+
if (owner.properties === false) {
|
|
3489
|
+
owner.properties = yield* owner.objectRegistry.fetchPropertiesOfType.gen(owner);
|
|
3490
|
+
}
|
|
3491
|
+
return owner.properties;
|
|
3492
|
+
});
|
|
1899
3493
|
}
|
|
1900
|
-
getProperty(
|
|
1901
|
-
|
|
3494
|
+
get getProperty() {
|
|
3495
|
+
const owner = this;
|
|
3496
|
+
return cacheGeneratorMethod(owner, "getProperty", function (propertyName) {
|
|
3497
|
+
return owner.objectRegistry.fetchPropertyOfType(owner, propertyName);
|
|
3498
|
+
}, function* (propertyName) {
|
|
3499
|
+
return yield* owner.objectRegistry.fetchPropertyOfType.gen(owner, propertyName);
|
|
3500
|
+
});
|
|
1902
3501
|
}
|
|
1903
|
-
getApparentProperties() {
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
3502
|
+
get getApparentProperties() {
|
|
3503
|
+
const owner = this;
|
|
3504
|
+
return cacheGeneratorMethod(owner, "getApparentProperties", function () {
|
|
3505
|
+
if (owner.apparentProperties === false) {
|
|
3506
|
+
owner.apparentProperties = owner.objectRegistry.fetchApparentPropertiesOfType(owner);
|
|
3507
|
+
}
|
|
3508
|
+
return owner.apparentProperties;
|
|
3509
|
+
}, function* () {
|
|
3510
|
+
if (owner.apparentProperties === false) {
|
|
3511
|
+
owner.apparentProperties = yield* owner.objectRegistry.fetchApparentPropertiesOfType.gen(owner);
|
|
3512
|
+
}
|
|
3513
|
+
return owner.apparentProperties;
|
|
3514
|
+
});
|
|
1908
3515
|
}
|
|
1909
|
-
getCallSignatures() {
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
3516
|
+
get getCallSignatures() {
|
|
3517
|
+
const owner = this;
|
|
3518
|
+
return cacheGeneratorMethod(owner, "getCallSignatures", function () {
|
|
3519
|
+
if (owner.callSignatures === false) {
|
|
3520
|
+
owner.callSignatures = owner.objectRegistry.fetchSignaturesOfType(owner, SignatureKind.Call);
|
|
3521
|
+
}
|
|
3522
|
+
return owner.callSignatures;
|
|
3523
|
+
}, function* () {
|
|
3524
|
+
if (owner.callSignatures === false) {
|
|
3525
|
+
owner.callSignatures = yield* owner.objectRegistry.fetchSignaturesOfType.gen(owner, SignatureKind.Call);
|
|
3526
|
+
}
|
|
3527
|
+
return owner.callSignatures;
|
|
3528
|
+
});
|
|
1914
3529
|
}
|
|
1915
|
-
getConstructSignatures() {
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
3530
|
+
get getConstructSignatures() {
|
|
3531
|
+
const owner = this;
|
|
3532
|
+
return cacheGeneratorMethod(owner, "getConstructSignatures", function () {
|
|
3533
|
+
if (owner.constructSignatures === false) {
|
|
3534
|
+
owner.constructSignatures = owner.objectRegistry.fetchSignaturesOfType(owner, SignatureKind.Construct);
|
|
3535
|
+
}
|
|
3536
|
+
return owner.constructSignatures;
|
|
3537
|
+
}, function* () {
|
|
3538
|
+
if (owner.constructSignatures === false) {
|
|
3539
|
+
owner.constructSignatures = yield* owner.objectRegistry.fetchSignaturesOfType.gen(owner, SignatureKind.Construct);
|
|
3540
|
+
}
|
|
3541
|
+
return owner.constructSignatures;
|
|
3542
|
+
});
|
|
1920
3543
|
}
|
|
1921
|
-
getNonNullableType() {
|
|
1922
|
-
const
|
|
1923
|
-
|
|
1924
|
-
|
|
3544
|
+
get getNonNullableType() {
|
|
3545
|
+
const owner = this;
|
|
3546
|
+
return cacheGeneratorMethod(owner, "getNonNullableType", function () {
|
|
3547
|
+
const result = owner.objectRegistry.fetchType(owner, "getNonNullableType", owner.nonNullableType);
|
|
3548
|
+
owner.nonNullableType = result.id;
|
|
3549
|
+
return result;
|
|
3550
|
+
}, function* () {
|
|
3551
|
+
const result = yield* owner.objectRegistry.fetchType.gen(owner, "getNonNullableType", owner.nonNullableType);
|
|
3552
|
+
owner.nonNullableType = result.id;
|
|
3553
|
+
return result;
|
|
3554
|
+
});
|
|
1925
3555
|
}
|
|
1926
|
-
getStringIndexType() {
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
3556
|
+
get getStringIndexType() {
|
|
3557
|
+
const owner = this;
|
|
3558
|
+
return cacheGeneratorMethod(owner, "getStringIndexType", function () {
|
|
3559
|
+
if (owner.stringIndexType === false) {
|
|
3560
|
+
owner.stringIndexType = owner.getStringIndexTypeWorker();
|
|
3561
|
+
}
|
|
3562
|
+
return owner.stringIndexType;
|
|
3563
|
+
}, function* () {
|
|
3564
|
+
if (owner.stringIndexType === false) {
|
|
3565
|
+
owner.stringIndexType = yield* owner.getStringIndexTypeWorker.gen();
|
|
3566
|
+
}
|
|
3567
|
+
return owner.stringIndexType;
|
|
3568
|
+
});
|
|
1931
3569
|
}
|
|
1932
|
-
getStringIndexTypeWorker() {
|
|
1933
|
-
const
|
|
1934
|
-
return
|
|
3570
|
+
get getStringIndexTypeWorker() {
|
|
3571
|
+
const owner = this;
|
|
3572
|
+
return cacheGeneratorMethod(owner, "getStringIndexTypeWorker", function () {
|
|
3573
|
+
const infos = owner.getIndexInfos();
|
|
3574
|
+
return infos.find(info => (info.keyType.flags & TypeFlags.String) !== 0)?.valueType;
|
|
3575
|
+
}, function* () {
|
|
3576
|
+
const infos = yield* owner.getIndexInfos.gen();
|
|
3577
|
+
return infos.find(info => (info.keyType.flags & TypeFlags.String) !== 0)?.valueType;
|
|
3578
|
+
});
|
|
1935
3579
|
}
|
|
1936
|
-
getNumberIndexType() {
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
3580
|
+
get getNumberIndexType() {
|
|
3581
|
+
const owner = this;
|
|
3582
|
+
return cacheGeneratorMethod(owner, "getNumberIndexType", function () {
|
|
3583
|
+
if (owner.numberIndexType === false) {
|
|
3584
|
+
owner.numberIndexType = owner.getNumberIndexTypeWorker();
|
|
3585
|
+
}
|
|
3586
|
+
return owner.numberIndexType;
|
|
3587
|
+
}, function* () {
|
|
3588
|
+
if (owner.numberIndexType === false) {
|
|
3589
|
+
owner.numberIndexType = yield* owner.getNumberIndexTypeWorker.gen();
|
|
3590
|
+
}
|
|
3591
|
+
return owner.numberIndexType;
|
|
3592
|
+
});
|
|
1941
3593
|
}
|
|
1942
|
-
getNumberIndexTypeWorker() {
|
|
1943
|
-
const
|
|
1944
|
-
return
|
|
3594
|
+
get getNumberIndexTypeWorker() {
|
|
3595
|
+
const owner = this;
|
|
3596
|
+
return cacheGeneratorMethod(owner, "getNumberIndexTypeWorker", function () {
|
|
3597
|
+
const infos = owner.getIndexInfos();
|
|
3598
|
+
return infos.find(info => (info.keyType.flags & TypeFlags.Number) !== 0)?.valueType;
|
|
3599
|
+
}, function* () {
|
|
3600
|
+
const infos = yield* owner.getIndexInfos.gen();
|
|
3601
|
+
return infos.find(info => (info.keyType.flags & TypeFlags.Number) !== 0)?.valueType;
|
|
3602
|
+
});
|
|
1945
3603
|
}
|
|
1946
|
-
getApparentType() {
|
|
1947
|
-
const
|
|
1948
|
-
|
|
1949
|
-
|
|
3604
|
+
get getApparentType() {
|
|
3605
|
+
const owner = this;
|
|
3606
|
+
return cacheGeneratorMethod(owner, "getApparentType", function () {
|
|
3607
|
+
const result = owner.objectRegistry.fetchType(owner, "getApparentType", owner.apparentType);
|
|
3608
|
+
owner.apparentType = result.id;
|
|
3609
|
+
return result;
|
|
3610
|
+
}, function* () {
|
|
3611
|
+
const result = yield* owner.objectRegistry.fetchType.gen(owner, "getApparentType", owner.apparentType);
|
|
3612
|
+
owner.apparentType = result.id;
|
|
3613
|
+
return result;
|
|
3614
|
+
});
|
|
1950
3615
|
}
|
|
1951
|
-
getReducedType() {
|
|
1952
|
-
const
|
|
1953
|
-
|
|
1954
|
-
|
|
3616
|
+
get getReducedType() {
|
|
3617
|
+
const owner = this;
|
|
3618
|
+
return cacheGeneratorMethod(owner, "getReducedType", function () {
|
|
3619
|
+
const result = owner.objectRegistry.fetchType(owner, "getReducedType", owner.reducedType);
|
|
3620
|
+
owner.reducedType = result.id;
|
|
3621
|
+
return result;
|
|
3622
|
+
}, function* () {
|
|
3623
|
+
const result = yield* owner.objectRegistry.fetchType.gen(owner, "getReducedType", owner.reducedType);
|
|
3624
|
+
owner.reducedType = result.id;
|
|
3625
|
+
return result;
|
|
3626
|
+
});
|
|
1955
3627
|
}
|
|
1956
|
-
getIndexInfos() {
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
3628
|
+
get getIndexInfos() {
|
|
3629
|
+
const owner = this;
|
|
3630
|
+
return cacheGeneratorMethod(owner, "getIndexInfos", function () {
|
|
3631
|
+
if (owner.indexInfos === false) {
|
|
3632
|
+
owner.indexInfos = owner.objectRegistry.fetchIndexInfosOfType(owner);
|
|
3633
|
+
}
|
|
3634
|
+
return owner.indexInfos;
|
|
3635
|
+
}, function* () {
|
|
3636
|
+
if (owner.indexInfos === false) {
|
|
3637
|
+
owner.indexInfos = yield* owner.objectRegistry.fetchIndexInfosOfType.gen(owner);
|
|
3638
|
+
}
|
|
3639
|
+
return owner.indexInfos;
|
|
3640
|
+
});
|
|
1961
3641
|
}
|
|
1962
|
-
getAliasSymbol() {
|
|
1963
|
-
|
|
3642
|
+
get getAliasSymbol() {
|
|
3643
|
+
const owner = this;
|
|
3644
|
+
return cacheGeneratorMethod(owner, "getAliasSymbol", function () {
|
|
3645
|
+
return owner.objectRegistry.fetchSymbol(owner, "getAliasSymbolOfType", owner.aliasSymbol);
|
|
3646
|
+
}, function* () {
|
|
3647
|
+
return yield* owner.objectRegistry.fetchSymbol.gen(owner, "getAliasSymbolOfType", owner.aliasSymbol);
|
|
3648
|
+
});
|
|
1964
3649
|
}
|
|
1965
|
-
getTarget() {
|
|
1966
|
-
|
|
3650
|
+
get getTarget() {
|
|
3651
|
+
const owner = this;
|
|
3652
|
+
return cacheGeneratorMethod(owner, "getTarget", function () {
|
|
3653
|
+
return owner.objectRegistry.fetchType(owner, "getTargetOfType", owner.target);
|
|
3654
|
+
}, function* () {
|
|
3655
|
+
return yield* owner.objectRegistry.fetchType.gen(owner, "getTargetOfType", owner.target);
|
|
3656
|
+
});
|
|
1967
3657
|
}
|
|
1968
|
-
getFreshType() {
|
|
1969
|
-
|
|
3658
|
+
get getFreshType() {
|
|
3659
|
+
const owner = this;
|
|
3660
|
+
return cacheGeneratorMethod(owner, "getFreshType", function () {
|
|
3661
|
+
return owner.objectRegistry.fetchOptionalType(owner, "getFreshTypeOfType", owner.freshType);
|
|
3662
|
+
}, function* () {
|
|
3663
|
+
return yield* owner.objectRegistry.fetchOptionalType.gen(owner, "getFreshTypeOfType", owner.freshType);
|
|
3664
|
+
});
|
|
1970
3665
|
}
|
|
1971
|
-
getRegularType() {
|
|
1972
|
-
|
|
3666
|
+
get getRegularType() {
|
|
3667
|
+
const owner = this;
|
|
3668
|
+
return cacheGeneratorMethod(owner, "getRegularType", function () {
|
|
3669
|
+
return owner.objectRegistry.fetchOptionalType(owner, "getRegularTypeOfType", owner.regularType);
|
|
3670
|
+
}, function* () {
|
|
3671
|
+
return yield* owner.objectRegistry.fetchOptionalType.gen(owner, "getRegularTypeOfType", owner.regularType);
|
|
3672
|
+
});
|
|
1973
3673
|
}
|
|
1974
|
-
getTypes() {
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
3674
|
+
get getTypes() {
|
|
3675
|
+
const owner = this;
|
|
3676
|
+
return cacheGeneratorMethod(owner, "getTypes", function () {
|
|
3677
|
+
// Only union, intersection, and template literal types have constituent
|
|
3678
|
+
// types; any other kind has none, so return undefined rather than sending
|
|
3679
|
+
// a request the server cannot satisfy.
|
|
3680
|
+
if (!(owner.flags & (TypeFlags.UnionOrIntersection | TypeFlags.TemplateLiteral))) {
|
|
3681
|
+
return undefined;
|
|
3682
|
+
}
|
|
3683
|
+
return owner.objectRegistry.fetchTypes(owner, "getTypesOfType");
|
|
3684
|
+
}, function* () {
|
|
3685
|
+
// Only union, intersection, and template literal types have constituent
|
|
3686
|
+
// types; any other kind has none, so return undefined rather than sending
|
|
3687
|
+
// a request the server cannot satisfy.
|
|
3688
|
+
if (!(owner.flags & (TypeFlags.UnionOrIntersection | TypeFlags.TemplateLiteral))) {
|
|
3689
|
+
return undefined;
|
|
3690
|
+
}
|
|
3691
|
+
return yield* owner.objectRegistry.fetchTypes.gen(owner, "getTypesOfType");
|
|
3692
|
+
});
|
|
1982
3693
|
}
|
|
1983
|
-
getTypeParameters() {
|
|
1984
|
-
|
|
3694
|
+
get getTypeParameters() {
|
|
3695
|
+
const owner = this;
|
|
3696
|
+
return cacheGeneratorMethod(owner, "getTypeParameters", function () {
|
|
3697
|
+
return owner.objectRegistry.fetchTypes(owner, "getTypeParametersOfType", owner.typeParameters);
|
|
3698
|
+
}, function* () {
|
|
3699
|
+
return (yield* owner.objectRegistry.fetchTypes.gen(owner, "getTypeParametersOfType", owner.typeParameters));
|
|
3700
|
+
});
|
|
1985
3701
|
}
|
|
1986
|
-
getOuterTypeParameters() {
|
|
1987
|
-
|
|
3702
|
+
get getOuterTypeParameters() {
|
|
3703
|
+
const owner = this;
|
|
3704
|
+
return cacheGeneratorMethod(owner, "getOuterTypeParameters", function () {
|
|
3705
|
+
return owner.objectRegistry.fetchTypes(owner, "getOuterTypeParametersOfType", owner.outerTypeParameters);
|
|
3706
|
+
}, function* () {
|
|
3707
|
+
return (yield* owner.objectRegistry.fetchTypes.gen(owner, "getOuterTypeParametersOfType", owner.outerTypeParameters));
|
|
3708
|
+
});
|
|
1988
3709
|
}
|
|
1989
|
-
getLocalTypeParameters() {
|
|
1990
|
-
|
|
3710
|
+
get getLocalTypeParameters() {
|
|
3711
|
+
const owner = this;
|
|
3712
|
+
return cacheGeneratorMethod(owner, "getLocalTypeParameters", function () {
|
|
3713
|
+
return owner.objectRegistry.fetchTypes(owner, "getLocalTypeParametersOfType", owner.localTypeParameters);
|
|
3714
|
+
}, function* () {
|
|
3715
|
+
return (yield* owner.objectRegistry.fetchTypes.gen(owner, "getLocalTypeParametersOfType", owner.localTypeParameters));
|
|
3716
|
+
});
|
|
1991
3717
|
}
|
|
1992
|
-
getAliasTypeArguments() {
|
|
1993
|
-
|
|
3718
|
+
get getAliasTypeArguments() {
|
|
3719
|
+
const owner = this;
|
|
3720
|
+
return cacheGeneratorMethod(owner, "getAliasTypeArguments", function () {
|
|
3721
|
+
return owner.objectRegistry.fetchTypes(owner, "getAliasTypeArgumentsOfType", owner.aliasTypeArguments);
|
|
3722
|
+
}, function* () {
|
|
3723
|
+
return yield* owner.objectRegistry.fetchTypes.gen(owner, "getAliasTypeArgumentsOfType", owner.aliasTypeArguments);
|
|
3724
|
+
});
|
|
1994
3725
|
}
|
|
1995
|
-
getObjectType() {
|
|
1996
|
-
|
|
3726
|
+
get getObjectType() {
|
|
3727
|
+
const owner = this;
|
|
3728
|
+
return cacheGeneratorMethod(owner, "getObjectType", function () {
|
|
3729
|
+
return owner.objectRegistry.fetchType(owner, "getObjectTypeOfType", owner.objectType);
|
|
3730
|
+
}, function* () {
|
|
3731
|
+
return yield* owner.objectRegistry.fetchType.gen(owner, "getObjectTypeOfType", owner.objectType);
|
|
3732
|
+
});
|
|
1997
3733
|
}
|
|
1998
|
-
getIndexType() {
|
|
1999
|
-
|
|
3734
|
+
get getIndexType() {
|
|
3735
|
+
const owner = this;
|
|
3736
|
+
return cacheGeneratorMethod(owner, "getIndexType", function () {
|
|
3737
|
+
return owner.objectRegistry.fetchType(owner, "getIndexTypeOfType", owner.indexType);
|
|
3738
|
+
}, function* () {
|
|
3739
|
+
return yield* owner.objectRegistry.fetchType.gen(owner, "getIndexTypeOfType", owner.indexType);
|
|
3740
|
+
});
|
|
2000
3741
|
}
|
|
2001
|
-
getCheckType() {
|
|
2002
|
-
|
|
3742
|
+
get getCheckType() {
|
|
3743
|
+
const owner = this;
|
|
3744
|
+
return cacheGeneratorMethod(owner, "getCheckType", function () {
|
|
3745
|
+
return owner.objectRegistry.fetchType(owner, "getCheckTypeOfType", owner.checkType);
|
|
3746
|
+
}, function* () {
|
|
3747
|
+
return yield* owner.objectRegistry.fetchType.gen(owner, "getCheckTypeOfType", owner.checkType);
|
|
3748
|
+
});
|
|
2003
3749
|
}
|
|
2004
|
-
getExtendsType() {
|
|
2005
|
-
|
|
3750
|
+
get getExtendsType() {
|
|
3751
|
+
const owner = this;
|
|
3752
|
+
return cacheGeneratorMethod(owner, "getExtendsType", function () {
|
|
3753
|
+
return owner.objectRegistry.fetchType(owner, "getExtendsTypeOfType", owner.extendsType);
|
|
3754
|
+
}, function* () {
|
|
3755
|
+
return yield* owner.objectRegistry.fetchType.gen(owner, "getExtendsTypeOfType", owner.extendsType);
|
|
3756
|
+
});
|
|
2006
3757
|
}
|
|
2007
|
-
getBaseType() {
|
|
2008
|
-
|
|
3758
|
+
get getBaseType() {
|
|
3759
|
+
const owner = this;
|
|
3760
|
+
return cacheGeneratorMethod(owner, "getBaseType", function () {
|
|
3761
|
+
return owner.objectRegistry.fetchType(owner, "getBaseTypeOfType", owner.baseType);
|
|
3762
|
+
}, function* () {
|
|
3763
|
+
return yield* owner.objectRegistry.fetchType.gen(owner, "getBaseTypeOfType", owner.baseType);
|
|
3764
|
+
});
|
|
2009
3765
|
}
|
|
2010
|
-
getConstraint() {
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
3766
|
+
get getConstraint() {
|
|
3767
|
+
const owner = this;
|
|
3768
|
+
return cacheGeneratorMethod(owner, "getConstraint", function () {
|
|
3769
|
+
// Type parameters resolve their constraint lazily through the checker,
|
|
3770
|
+
// whereas substitution types carry a preloaded constraint handle.
|
|
3771
|
+
if (owner.flags & TypeFlags.TypeParameter) {
|
|
3772
|
+
const result = owner.objectRegistry.fetchOptionalType(owner, "getConstraintOfTypeParameter", owner.constraint);
|
|
3773
|
+
owner.constraint = result ? result.id : 0;
|
|
3774
|
+
return result;
|
|
3775
|
+
}
|
|
3776
|
+
return owner.objectRegistry.fetchType(owner, "getConstraintOfType", owner.substConstraint);
|
|
3777
|
+
}, function* () {
|
|
3778
|
+
// Type parameters resolve their constraint lazily through the checker,
|
|
3779
|
+
// whereas substitution types carry a preloaded constraint handle.
|
|
3780
|
+
if (owner.flags & TypeFlags.TypeParameter) {
|
|
3781
|
+
const result = yield* owner.objectRegistry.fetchOptionalType.gen(owner, "getConstraintOfTypeParameter", owner.constraint);
|
|
3782
|
+
owner.constraint = result ? result.id : 0;
|
|
3783
|
+
return result;
|
|
3784
|
+
}
|
|
3785
|
+
return yield* owner.objectRegistry.fetchType.gen(owner, "getConstraintOfType", owner.substConstraint);
|
|
3786
|
+
});
|
|
2019
3787
|
}
|
|
2020
|
-
getDefault() {
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2023
|
-
|
|
3788
|
+
get getDefault() {
|
|
3789
|
+
const owner = this;
|
|
3790
|
+
return cacheGeneratorMethod(owner, "getDefault", function () {
|
|
3791
|
+
const result = owner.objectRegistry.fetchOptionalType(owner, "getDefaultFromTypeParameter", owner.default);
|
|
3792
|
+
owner.default = result ? result.id : 0;
|
|
3793
|
+
return result;
|
|
3794
|
+
}, function* () {
|
|
3795
|
+
const result = yield* owner.objectRegistry.fetchOptionalType.gen(owner, "getDefaultFromTypeParameter", owner.default);
|
|
3796
|
+
owner.default = result ? result.id : 0;
|
|
3797
|
+
return result;
|
|
3798
|
+
});
|
|
2024
3799
|
}
|
|
2025
|
-
getTrueType() {
|
|
2026
|
-
const
|
|
2027
|
-
|
|
2028
|
-
|
|
3800
|
+
get getTrueType() {
|
|
3801
|
+
const owner = this;
|
|
3802
|
+
return cacheGeneratorMethod(owner, "getTrueType", function () {
|
|
3803
|
+
const result = owner.objectRegistry.fetchType(owner, "getTrueTypeOfConditionalType", owner.trueType);
|
|
3804
|
+
owner.trueType = result.id;
|
|
3805
|
+
return result;
|
|
3806
|
+
}, function* () {
|
|
3807
|
+
const result = yield* owner.objectRegistry.fetchType.gen(owner, "getTrueTypeOfConditionalType", owner.trueType);
|
|
3808
|
+
owner.trueType = result.id;
|
|
3809
|
+
return result;
|
|
3810
|
+
});
|
|
2029
3811
|
}
|
|
2030
|
-
getFalseType() {
|
|
2031
|
-
const
|
|
2032
|
-
|
|
2033
|
-
|
|
3812
|
+
get getFalseType() {
|
|
3813
|
+
const owner = this;
|
|
3814
|
+
return cacheGeneratorMethod(owner, "getFalseType", function () {
|
|
3815
|
+
const result = owner.objectRegistry.fetchType(owner, "getFalseTypeOfConditionalType", owner.falseType);
|
|
3816
|
+
owner.falseType = result.id;
|
|
3817
|
+
return result;
|
|
3818
|
+
}, function* () {
|
|
3819
|
+
const result = yield* owner.objectRegistry.fetchType.gen(owner, "getFalseTypeOfConditionalType", owner.falseType);
|
|
3820
|
+
owner.falseType = result.id;
|
|
3821
|
+
return result;
|
|
3822
|
+
});
|
|
2034
3823
|
}
|
|
2035
3824
|
/**
|
|
2036
3825
|
* Get the base types of this type. Returns `undefined` for any type that is
|
|
2037
3826
|
* not a class or interface.
|
|
2038
3827
|
*/
|
|
2039
|
-
getBaseTypes() {
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
3828
|
+
get getBaseTypes() {
|
|
3829
|
+
const owner = this;
|
|
3830
|
+
return cacheGeneratorMethod(owner, "getBaseTypes", function () {
|
|
3831
|
+
if (!owner.isClassOrInterface()) {
|
|
3832
|
+
return undefined;
|
|
3833
|
+
}
|
|
3834
|
+
if (owner.baseTypes === false) {
|
|
3835
|
+
owner.baseTypes = owner.objectRegistry.fetchBaseTypes(owner);
|
|
3836
|
+
}
|
|
3837
|
+
return owner.baseTypes;
|
|
3838
|
+
}, function* () {
|
|
3839
|
+
if (!owner.isClassOrInterface()) {
|
|
3840
|
+
return undefined;
|
|
3841
|
+
}
|
|
3842
|
+
if (owner.baseTypes === false) {
|
|
3843
|
+
owner.baseTypes = yield* owner.objectRegistry.fetchBaseTypes.gen(owner);
|
|
3844
|
+
}
|
|
3845
|
+
return owner.baseTypes;
|
|
3846
|
+
});
|
|
2047
3847
|
}
|
|
2048
3848
|
isClassOrInterface() {
|
|
2049
3849
|
return isClassOrInterfaceType(this);
|
|
@@ -2193,25 +3993,57 @@ export class Signature {
|
|
|
2193
3993
|
this.target = data.target;
|
|
2194
3994
|
this.returnType = false;
|
|
2195
3995
|
}
|
|
2196
|
-
getTypeParameters() {
|
|
2197
|
-
|
|
3996
|
+
get getTypeParameters() {
|
|
3997
|
+
const owner = this;
|
|
3998
|
+
return cacheGeneratorMethod(owner, "getTypeParameters", function () {
|
|
3999
|
+
return owner.objectRegistry.fetchTypes(owner, "getTypeParametersOfSignature", owner.typeParameters);
|
|
4000
|
+
}, function* () {
|
|
4001
|
+
return (yield* owner.objectRegistry.fetchTypes.gen(owner, "getTypeParametersOfSignature", owner.typeParameters));
|
|
4002
|
+
});
|
|
2198
4003
|
}
|
|
2199
|
-
getParameters() {
|
|
2200
|
-
|
|
4004
|
+
get getParameters() {
|
|
4005
|
+
const owner = this;
|
|
4006
|
+
return cacheGeneratorMethod(owner, "getParameters", function () {
|
|
4007
|
+
return owner.objectRegistry.fetchSymbols(owner, "getParametersOfSignature", owner.parameters);
|
|
4008
|
+
}, function* () {
|
|
4009
|
+
return yield* owner.objectRegistry.fetchSymbols.gen(owner, "getParametersOfSignature", owner.parameters);
|
|
4010
|
+
});
|
|
2201
4011
|
}
|
|
2202
|
-
getThisParameter() {
|
|
2203
|
-
|
|
4012
|
+
get getThisParameter() {
|
|
4013
|
+
const owner = this;
|
|
4014
|
+
return cacheGeneratorMethod(owner, "getThisParameter", function () {
|
|
4015
|
+
return owner.objectRegistry.fetchSymbol(owner, "getThisParameterOfSignature", owner.thisParameter);
|
|
4016
|
+
}, function* () {
|
|
4017
|
+
return yield* owner.objectRegistry.fetchSymbol.gen(owner, "getThisParameterOfSignature", owner.thisParameter);
|
|
4018
|
+
});
|
|
2204
4019
|
}
|
|
2205
|
-
getTarget() {
|
|
2206
|
-
|
|
4020
|
+
get getTarget() {
|
|
4021
|
+
const owner = this;
|
|
4022
|
+
return cacheGeneratorMethod(owner, "getTarget", function () {
|
|
4023
|
+
return owner.objectRegistry.fetchSignature(owner, "getTargetOfSignature", owner.target);
|
|
4024
|
+
}, function* () {
|
|
4025
|
+
return yield* owner.objectRegistry.fetchSignature.gen(owner, "getTargetOfSignature", owner.target);
|
|
4026
|
+
});
|
|
2207
4027
|
}
|
|
2208
|
-
getReturnType() {
|
|
2209
|
-
const
|
|
2210
|
-
|
|
2211
|
-
|
|
4028
|
+
get getReturnType() {
|
|
4029
|
+
const owner = this;
|
|
4030
|
+
return cacheGeneratorMethod(owner, "getReturnType", function () {
|
|
4031
|
+
const result = owner.objectRegistry.fetchType(owner, "getReturnTypeOfSignature", owner.returnType);
|
|
4032
|
+
owner.returnType = result.id;
|
|
4033
|
+
return result;
|
|
4034
|
+
}, function* () {
|
|
4035
|
+
const result = yield* owner.objectRegistry.fetchType.gen(owner, "getReturnTypeOfSignature", owner.returnType);
|
|
4036
|
+
owner.returnType = result.id;
|
|
4037
|
+
return result;
|
|
4038
|
+
});
|
|
2212
4039
|
}
|
|
2213
|
-
getTypeParameterAtPosition(
|
|
2214
|
-
|
|
4040
|
+
get getTypeParameterAtPosition() {
|
|
4041
|
+
const owner = this;
|
|
4042
|
+
return cacheGeneratorMethod(owner, "getTypeParameterAtPosition", function (pos) {
|
|
4043
|
+
return owner.objectRegistry.fetchTypeParameterAtPosition(owner, pos);
|
|
4044
|
+
}, function* (pos) {
|
|
4045
|
+
return yield* owner.objectRegistry.fetchTypeParameterAtPosition.gen(owner, pos);
|
|
4046
|
+
});
|
|
2215
4047
|
}
|
|
2216
4048
|
get hasRestParameter() {
|
|
2217
4049
|
return (this.flags & SignatureFlags.HasRestParameter) !== 0;
|