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