typescript 7.1.0-dev.20260827.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.
@@ -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, () => this.ensureInitialized());
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(options) {
56
- const api = new API(options);
57
- api.ensureInitialized();
58
- return api;
59
- }
60
- batchRequests(requests) {
61
- const response = this.client.apiRequest("batchRequests", { requests });
62
- // we're replacing the `unknown`s in the autogenerated types with much more specific per-request types here, which creates some variance issues for the
63
- // `batchRequests` method within the batch request object itself, so we cast.
64
- return response;
65
- }
66
- ensureInitialized() {
67
- if (!this.initialized) {
68
- const response = this.client.apiRequest("initialize", null);
69
- const getCanonicalFileName = createGetCanonicalFileName(response.useCaseSensitiveFileNames);
70
- const currentDirectory = response.currentDirectory;
71
- this.getCanonicalFileNameWorker = getCanonicalFileName;
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(file) {
93
- this.ensureInitialized();
94
- return this.client.apiRequest("parseConfigFile", { file });
95
- }
96
- parseCommandLine(commandLine) {
97
- this.ensureInitialized();
98
- return this.client.apiRequest("parseCommandLine", { commandLine });
99
- }
100
- readConfigFile(file) {
101
- this.ensureInitialized();
102
- return this.client.apiRequest("readConfigFile", { file });
103
- }
104
- parseJsonConfigFileContent(json, options) {
105
- this.ensureInitialized();
106
- return this.client.apiRequest("parseJsonConfigFileContent", { json, ...options });
107
- }
108
- transpileModule(input, options = {}) {
109
- this.ensureInitialized();
110
- return this.client.apiRequest("transpileModule", { input, options });
111
- }
112
- transpileModuleFromFile(fileName, options = {}) {
113
- this.ensureInitialized();
114
- return this.client.apiRequest("transpileModuleFromFile", { fileName, options });
115
- }
116
- transpileDeclaration(input, options = {}) {
117
- this.ensureInitialized();
118
- return this.client.apiRequest("transpileDeclaration", { input, options });
119
- }
120
- transpileDeclarationFromFile(fileName, options = {}) {
121
- this.ensureInitialized();
122
- return this.client.apiRequest("transpileDeclarationFromFile", { fileName, options });
123
- }
124
- updateSnapshot(params) {
125
- this.ensureInitialized();
126
- const requestParams = toUpdateSnapshotRequest(params);
127
- const data = this.client.apiRequest("updateSnapshot", requestParams);
128
- // Retain cached source files from previous snapshot for unchanged files
129
- if (this.latestSnapshot) {
130
- this.sourceFileCache.retainForSnapshot(data.snapshot, this.latestSnapshot.id, data.changes);
131
- if (this.latestSnapshot.isDisposed()) {
132
- this.sourceFileCache.releaseSnapshot(this.latestSnapshot.id);
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
- const snapshot = new Snapshot(data, this.client, this.sourceFileCache, this.toPath, this, () => {
136
- this.activeSnapshots.delete(snapshot);
137
- if (snapshot !== this.latestSnapshot) {
138
- this.sourceFileCache.releaseSnapshot(snapshot.id);
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
- // Dispose all active snapshots
147
- for (const snapshot of [...this.activeSnapshots]) {
148
- snapshot.dispose();
149
- }
150
- // Release the latest snapshot's cache refs if still held
151
- if (this.latestSnapshot) {
152
- this.sourceFileCache.releaseSnapshot(this.latestSnapshot.id);
153
- this.latestSnapshot = undefined;
154
- }
155
- this.client.close();
156
- this.sourceFileCache.clear();
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(baseSnapshot, file, newText, cb) {
162
- this.ensureInitialized();
163
- if (!this.activeSnapshots.has(baseSnapshot) || baseSnapshot.isDisposed()) {
164
- throw new Error("Cannot run a temporary file update on an inactive snapshot");
165
- }
166
- const data = this.client.apiRequest("updateTemporarySnapshot", { snapshot: baseSnapshot.id, file, newText });
167
- // Retain cached source files from the base snapshot for files unchanged by
168
- // the temporary update. The temporary snapshot is not the latest snapshot, so
169
- // we never release the latest snapshot's cache here.
170
- this.sourceFileCache.retainForSnapshot(data.snapshot, baseSnapshot.id, data.changes);
171
- const snapshot = new Snapshot(data, this.client, this.sourceFileCache, this.toPath, this, () => {
172
- this.activeSnapshots.delete(snapshot);
173
- this.sourceFileCache.releaseSnapshot(snapshot.id);
174
- });
175
- this.activeSnapshots.add(snapshot);
176
- try {
177
- cb(snapshot);
178
- }
179
- finally {
180
- snapshot.dispose();
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
- return this.client.getTimingInfo();
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
- return this.client.resetTimingInfo();
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(dir) {
211
- this.ensureInitialized();
212
- this.client.apiRequest("startCPUProfile", { dir });
213
- }
214
- stopCPUProfile() {
215
- this.ensureInitialized();
216
- const result = this.client.apiRequest("stopCPUProfile", null);
217
- return result.file;
218
- }
219
- saveHeapProfile(dir) {
220
- this.ensureInitialized();
221
- const result = this.client.apiRequest("saveHeapProfile", { dir });
222
- return result.file;
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(file) {
256
- this.ensureNotDisposed();
257
- const data = this.client.apiRequest("getDefaultProjectForFile", {
258
- snapshot: this.id,
259
- file,
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
- if (this.disposed)
270
- return;
271
- this.disposed = true;
272
- for (const project of this.projectMap.values()) {
273
- project.dispose();
274
- }
275
- this.projectMap.clear();
276
- this.snapshotRegistry.clear();
277
- this.onDispose();
278
- this.client.apiRequest("release", { snapshot: this.id });
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(source, method, handle, projectId) {
318
- if (!handle)
319
- return undefined;
320
- const cached = this.getSymbol(handle);
321
- if (cached)
322
- return cached;
323
- const data = this.client.apiRequest(method, {
324
- snapshot: this.snapshotId,
325
- project: projectId,
326
- objectId: source.id,
327
- });
328
- if (!data)
329
- throw new Error(`${method} returned null symbol for ${source.constructor.name} ${source.id}`);
330
- return this.getOrCreateSymbol(data);
331
- }
332
- fetchSymbols(source, method, handles, projectId) {
333
- if (handles) {
334
- const result = new Array(handles.length);
335
- let allCached = true;
336
- for (let i = 0; i < handles.length; i++) {
337
- const cached = this.getSymbol(handles[i]);
338
- if (!cached) {
339
- allCached = false;
340
- break;
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
- result[i] = cached;
546
+ if (allCached)
547
+ return result;
343
548
  }
344
- if (allCached)
345
- return result;
346
- }
347
- const symbolData = this.client.apiRequest(method, {
348
- snapshot: this.snapshotId,
349
- project: projectId,
350
- objectId: source.id,
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(source, method, handle) {
404
- if (handle !== false) {
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 = this.getType(handle);
693
+ const cached = owner.getSignature(handle);
408
694
  if (cached)
409
695
  return cached;
410
- }
411
- const data = this.client.apiRequest(method, {
412
- snapshot: this.snapshotId,
413
- project: this.project.id,
414
- objectId: source.id,
415
- });
416
- if (!data)
417
- return undefined;
418
- return this.getOrCreateType(data);
419
- }
420
- fetchType(source, method, handle) {
421
- const result = this.fetchOptionalType(source, method, handle);
422
- if (result === undefined)
423
- throw new Error(`${method} returned no type for ${source.constructor.name} ${source.id}`);
424
- return result;
425
- }
426
- fetchSymbol(source, method, handle) {
427
- return this.snapshotRegistry.fetchSymbol(source, method, handle, this.project.id);
428
- }
429
- fetchSignature(source, method, handle) {
430
- if (!handle)
431
- return undefined;
432
- const cached = this.getSignature(handle);
433
- if (cached)
434
- return cached;
435
- const data = this.client.apiRequest(method, {
436
- snapshot: this.snapshotId,
437
- project: this.project.id,
438
- objectId: source.id,
439
- });
440
- if (!data)
441
- throw new Error(`${method} returned null signature for ${source.constructor.name} ${source.id}`);
442
- return this.getOrCreateSignature(data);
443
- }
444
- fetchTypes(source, method, handles) {
445
- if (handles) {
446
- const result = new Array(handles.length);
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
- result[i] = cached;
734
+ if (allCached)
735
+ return result;
455
736
  }
456
- if (allCached)
457
- return result;
458
- }
459
- const typesData = this.client.apiRequest(method, {
460
- snapshot: this.snapshotId,
461
- project: this.project.id,
462
- objectId: source.id,
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(source, method, handles) {
470
- return this.snapshotRegistry.fetchSymbols(source, method, handles, this.project.id);
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(source) {
475
- const typesData = this.client.apiRequest("getBaseTypes", {
476
- snapshot: this.snapshotId,
477
- project: this.project.id,
478
- type: source.id,
479
- });
480
- if (typesData == null)
481
- return [];
482
- return typesData.map(data => this.getOrCreateType(data));
483
- }
484
- fetchPropertiesOfType(source) {
485
- const data = this.client.apiRequest("getPropertiesOfType", {
486
- snapshot: this.snapshotId,
487
- project: this.project.id,
488
- type: source.id,
489
- });
490
- return data ? data.map(symbol => this.getOrCreateSymbol(symbol)) : [];
491
- }
492
- fetchApparentPropertiesOfType(source) {
493
- const data = this.client.apiRequest("getApparentPropertiesOfType", {
494
- snapshot: this.snapshotId,
495
- project: this.project.id,
496
- objectId: source.id,
497
- });
498
- return data ? data.map(symbol => this.getOrCreateSymbol(symbol)) : [];
499
- }
500
- fetchPropertyOfType(source, name) {
501
- const data = this.client.apiRequest("getPropertyOfType", {
502
- snapshot: this.snapshotId,
503
- project: this.project.id,
504
- type: source.id,
505
- name,
506
- });
507
- return data ? this.getOrCreateSymbol(data) : undefined;
508
- }
509
- fetchSignaturesOfType(source, kind) {
510
- const data = this.client.apiRequest("getSignaturesOfType", {
511
- snapshot: this.snapshotId,
512
- project: this.project.id,
513
- type: source.id,
514
- kind,
515
- });
516
- return data.map(signature => this.getOrCreateSignature(signature));
517
- }
518
- fetchIndexInfosOfType(source) {
519
- const data = this.client.apiRequest("getIndexInfosOfType", {
520
- snapshot: this.snapshotId,
521
- project: this.project.id,
522
- type: source.id,
523
- });
524
- if (!data)
525
- return [];
526
- return data.map(info => ({
527
- keyType: this.getOrCreateType(info.keyType),
528
- valueType: this.getOrCreateType(info.valueType),
529
- isReadonly: info.isReadonly ?? false,
530
- declaration: info.declaration ? new NodeHandle(info.declaration, this.project) : undefined,
531
- }));
532
- }
533
- fetchTypeParameterAtPosition(source, pos) {
534
- const data = this.client.apiRequest("getTypeParameterAtPosition", {
535
- snapshot: this.snapshotId,
536
- project: this.project.id,
537
- signature: source.id,
538
- index: pos,
539
- });
540
- return this.getOrCreateType(data);
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(file, actions) {
578
- return this.languageService.getImportAdderEdits(file, actions);
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(file, symbols, options = {}) {
582
- return this.languageService.getImportEditsForSymbols(file, symbols, options);
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(file, actions) {
600
- const requestActions = actions.map(action => {
601
- switch (action.kind) {
602
- case "importSymbol":
603
- const importSymbolAction = {
604
- kind: "importSymbol",
605
- symbol: action.symbol.id,
606
- };
607
- if (action.isValidTypeOnlyUseSite !== undefined) {
608
- importSymbolAction.isValidTypeOnlyUseSite = action.isValidTypeOnlyUseSite;
609
- }
610
- return importSymbolAction;
611
- default:
612
- return assertNever(action.kind);
613
- }
614
- });
615
- const data = this.client.apiRequest("getImportAdderEdits", {
616
- snapshot: this.snapshotId,
617
- project: this.project.id,
618
- file,
619
- actions: requestActions,
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(file, symbols, options = {}) {
624
- return this.getImportAdderEdits(file, symbols.map((symbol) => {
625
- if (options.isValidTypeOnlyUseSite !== undefined) {
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;
1146
+ return {
1147
+ isIncomplete: data.isIncomplete,
1148
+ entries: data.entries.map(e => ({
1149
+ ...e,
1150
+ symbol: e.symbol ? owner.objectRegistry.getOrCreateSymbol(e.symbol) : undefined,
1151
+ })),
1152
+ };
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;
632
1164
  return {
633
- kind: "importSymbol",
634
- symbol,
1165
+ isIncomplete: data.isIncomplete,
1166
+ entries: data.entries.map(e => ({
1167
+ ...e,
1168
+ symbol: e.symbol ? owner.objectRegistry.getOrCreateSymbol(e.symbol) : undefined,
1169
+ })),
635
1170
  };
636
- }));
637
- }
638
- getReferencedSymbolsForNode(node, position) {
639
- const data = this.client.apiRequest("getReferencedSymbolsForNode", {
640
- snapshot: this.snapshotId,
641
- project: this.project.id,
642
- node: getNodeId(node),
643
- position,
644
- });
645
- return (data ?? []).map(entry => ({
646
- definition: new NodeHandle(entry.definition, this.project),
647
- symbol: entry.symbol ? this.objectRegistry.getOrCreateSymbol(entry.symbol) : undefined,
648
- references: (entry.references ?? []).map(h => new NodeHandle(h, this.project)),
649
- }));
650
- }
651
- getSignatureUsage(signatureDecl) {
652
- const data = this.client.apiRequest("getSignatureUsages", {
653
- snapshot: this.snapshotId,
654
- project: this.project.id,
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
- };
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(file) {
712
- const fileName = resolveFileName(file);
713
- const path = this.toPath(fileName);
714
- // Check if we already have a retained cache entry for this (snapshot, project) pair
715
- const retained = this.sourceFileCache.getRetained(path, this.snapshotId, this.project.id);
716
- if (retained) {
717
- return retained;
718
- }
719
- // Fetch from server
720
- const binaryData = this.client.apiRequestBinary("getSourceFile", {
721
- snapshot: this.snapshotId,
722
- project: this.project.id,
723
- file,
724
- });
725
- if (!binaryData) {
726
- return undefined;
727
- }
728
- const view = new DataView(binaryData.buffer, binaryData.byteOffset, binaryData.byteLength);
729
- const contentHash = readSourceFileHash(view);
730
- const parseOptionsKey = readParseOptionsKey(view);
731
- // Create a new RemoteSourceFile and cache it (set returns existing if hash matches)
732
- const sourceFile = new RemoteSourceFile(binaryData, this.decoder, this.client.getTimingCollector());
733
- return this.sourceFileCache.set(path, sourceFile, parseOptionsKey, contentHash, this.snapshotId, this.project.id);
734
- }
735
- getSourceFileNames() {
736
- const data = this.client.apiRequest("getSourceFileNames", {
737
- snapshot: this.snapshotId,
738
- project: this.project.id,
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(fileName) {
748
- return this.getSourceFileMetadataByPath(this.toPath(fileName));
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(path) {
757
- let metadata = this.sourceFileMetadataCache.get(path);
758
- if (metadata === undefined) {
759
- metadata = this.fetchSourceFileMetadata(path);
760
- this.sourceFileMetadataCache.set(path, metadata);
761
- }
762
- return metadata;
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(path) {
765
- const data = this.client.apiRequest("getSourceFileMetadata", {
766
- snapshot: this.snapshotId,
767
- project: this.project.id,
768
- file: path,
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(file) {
778
- const metadata = this.getSourceFileMetadataByPath(file.path);
779
- return metadata?.isFromExternalLibrary ?? false;
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(file) {
787
- const metadata = this.getSourceFileMetadataByPath(file.path);
788
- return metadata?.isDefaultLibrary ?? false;
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 data = this.client.apiRequest("getConfigFileNames", {
796
- snapshot: this.snapshotId,
797
- project: this.project.id,
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(file) {
806
- const binaryData = this.client.apiRequestBinary("getConfigSourceFile", {
807
- snapshot: this.snapshotId,
808
- project: this.project.id,
809
- file,
810
- });
811
- if (!binaryData) {
812
- return undefined;
813
- }
814
- return new RemoteSourceFile(binaryData, this.decoder);
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(file) {
821
- const files = file === undefined ? undefined
822
- : Array.isArray(file) ? file
823
- : [file];
824
- const data = this.client.apiRequest("getSyntacticDiagnostics", {
825
- snapshot: this.snapshotId,
826
- project: this.project.id,
827
- ...(files !== undefined ? { files } : {}),
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(file) {
836
- const files = file === undefined ? undefined
837
- : Array.isArray(file) ? file
838
- : [file];
839
- const data = this.client.apiRequest("getBindDiagnostics", {
840
- snapshot: this.snapshotId,
841
- project: this.project.id,
842
- ...(files !== undefined ? { files } : {}),
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(file) {
851
- const files = file === undefined ? undefined
852
- : Array.isArray(file) ? file
853
- : [file];
854
- const data = this.client.apiRequest("getSemanticDiagnostics", {
855
- snapshot: this.snapshotId,
856
- project: this.project.id,
857
- ...(files !== undefined ? { files } : {}),
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(file) {
866
- const files = file === undefined ? undefined
867
- : Array.isArray(file) ? file
868
- : [file];
869
- const data = this.client.apiRequest("getSuggestionDiagnostics", {
870
- snapshot: this.snapshotId,
871
- project: this.project.id,
872
- ...(files !== undefined ? { files } : {}),
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(file) {
881
- const files = file === undefined ? undefined
882
- : Array.isArray(file) ? file
883
- : [file];
884
- const data = this.client.apiRequest("getDeclarationDiagnostics", {
885
- snapshot: this.snapshotId,
886
- project: this.project.id,
887
- ...(files !== undefined ? { files } : {}),
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 data = this.client.apiRequest("getProgramDiagnostics", {
896
- snapshot: this.snapshotId,
897
- project: this.project.id,
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 data = this.client.apiRequest("getGlobalDiagnostics", {
906
- snapshot: this.snapshotId,
907
- project: this.project.id,
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 data = this.client.apiRequest("getConfigFileParsingDiagnostics", {
916
- snapshot: this.snapshotId,
917
- project: this.project.id,
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(emitOnly) {
928
- const response = this.client.apiRequest("emit", {
929
- snapshot: this.snapshotId,
930
- project: this.project.id,
931
- ...(emitOnly !== undefined ? { emitOnly } : {}),
932
- });
933
- return {
934
- emitSkipped: response.emitSkipped,
935
- diagnostics: response.diagnostics,
936
- emittedFiles: response.emittedFiles,
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(emitOnly) {
943
- const response = this.client.apiRequest("emitToString", {
944
- snapshot: this.snapshotId,
945
- project: this.project.id,
946
- ...(emitOnly !== undefined ? { emitOnly } : {}),
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(files) {
954
- const response = this.client.apiRequest("getJavaScriptEmit", {
955
- snapshot: this.snapshotId,
956
- project: this.project.id,
957
- files,
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(files) {
965
- const response = this.client.apiRequest("getDeclarationEmit", {
966
- snapshot: this.snapshotId,
967
- project: this.project.id,
968
- files,
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,543 +1719,1219 @@ export class Checker {
997
1719
  dispose() {
998
1720
  this.objectRegistry.clear();
999
1721
  }
1000
- getSymbolAtLocation(nodeOrNodes) {
1001
- if (Array.isArray(nodeOrNodes)) {
1002
- const data = this.client.apiRequest("getSymbolsAtLocations", {
1003
- snapshot: this.snapshotId,
1004
- project: this.project.id,
1005
- locations: nodeOrNodes.map(node => getNodeId(node)),
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.map(d => d ? this.objectRegistry.getOrCreateSymbol(d) : undefined);
1738
+ return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
1008
1739
  }
1009
- const data = this.client.apiRequest("getSymbolAtLocation", {
1010
- snapshot: this.snapshotId,
1011
- project: this.project.id,
1012
- location: getNodeId(nodeOrNodes),
1013
- });
1014
- return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
1015
- }
1016
- getSymbolAtPosition(file, positionOrPositions) {
1017
- if (typeof positionOrPositions === "number") {
1018
- const data = this.client.apiRequest("getSymbolAtPosition", {
1019
- snapshot: this.snapshotId,
1020
- project: this.project.id,
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
- position: positionOrPositions,
1774
+ positions: positionOrPositions,
1023
1775
  });
1024
- return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
1776
+ return data.map(d => d ? owner.objectRegistry.getOrCreateSymbol(d) : undefined);
1025
1777
  }
1026
- const data = this.client.apiRequest("getSymbolsAtPositions", {
1027
- snapshot: this.snapshotId,
1028
- project: this.project.id,
1029
- file,
1030
- positions: positionOrPositions,
1031
- });
1032
- return data.map(d => d ? this.objectRegistry.getOrCreateSymbol(d) : undefined);
1033
- }
1034
- getSymbolOfSourceFile(fileOrFiles) {
1035
- if (Array.isArray(fileOrFiles)) {
1036
- const data = this.client.apiRequest("getSymbolsOfSourceFiles", {
1037
- snapshot: this.snapshotId,
1038
- project: this.project.id,
1039
- files: fileOrFiles,
1040
- });
1041
- return data.map(d => d ? this.objectRegistry.getOrCreateSymbol(d) : undefined);
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
- const data = this.client.apiRequest("getSymbolOfSourceFile", {
1044
- snapshot: this.snapshotId,
1045
- project: this.project.id,
1046
- file: fileOrFiles,
1047
- });
1048
- return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
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
- getTypeOfSymbol(symbolOrSymbols) {
1051
- if (Array.isArray(symbolOrSymbols)) {
1052
- const data = this.client.apiRequest("getTypesOfSymbols", {
1053
- snapshot: this.snapshotId,
1054
- project: this.project.id,
1055
- symbols: symbolOrSymbols.map(s => s.id),
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 data.map(d => this.objectRegistry.getOrCreateType(d));
1855
+ return owner.objectRegistry.getOrCreateType(data);
1058
1856
  }
1059
- const data = this.client.apiRequest("getTypeOfSymbol", {
1060
- snapshot: this.snapshotId,
1061
- project: this.project.id,
1062
- symbol: symbolOrSymbols.id,
1063
- });
1064
- return this.objectRegistry.getOrCreateType(data);
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(symbol) {
1072
- const data = this.client.apiRequest("getDeclaredTypeOfSymbol", {
1073
- snapshot: this.snapshotId,
1074
- project: this.project.id,
1075
- symbol: symbol.id,
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);
1076
1896
  });
1077
- return this.objectRegistry.getOrCreateType(data);
1078
1897
  }
1079
- getReferencesToSymbolInFile(file, symbol) {
1080
- const data = this.client.apiRequest("getReferencesToSymbolInFile", {
1081
- snapshot: this.snapshotId,
1082
- project: this.project.id,
1083
- file,
1084
- symbol: symbol.id,
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);
1920
+ });
1921
+ }
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(node, position) {
1090
- return this.project.languageService.getReferencedSymbolsForNode(node, position);
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(signatureDecl) {
1094
- return this.project.languageService.getSignatureUsage(signatureDecl);
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(document, position, options) {
1098
- return this.project.languageService.getCompletionsAtPosition(document, position, options);
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
- getTypeAtLocation(nodeOrNodes) {
1101
- if (Array.isArray(nodeOrNodes)) {
1102
- const data = this.client.apiRequest("getTypeAtLocations", {
1103
- snapshot: this.snapshotId,
1104
- project: this.project.id,
1105
- locations: nodeOrNodes.map(node => getNodeId(node)),
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 data.map(d => this.objectRegistry.getOrCreateType(d));
1990
+ return owner.objectRegistry.getOrCreateType(data);
1108
1991
  }
1109
- const data = this.client.apiRequest("getTypeAtLocation", {
1110
- snapshot: this.snapshotId,
1111
- project: this.project.id,
1112
- location: getNodeId(nodeOrNodes),
1113
- });
1114
- return this.objectRegistry.getOrCreateType(data);
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(type, kind) {
1117
- return kind === SignatureKind.Call ? type.getCallSignatures() : type.getConstructSignatures();
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(node) {
1125
- const data = this.client.apiRequest("getResolvedSignature", {
1126
- snapshot: this.snapshotId,
1127
- project: this.project.id,
1128
- location: getNodeId(node),
1129
- });
1130
- return this.objectRegistry.getOrCreateSignature(data);
1131
- }
1132
- getTypeAtPosition(file, positionOrPositions) {
1133
- if (typeof positionOrPositions === "number") {
1134
- const data = this.client.apiRequest("getTypeAtPosition", {
1135
- snapshot: this.snapshotId,
1136
- project: this.project.id,
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,
1137
2056
  file,
1138
- position: positionOrPositions,
2057
+ positions: positionOrPositions,
1139
2058
  });
1140
- return data ? this.objectRegistry.getOrCreateType(data) : undefined;
2059
+ return data.map(d => d ? owner.objectRegistry.getOrCreateType(d) : undefined);
1141
2060
  }
1142
- const data = this.client.apiRequest("getTypesAtPositions", {
1143
- snapshot: this.snapshotId,
1144
- project: this.project.id,
1145
- file,
1146
- positions: positionOrPositions,
1147
- });
1148
- return data.map(d => d ? this.objectRegistry.getOrCreateType(d) : undefined);
1149
- }
1150
- resolveName(name, meaning, location, excludeGlobals) {
1151
- // Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
1152
- const isNode = location && "kind" in location;
1153
- const data = this.client.apiRequest("resolveName", {
1154
- snapshot: this.snapshotId,
1155
- project: this.project.id,
1156
- name,
1157
- meaning,
1158
- ...(isNode ? { location: getNodeId(location) } : {}),
1159
- ...(!isNode && location
1160
- ? {
1161
- file: location.document,
1162
- position: location.position,
1163
- }
1164
- : {}),
1165
- ...(excludeGlobals !== undefined ? { excludeGlobals } : {}),
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,
2074
+ file,
2075
+ positions: positionOrPositions,
2076
+ });
2077
+ return data.map(d => d ? owner.objectRegistry.getOrCreateType(d) : undefined);
2078
+ }
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(location, meaning) {
1173
- // Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
1174
- const isNode = "kind" in location;
1175
- const data = this.client.apiRequest("getSymbolsInScope", {
1176
- snapshot: this.snapshotId,
1177
- project: this.project.id,
1178
- meaning,
1179
- ...(isNode
1180
- ? { location: getNodeId(location) }
1181
- : {
1182
- file: location.document,
1183
- position: location.position,
1184
- }),
1185
- });
1186
- return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
1187
- }
1188
- getResolvedSymbol(node) {
1189
- const text = node.text;
1190
- if (!text)
1191
- return undefined;
1192
- return this.resolveName(text, SymbolFlags.Value | SymbolFlags.ExportValue, node);
1193
- }
1194
- getContextualType(node) {
1195
- const data = this.client.apiRequest("getContextualType", {
1196
- snapshot: this.snapshotId,
1197
- project: this.project.id,
1198
- location: getNodeId(node),
1199
- });
1200
- return data ? this.objectRegistry.getOrCreateType(data) : undefined;
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(type) {
1204
- const data = this.client.apiRequest("getBaseTypeOfLiteralType", {
1205
- snapshot: this.snapshotId,
1206
- project: this.project.id,
1207
- type: type.id,
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(type) {
1213
- return type.getNonNullableType();
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(node) {
1221
- const data = this.client.apiRequest("getTypeFromTypeNode", {
1222
- snapshot: this.snapshotId,
1223
- project: this.project.id,
1224
- location: getNodeId(node),
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(type) {
1230
- const data = this.client.apiRequest("getWidenedType", {
1231
- snapshot: this.snapshotId,
1232
- project: this.project.id,
1233
- type: type.id,
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(signature, index) {
1242
- const data = this.client.apiRequest("getParameterType", {
1243
- snapshot: this.snapshotId,
1244
- project: this.project.id,
1245
- signature: signature.id,
1246
- index,
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(type) {
1251
- return this.client.apiRequest("isArrayLikeType", {
1252
- snapshot: this.snapshotId,
1253
- project: this.project.id,
1254
- type: type.id,
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(source, target) {
1258
- return this.client.apiRequest("isTypeAssignableTo", {
1259
- snapshot: this.snapshotId,
1260
- project: this.project.id,
1261
- source: source.id,
1262
- target: target.id,
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(node) {
1266
- const data = this.client.apiRequest("getShorthandAssignmentValueSymbol", {
1267
- snapshot: this.snapshotId,
1268
- project: this.project.id,
1269
- location: getNodeId(node),
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(symbol, location) {
1279
- const data = this.client.apiRequest("getTypeOfSymbolAtLocation", {
1280
- snapshot: this.snapshotId,
1281
- project: this.project.id,
1282
- symbol: symbol.id,
1283
- location: getNodeId(location),
1284
- });
1285
- return this.objectRegistry.getOrCreateType(data);
1286
- }
1287
- getIntrinsicType(method) {
1288
- const data = this.client.apiRequest(method, {
1289
- snapshot: this.snapshotId,
1290
- project: this.project.id,
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
- }
1327
- getNonPrimitiveType() {
1328
- return this.getIntrinsicType("getNonPrimitiveType");
1329
2360
  }
1330
- typeToTypeNode(type, enclosingDeclaration, flags) {
1331
- const binaryData = this.client.apiRequestBinary("typeToTypeNode", {
1332
- snapshot: this.snapshotId,
1333
- project: this.project.id,
1334
- type: type.id,
1335
- ...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
1336
- ...(flags !== undefined ? { flags } : {}),
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
- signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags) {
1343
- const binaryData = this.client.apiRequestBinary("signatureToSignatureDeclaration", {
1344
- snapshot: this.snapshotId,
1345
- project: this.project.id,
1346
- signature: signature.id,
1347
- kind,
1348
- ...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
1349
- ...(flags !== undefined ? { flags } : {}),
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
- typeToString(type, enclosingDeclaration, flags) {
1356
- const result = this.client.apiRequest("typeToString", {
1357
- snapshot: this.snapshotId,
1358
- project: this.project.id,
1359
- type: type.id,
1360
- ...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
1361
- ...(flags !== undefined ? { flags } : {}),
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
- isContextSensitive(node) {
1368
- return this.client.apiRequest("isContextSensitive", {
1369
- snapshot: this.snapshotId,
1370
- project: this.project.id,
1371
- location: getNodeId(node),
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
- isArrayType(type) {
1375
- return this.client.apiRequest("isArrayType", {
1376
- snapshot: this.snapshotId,
1377
- project: this.project.id,
1378
- type: type.id,
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
- isTupleType(type) {
1382
- return this.client.apiRequest("isTupleType", {
1383
- snapshot: this.snapshotId,
1384
- project: this.project.id,
1385
- type: type.id,
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(signature) {
1390
- return signature.getReturnType();
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(signature) {
1397
- const data = this.client.apiRequest("getRestTypeOfSignature", {
1398
- snapshot: this.snapshotId,
1399
- project: this.project.id,
1400
- signature: signature.id,
1401
- });
1402
- return this.objectRegistry.getOrCreateType(data);
1403
- }
1404
- getTypePredicateOfSignature(signature) {
1405
- const data = this.client.apiRequest("getTypePredicateOfSignature", {
1406
- snapshot: this.snapshotId,
1407
- project: this.project.id,
1408
- signature: signature.id,
1409
- });
1410
- if (!data)
1411
- return undefined;
1412
- return {
1413
- kind: data.kind,
1414
- parameterIndex: data.parameterIndex,
1415
- parameterName: data.parameterName,
1416
- type: data.type ? this.objectRegistry.getOrCreateType(data.type) : undefined,
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(type) {
1424
- return type.getBaseTypes() ?? [];
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(type) {
1428
- return type.getApparentType();
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(type) {
1432
- return type.getReducedType();
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(type) {
1435
- return type.getProperties();
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(type) {
1438
- return type.getIndexInfos();
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(type) {
1445
- return type.getConstraint();
1446
- }
1447
- getDefaultFromTypeParameter(type) {
1448
- return type.getDefault();
1449
- }
1450
- getBaseConstraintOfType(type) {
1451
- const data = this.client.apiRequest("getBaseConstraintOfType", {
1452
- snapshot: this.snapshotId,
1453
- project: this.project.id,
1454
- type: type.id,
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(type, name) {
1459
- const data = this.client.apiRequest("getPropertyOfType", {
1460
- snapshot: this.snapshotId,
1461
- project: this.project.id,
1462
- type: type.id,
1463
- name,
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(node) {
1468
- const data = this.client.apiRequest("getConstantValue", {
1469
- snapshot: this.snapshotId,
1470
- project: this.project.id,
1471
- location: getNodeId(node),
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(node) {
1477
- const data = this.client.apiRequest("getSignatureFromDeclaration", {
1478
- snapshot: this.snapshotId,
1479
- project: this.project.id,
1480
- location: getNodeId(node),
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(node) {
1485
- const data = this.client.apiRequest("getExportSpecifierLocalTargetSymbol", {
1486
- snapshot: this.snapshotId,
1487
- project: this.project.id,
1488
- location: getNodeId(node),
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(symbol) {
1498
- const data = this.client.apiRequest("getAliasedSymbol", {
1499
- snapshot: this.snapshotId,
1500
- project: this.project.id,
1501
- symbol: symbol.id,
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(symbol) {
1510
- return this.client.apiRequest("getFullyQualifiedName", {
1511
- snapshot: this.snapshotId,
1512
- project: this.project.id,
1513
- symbol: symbol.id,
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
+ });
1514
2889
  });
1515
2890
  }
1516
- getImmediateAliasedSymbol(symbol) {
1517
- const data = this.client.apiRequest("getImmediateAliasedSymbol", {
1518
- snapshot: this.snapshotId,
1519
- project: this.project.id,
1520
- symbol: symbol.id,
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;
1521
2907
  });
1522
- return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
1523
2908
  }
1524
2909
  /**
1525
2910
  * Get the target symbol if instantiated, or the provided symbol otherwise.
1526
2911
  */
1527
- getTargetSymbol(symbol) {
1528
- if (symbol.checkFlags & CheckFlags.Instantiated) {
1529
- const data = this.client.apiRequest("getTargetSymbol", {
1530
- snapshot: this.snapshotId,
1531
- project: this.project.id,
1532
- symbol: symbol.id,
1533
- });
1534
- return this.objectRegistry.getOrCreateSymbol(data);
1535
- }
1536
- return symbol;
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;
2934
+ });
1537
2935
  }
1538
2936
  /**
1539
2937
  * Fetch (once, then cache) the handle ids of the per-checker singleton
@@ -1541,40 +2939,71 @@ export class Checker {
1541
2939
  * of the project's checker, so identity checks against them are local after
1542
2940
  * the first call.
1543
2941
  */
1544
- getWellKnownSymbols() {
1545
- return this.wellKnownSymbols ??= this.client.apiRequest("getWellKnownSymbols", {
1546
- snapshot: this.snapshotId,
1547
- project: this.project.id,
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
+ });
1548
2954
  });
1549
2955
  }
1550
2956
  /**
1551
2957
  * Returns `true` if the symbol is the checker's "unknown" symbol (e.g. the
1552
2958
  * result of {@link Checker.getAliasedSymbol} on an unresolved alias).
1553
2959
  */
1554
- isUnknownSymbol(symbol) {
1555
- return symbol.id === (this.getWellKnownSymbols()).unknown;
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
+ });
1556
2967
  }
1557
2968
  /**
1558
2969
  * Returns `true` if the symbol is the checker's "undefined" symbol.
1559
2970
  */
1560
- isUndefinedSymbol(symbol) {
1561
- return symbol.id === (this.getWellKnownSymbols()).undefined;
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
+ });
1562
2978
  }
1563
2979
  /**
1564
2980
  * Returns `true` if the symbol is the checker's "arguments" symbol.
1565
2981
  */
1566
- isArgumentsSymbol(symbol) {
1567
- return symbol.id === (this.getWellKnownSymbols()).arguments;
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
+ });
1568
2989
  }
1569
2990
  /**
1570
2991
  * Fetch (once, then cache) the handle id of the per-checker unknown
1571
2992
  * signature. This id is stable for the life of the project's checker, so
1572
2993
  * identity checks against it are local after the first call.
1573
2994
  */
1574
- getWellKnownSignatures() {
1575
- return this.wellKnownSignatures ??= this.client.apiRequest("getWellKnownSignatures", {
1576
- snapshot: this.snapshotId,
1577
- project: this.project.id,
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
+ });
1578
3007
  });
1579
3008
  }
1580
3009
  /**
@@ -1582,51 +3011,106 @@ export class Checker {
1582
3011
  * the result of {@link Checker.getResolvedSignature} on a call that cannot be
1583
3012
  * resolved).
1584
3013
  */
1585
- isUnknownSignature(signature) {
1586
- return signature.id === (this.getWellKnownSignatures()).unknown;
1587
- }
1588
- getExportsOfModule(symbol) {
1589
- const data = this.client.apiRequest("getExportsOfModule", {
1590
- snapshot: this.snapshotId,
1591
- project: this.project.id,
1592
- symbol: symbol.id,
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)) : [];
1593
3038
  });
1594
- return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
1595
3039
  }
1596
- getMemberInModuleExports(symbol, name) {
1597
- const data = this.client.apiRequest("getMemberInModuleExports", {
1598
- snapshot: this.snapshotId,
1599
- project: this.project.id,
1600
- symbol: symbol.id,
1601
- name,
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;
1602
3058
  });
1603
- return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
1604
3059
  }
1605
- getJsDocTagsOfSymbol(symbol) {
1606
- const data = this.client.apiRequest("getJsDocTags", {
1607
- snapshot: this.snapshotId,
1608
- project: this.project.id,
1609
- symbol: symbol.id,
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 ?? [];
1610
3076
  });
1611
- return data ?? [];
1612
3077
  }
1613
- getDocumentationCommentOfSymbol(symbol) {
1614
- return this.client.apiRequest("getDocumentationComment", {
1615
- snapshot: this.snapshotId,
1616
- project: this.project.id,
1617
- symbol: symbol.id,
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
+ });
1618
3092
  });
1619
3093
  }
1620
3094
  /**
1621
3095
  * Get the type arguments of a type reference (e.g. the `string` in `Array<string>`).
1622
3096
  */
1623
- getTypeArguments(type) {
1624
- const data = this.client.apiRequest("getTypeArguments", {
1625
- snapshot: this.snapshotId,
1626
- project: this.project.id,
1627
- type: type.id,
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)) : [];
1628
3113
  });
1629
- return data ? data.map(d => this.objectRegistry.getOrCreateType(d)) : [];
1630
3114
  }
1631
3115
  }
1632
3116
  export class Emitter {
@@ -1634,14 +3118,26 @@ export class Emitter {
1634
3118
  constructor(client) {
1635
3119
  this.client = client;
1636
3120
  }
1637
- printNode(node, options = {}) {
1638
- const encoded = encodeNode(node);
1639
- const base64 = uint8ArrayToBase64(encoded);
1640
- return this.client.apiRequest("printNode", {
1641
- data: base64,
1642
- ...(options.preserveSourceNewlines !== undefined ? { preserveSourceNewlines: options.preserveSourceNewlines } : {}),
1643
- ...(options.neverAsciiEscape !== undefined ? { neverAsciiEscape: options.neverAsciiEscape } : {}),
1644
- ...(options.terminateUnterminatedLiterals !== undefined ? { terminateUnterminatedLiterals: options.terminateUnterminatedLiterals } : {}),
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
+ });
1645
3141
  });
1646
3142
  }
1647
3143
  }
@@ -1661,22 +3157,42 @@ export class SnapshotInternalAPI {
1661
3157
  * @param position The UTF-16 code-unit offset in the target file for insertion.
1662
3158
  * @returns The formatted text of the node, indented for the insertion position.
1663
3159
  */
1664
- formatNodeForInsertion(node, file, position) {
1665
- const data = this.client.apiRequest("getDefaultProjectForFile", {
1666
- snapshot: this.snapshotId,
1667
- file,
1668
- });
1669
- if (!data) {
1670
- throw new Error(`No project found for file: ${typeof file === "string" ? file : file.uri}`);
1671
- }
1672
- const encoded = encodeNode(node);
1673
- const base64 = uint8ArrayToBase64(encoded);
1674
- return this.client.apiRequest("formatNodeForInsertion", {
1675
- snapshot: this.snapshotId,
1676
- project: data.id,
1677
- file,
1678
- position,
1679
- data: base64,
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
+ });
1680
3196
  });
1681
3197
  }
1682
3198
  }
@@ -1702,12 +3218,21 @@ export class NodeHandle {
1702
3218
  * and looking up the node by index. If no project is passed, the project that produced
1703
3219
  * the handle is used.
1704
3220
  */
1705
- resolve(project = this.canonicalProject) {
1706
- const sourceFile = project.program.getSourceFile(this.path);
1707
- if (!sourceFile) {
1708
- return undefined;
1709
- }
1710
- return sourceFile.getOrCreateNodeAtIndex(this.index);
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
+ });
1711
3236
  }
1712
3237
  }
1713
3238
  export class Symbol {
@@ -1750,41 +3275,83 @@ export class Symbol {
1750
3275
  if (data.exportSymbol !== undefined)
1751
3276
  this.exportSymbol = data.exportSymbol;
1752
3277
  }
1753
- getParent() {
1754
- return this.objectRegistry.fetchSymbol(this, "getParentOfSymbol", this.parent, this.canonicalProject.id);
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
+ });
1755
3285
  }
1756
3286
  /**
1757
3287
  * Get this symbol's members keyed by escaped name. The result is cached on
1758
3288
  * the symbol, so repeated calls do not round-trip to the server.
1759
3289
  */
1760
- getMembers() {
1761
- return this.membersCache ??= this.fetchSymbolTable("getMembersOfSymbol");
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
+ });
1762
3297
  }
1763
3298
  /**
1764
3299
  * Get this symbol's exports keyed by escaped name. The result is cached on
1765
3300
  * the symbol, so repeated calls do not round-trip to the server.
1766
3301
  */
1767
- getExports() {
1768
- return this.exportsCache ??= this.fetchSymbolTable("getExportsOfSymbol");
1769
- }
1770
- fetchSymbolTable(method) {
1771
- const symbols = this.objectRegistry.fetchSymbols(this, method, undefined, this.canonicalProject.id);
1772
- const table = new Map();
1773
- for (const symbol of symbols) {
1774
- table.set(symbol.escapedName, symbol);
1775
- }
1776
- return table;
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
+ });
1777
3327
  }
1778
- getExportSymbol() {
1779
- if (!this.exportSymbol)
1780
- return this;
1781
- return this.objectRegistry.fetchSymbol(this, "getExportSymbolOfSymbol", this.exportSymbol, this.canonicalProject.id);
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
+ });
1782
3339
  }
1783
- getJsDocTags(checker) {
1784
- return checker.getJsDocTagsOfSymbol(this);
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
+ });
1785
3347
  }
1786
- getDocumentationComment(checker) {
1787
- return checker.getDocumentationCommentOfSymbol(this);
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
+ });
1788
3355
  }
1789
3356
  }
1790
3357
  class TypeObject {
@@ -1902,162 +3469,381 @@ class TypeObject {
1902
3469
  this.stringIndexType = false;
1903
3470
  this.numberIndexType = false;
1904
3471
  }
1905
- getSymbol() {
1906
- return this.objectRegistry.fetchSymbol(this, "getSymbolOfType", this.symbol);
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
+ });
1907
3479
  }
1908
- getProperties() {
1909
- if (this.properties === false) {
1910
- this.properties = this.objectRegistry.fetchPropertiesOfType(this);
1911
- }
1912
- return this.properties;
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
+ });
1913
3493
  }
1914
- getProperty(propertyName) {
1915
- return this.objectRegistry.fetchPropertyOfType(this, propertyName);
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
+ });
1916
3501
  }
1917
- getApparentProperties() {
1918
- if (this.apparentProperties === false) {
1919
- this.apparentProperties = this.objectRegistry.fetchApparentPropertiesOfType(this);
1920
- }
1921
- return this.apparentProperties;
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
+ });
1922
3515
  }
1923
- getCallSignatures() {
1924
- if (this.callSignatures === false) {
1925
- this.callSignatures = this.objectRegistry.fetchSignaturesOfType(this, SignatureKind.Call);
1926
- }
1927
- return this.callSignatures;
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
+ });
1928
3529
  }
1929
- getConstructSignatures() {
1930
- if (this.constructSignatures === false) {
1931
- this.constructSignatures = this.objectRegistry.fetchSignaturesOfType(this, SignatureKind.Construct);
1932
- }
1933
- return this.constructSignatures;
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
+ });
1934
3543
  }
1935
- getNonNullableType() {
1936
- const result = this.objectRegistry.fetchType(this, "getNonNullableType", this.nonNullableType);
1937
- this.nonNullableType = result.id;
1938
- return result;
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
+ });
1939
3555
  }
1940
- getStringIndexType() {
1941
- if (this.stringIndexType === false) {
1942
- this.stringIndexType = this.getStringIndexTypeWorker();
1943
- }
1944
- return this.stringIndexType;
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
+ });
1945
3569
  }
1946
- getStringIndexTypeWorker() {
1947
- const infos = this.getIndexInfos();
1948
- return infos.find(info => (info.keyType.flags & TypeFlags.String) !== 0)?.valueType;
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
+ });
1949
3579
  }
1950
- getNumberIndexType() {
1951
- if (this.numberIndexType === false) {
1952
- this.numberIndexType = this.getNumberIndexTypeWorker();
1953
- }
1954
- return this.numberIndexType;
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
+ });
1955
3593
  }
1956
- getNumberIndexTypeWorker() {
1957
- const infos = this.getIndexInfos();
1958
- return infos.find(info => (info.keyType.flags & TypeFlags.Number) !== 0)?.valueType;
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
+ });
1959
3603
  }
1960
- getApparentType() {
1961
- const result = this.objectRegistry.fetchType(this, "getApparentType", this.apparentType);
1962
- this.apparentType = result.id;
1963
- return result;
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
+ });
1964
3615
  }
1965
- getReducedType() {
1966
- const result = this.objectRegistry.fetchType(this, "getReducedType", this.reducedType);
1967
- this.reducedType = result.id;
1968
- return result;
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
+ });
1969
3627
  }
1970
- getIndexInfos() {
1971
- if (this.indexInfos === false) {
1972
- this.indexInfos = this.objectRegistry.fetchIndexInfosOfType(this);
1973
- }
1974
- return this.indexInfos;
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
+ });
1975
3641
  }
1976
- getAliasSymbol() {
1977
- return this.objectRegistry.fetchSymbol(this, "getAliasSymbolOfType", this.aliasSymbol);
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
+ });
1978
3649
  }
1979
- getTarget() {
1980
- return this.objectRegistry.fetchType(this, "getTargetOfType", this.target);
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
+ });
1981
3657
  }
1982
- getFreshType() {
1983
- return this.objectRegistry.fetchOptionalType(this, "getFreshTypeOfType", this.freshType);
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
+ });
1984
3665
  }
1985
- getRegularType() {
1986
- return this.objectRegistry.fetchOptionalType(this, "getRegularTypeOfType", this.regularType);
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
+ });
1987
3673
  }
1988
- getTypes() {
1989
- // Only union, intersection, and template literal types have constituent
1990
- // types; any other kind has none, so return undefined rather than sending
1991
- // a request the server cannot satisfy.
1992
- if (!(this.flags & (TypeFlags.UnionOrIntersection | TypeFlags.TemplateLiteral))) {
1993
- return undefined;
1994
- }
1995
- return this.objectRegistry.fetchTypes(this, "getTypesOfType");
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
+ });
1996
3693
  }
1997
- getTypeParameters() {
1998
- return this.objectRegistry.fetchTypes(this, "getTypeParametersOfType", this.typeParameters);
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
+ });
1999
3701
  }
2000
- getOuterTypeParameters() {
2001
- return this.objectRegistry.fetchTypes(this, "getOuterTypeParametersOfType", this.outerTypeParameters);
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
+ });
2002
3709
  }
2003
- getLocalTypeParameters() {
2004
- return this.objectRegistry.fetchTypes(this, "getLocalTypeParametersOfType", this.localTypeParameters);
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
+ });
2005
3717
  }
2006
- getAliasTypeArguments() {
2007
- return this.objectRegistry.fetchTypes(this, "getAliasTypeArgumentsOfType", this.aliasTypeArguments);
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
+ });
2008
3725
  }
2009
- getObjectType() {
2010
- return this.objectRegistry.fetchType(this, "getObjectTypeOfType", this.objectType);
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
+ });
2011
3733
  }
2012
- getIndexType() {
2013
- return this.objectRegistry.fetchType(this, "getIndexTypeOfType", this.indexType);
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
+ });
2014
3741
  }
2015
- getCheckType() {
2016
- return this.objectRegistry.fetchType(this, "getCheckTypeOfType", this.checkType);
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
+ });
2017
3749
  }
2018
- getExtendsType() {
2019
- return this.objectRegistry.fetchType(this, "getExtendsTypeOfType", this.extendsType);
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
+ });
2020
3757
  }
2021
- getBaseType() {
2022
- return this.objectRegistry.fetchType(this, "getBaseTypeOfType", this.baseType);
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
+ });
2023
3765
  }
2024
- getConstraint() {
2025
- // Type parameters resolve their constraint lazily through the checker,
2026
- // whereas substitution types carry a preloaded constraint handle.
2027
- if (this.flags & TypeFlags.TypeParameter) {
2028
- const result = this.objectRegistry.fetchOptionalType(this, "getConstraintOfTypeParameter", this.constraint);
2029
- this.constraint = result ? result.id : 0;
2030
- return result;
2031
- }
2032
- return this.objectRegistry.fetchType(this, "getConstraintOfType", this.substConstraint);
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
+ });
2033
3787
  }
2034
- getDefault() {
2035
- const result = this.objectRegistry.fetchOptionalType(this, "getDefaultFromTypeParameter", this.default);
2036
- this.default = result ? result.id : 0;
2037
- return result;
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
+ });
2038
3799
  }
2039
- getTrueType() {
2040
- const result = this.objectRegistry.fetchType(this, "getTrueTypeOfConditionalType", this.trueType);
2041
- this.trueType = result.id;
2042
- return result;
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
+ });
2043
3811
  }
2044
- getFalseType() {
2045
- const result = this.objectRegistry.fetchType(this, "getFalseTypeOfConditionalType", this.falseType);
2046
- this.falseType = result.id;
2047
- return result;
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
+ });
2048
3823
  }
2049
3824
  /**
2050
3825
  * Get the base types of this type. Returns `undefined` for any type that is
2051
3826
  * not a class or interface.
2052
3827
  */
2053
- getBaseTypes() {
2054
- if (!this.isClassOrInterface()) {
2055
- return undefined;
2056
- }
2057
- if (this.baseTypes === false) {
2058
- this.baseTypes = this.objectRegistry.fetchBaseTypes(this);
2059
- }
2060
- return this.baseTypes;
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
+ });
2061
3847
  }
2062
3848
  isClassOrInterface() {
2063
3849
  return isClassOrInterfaceType(this);
@@ -2207,25 +3993,57 @@ export class Signature {
2207
3993
  this.target = data.target;
2208
3994
  this.returnType = false;
2209
3995
  }
2210
- getTypeParameters() {
2211
- return this.objectRegistry.fetchTypes(this, "getTypeParametersOfSignature", this.typeParameters);
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
+ });
2212
4003
  }
2213
- getParameters() {
2214
- return this.objectRegistry.fetchSymbols(this, "getParametersOfSignature", this.parameters);
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
+ });
2215
4011
  }
2216
- getThisParameter() {
2217
- return this.objectRegistry.fetchSymbol(this, "getThisParameterOfSignature", this.thisParameter);
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
+ });
2218
4019
  }
2219
- getTarget() {
2220
- return this.objectRegistry.fetchSignature(this, "getTargetOfSignature", this.target);
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
+ });
2221
4027
  }
2222
- getReturnType() {
2223
- const result = this.objectRegistry.fetchType(this, "getReturnTypeOfSignature", this.returnType);
2224
- this.returnType = result.id;
2225
- return result;
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
+ });
2226
4039
  }
2227
- getTypeParameterAtPosition(pos) {
2228
- return this.objectRegistry.fetchTypeParameterAtPosition(this, pos);
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
+ });
2229
4047
  }
2230
4048
  get hasRestParameter() {
2231
4049
  return (this.flags & SignatureFlags.HasRestParameter) !== 0;