vscode-apollo 1.19.3 → 1.20.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 (156) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +14 -0
  3. package/.circleci/config.yml +82 -0
  4. package/.eslintrc.js +10 -0
  5. package/.gitattributes +1 -0
  6. package/.github/workflows/build-prs.yml +57 -0
  7. package/.github/workflows/release.yml +114 -0
  8. package/.gitleaks.toml +26 -0
  9. package/.nvmrc +1 -0
  10. package/.prettierrc +5 -0
  11. package/.vscode/launch.json +61 -0
  12. package/.vscode/settings.json +16 -0
  13. package/.vscode/tasks.json +18 -0
  14. package/.vscodeignore +17 -1
  15. package/CHANGELOG.md +178 -1
  16. package/LICENSE +2 -2
  17. package/README.md +9 -9
  18. package/codegen.yml +12 -0
  19. package/images/IconRun.svg +8 -0
  20. package/jest.config.ts +11 -0
  21. package/package.json +102 -22
  22. package/renovate.json +23 -0
  23. package/src/__mocks__/fs.js +3 -0
  24. package/src/__tests__/statusBar.test.ts +8 -7
  25. package/src/debug.ts +2 -5
  26. package/src/env/fetch/fetch.ts +32 -0
  27. package/src/env/fetch/global.ts +30 -0
  28. package/src/env/fetch/index.d.ts +2 -0
  29. package/src/env/fetch/index.ts +2 -0
  30. package/src/env/fetch/url.ts +9 -0
  31. package/src/env/index.ts +4 -0
  32. package/src/env/polyfills/array.ts +17 -0
  33. package/src/env/polyfills/index.ts +2 -0
  34. package/src/env/polyfills/object.ts +7 -0
  35. package/src/env/typescript-utility-types.ts +2 -0
  36. package/src/extension.ts +106 -37
  37. package/src/language-server/__tests__/diagnostics.test.ts +86 -0
  38. package/src/language-server/__tests__/document.test.ts +187 -0
  39. package/src/language-server/__tests__/fileSet.test.ts +46 -0
  40. package/src/language-server/__tests__/fixtures/starwarsSchema.ts +1917 -0
  41. package/src/language-server/config/__tests__/config.ts +128 -0
  42. package/src/language-server/config/__tests__/loadConfig.ts +508 -0
  43. package/src/language-server/config/__tests__/utils.ts +106 -0
  44. package/src/language-server/config/config.ts +219 -0
  45. package/src/language-server/config/index.ts +3 -0
  46. package/src/language-server/config/loadConfig.ts +228 -0
  47. package/src/language-server/config/utils.ts +56 -0
  48. package/src/language-server/diagnostics.ts +109 -0
  49. package/src/language-server/document.ts +277 -0
  50. package/src/language-server/engine/GraphQLDataSource.ts +124 -0
  51. package/src/language-server/engine/index.ts +105 -0
  52. package/src/language-server/engine/operations/frontendUrlRoot.ts +7 -0
  53. package/src/language-server/engine/operations/schemaTagsAndFieldStats.ts +24 -0
  54. package/src/language-server/errors/__tests__/NoMissingClientDirectives.test.ts +220 -0
  55. package/src/language-server/errors/logger.ts +58 -0
  56. package/src/language-server/errors/validation.ts +277 -0
  57. package/src/language-server/fileSet.ts +65 -0
  58. package/src/language-server/format.ts +48 -0
  59. package/src/language-server/graphqlTypes.ts +7176 -0
  60. package/src/language-server/index.ts +29 -0
  61. package/src/language-server/languageProvider.ts +798 -0
  62. package/src/language-server/loadingHandler.ts +64 -0
  63. package/src/language-server/project/base.ts +399 -0
  64. package/src/language-server/project/client.ts +602 -0
  65. package/src/language-server/project/defaultClientSchema.ts +45 -0
  66. package/src/language-server/project/service.ts +48 -0
  67. package/src/language-server/providers/schema/__tests__/file.ts +150 -0
  68. package/src/language-server/providers/schema/base.ts +15 -0
  69. package/src/language-server/providers/schema/endpoint.ts +157 -0
  70. package/src/language-server/providers/schema/engine.ts +197 -0
  71. package/src/language-server/providers/schema/file.ts +167 -0
  72. package/src/language-server/providers/schema/index.ts +75 -0
  73. package/src/language-server/server.ts +252 -0
  74. package/src/language-server/typings/codemirror.d.ts +4 -0
  75. package/src/language-server/typings/graphql.d.ts +27 -0
  76. package/src/language-server/utilities/__tests__/graphql.test.ts +411 -0
  77. package/src/language-server/utilities/__tests__/uri.ts +55 -0
  78. package/src/language-server/utilities/debouncer.ts +8 -0
  79. package/src/language-server/utilities/debug.ts +89 -0
  80. package/src/language-server/utilities/graphql.ts +432 -0
  81. package/src/language-server/utilities/index.ts +3 -0
  82. package/src/language-server/utilities/source.ts +182 -0
  83. package/src/language-server/utilities/uri.ts +19 -0
  84. package/src/language-server/workspace.ts +262 -0
  85. package/src/languageServerClient.ts +19 -12
  86. package/src/messages.ts +84 -0
  87. package/src/statusBar.ts +5 -5
  88. package/src/tools/__tests__/buildServiceDefinition.test.ts +491 -0
  89. package/src/tools/__tests__/snapshotSerializers/astSerializer.ts +19 -0
  90. package/src/tools/__tests__/snapshotSerializers/graphQLTypeSerializer.ts +14 -0
  91. package/src/tools/buildServiceDefinition.ts +241 -0
  92. package/src/tools/index.ts +6 -0
  93. package/src/tools/schema/index.ts +2 -0
  94. package/src/tools/schema/resolveObject.ts +18 -0
  95. package/src/tools/schema/resolverMap.ts +23 -0
  96. package/src/tools/utilities/graphql.ts +22 -0
  97. package/src/tools/utilities/index.ts +3 -0
  98. package/src/tools/utilities/invariant.ts +5 -0
  99. package/src/tools/utilities/predicates.ts +5 -0
  100. package/src/utils.ts +1 -16
  101. package/syntaxes/graphql.js.json +3 -3
  102. package/syntaxes/graphql.json +13 -9
  103. package/syntaxes/graphql.lua.json +51 -0
  104. package/syntaxes/graphql.rb.json +1 -1
  105. package/tsconfig.build.json +4 -0
  106. package/tsconfig.json +20 -7
  107. package/create-server-symlink.js +0 -8
  108. package/lib/debug.d.ts +0 -11
  109. package/lib/debug.d.ts.map +0 -1
  110. package/lib/debug.js +0 -48
  111. package/lib/debug.js.map +0 -1
  112. package/lib/extension.d.ts +0 -4
  113. package/lib/extension.d.ts.map +0 -1
  114. package/lib/extension.js +0 -187
  115. package/lib/extension.js.map +0 -1
  116. package/lib/languageServerClient.d.ts +0 -4
  117. package/lib/languageServerClient.d.ts.map +0 -1
  118. package/lib/languageServerClient.js +0 -57
  119. package/lib/languageServerClient.js.map +0 -1
  120. package/lib/statusBar.d.ts +0 -24
  121. package/lib/statusBar.d.ts.map +0 -1
  122. package/lib/statusBar.js +0 -46
  123. package/lib/statusBar.js.map +0 -1
  124. package/lib/testRunner/index.d.ts +0 -3
  125. package/lib/testRunner/index.d.ts.map +0 -1
  126. package/lib/testRunner/index.js +0 -49
  127. package/lib/testRunner/index.js.map +0 -1
  128. package/lib/testRunner/jest-config.d.ts +0 -14
  129. package/lib/testRunner/jest-config.d.ts.map +0 -1
  130. package/lib/testRunner/jest-config.js +0 -18
  131. package/lib/testRunner/jest-config.js.map +0 -1
  132. package/lib/testRunner/jest-vscode-environment.d.ts +0 -2
  133. package/lib/testRunner/jest-vscode-environment.d.ts.map +0 -1
  134. package/lib/testRunner/jest-vscode-environment.js +0 -19
  135. package/lib/testRunner/jest-vscode-environment.js.map +0 -1
  136. package/lib/testRunner/jest-vscode-framework-setup.d.ts +0 -1
  137. package/lib/testRunner/jest-vscode-framework-setup.d.ts.map +0 -1
  138. package/lib/testRunner/jest-vscode-framework-setup.js +0 -3
  139. package/lib/testRunner/jest-vscode-framework-setup.js.map +0 -1
  140. package/lib/testRunner/vscode-test-script.d.ts +0 -2
  141. package/lib/testRunner/vscode-test-script.d.ts.map +0 -1
  142. package/lib/testRunner/vscode-test-script.js +0 -23
  143. package/lib/testRunner/vscode-test-script.js.map +0 -1
  144. package/lib/utils.d.ts +0 -18
  145. package/lib/utils.d.ts.map +0 -1
  146. package/lib/utils.js +0 -52
  147. package/lib/utils.js.map +0 -1
  148. package/src/testRunner/README.md +0 -23
  149. package/src/testRunner/index.ts +0 -72
  150. package/src/testRunner/jest-config.ts +0 -17
  151. package/src/testRunner/jest-vscode-environment.ts +0 -25
  152. package/src/testRunner/jest-vscode-framework-setup.ts +0 -10
  153. package/src/testRunner/jest.d.ts +0 -37
  154. package/src/testRunner/vscode-test-script.ts +0 -38
  155. package/tsconfig.test.json +0 -4
  156. package/tsconfig.tsbuildinfo +0 -2486
@@ -0,0 +1,64 @@
1
+ import { IConnection, NotificationType } from "vscode-languageserver";
2
+
3
+ // XXX I think we want to combine this into an interface
4
+ // with the errors tooling as well
5
+
6
+ export interface LoadingHandler {
7
+ handle<T>(message: string, value: Promise<T>): Promise<T>;
8
+ handleSync<T>(message: string, value: () => T): T;
9
+ showError(message: string): void;
10
+ }
11
+
12
+ export class LanguageServerLoadingHandler implements LoadingHandler {
13
+ constructor(private connection: IConnection) {}
14
+ private latestLoadingToken = 0;
15
+ async handle<T>(message: string, value: Promise<T>): Promise<T> {
16
+ const token = this.latestLoadingToken;
17
+ this.latestLoadingToken += 1;
18
+ this.connection.sendNotification(
19
+ new NotificationType<any, void>("apollographql/loading"),
20
+ { message, token }
21
+ );
22
+ try {
23
+ const ret = await value;
24
+ this.connection.sendNotification(
25
+ new NotificationType<any, void>("apollographql/loadingComplete"),
26
+ token
27
+ );
28
+ return ret;
29
+ } catch (e) {
30
+ this.connection.sendNotification(
31
+ new NotificationType<any, void>("apollographql/loadingComplete"),
32
+ token
33
+ );
34
+ this.showError(`Error in "${message}": ${e}`);
35
+ throw e;
36
+ }
37
+ }
38
+ handleSync<T>(message: string, value: () => T): T {
39
+ const token = this.latestLoadingToken;
40
+ this.latestLoadingToken += 1;
41
+ this.connection.sendNotification(
42
+ new NotificationType<any, void>("apollographql/loading"),
43
+ { message, token }
44
+ );
45
+ try {
46
+ const ret = value();
47
+ this.connection.sendNotification(
48
+ new NotificationType<any, void>("apollographql/loadingComplete"),
49
+ token
50
+ );
51
+ return ret;
52
+ } catch (e) {
53
+ this.connection.sendNotification(
54
+ new NotificationType<any, void>("apollographql/loadingComplete"),
55
+ token
56
+ );
57
+ this.showError(`Error in "${message}": ${e}`);
58
+ throw e;
59
+ }
60
+ }
61
+ showError(message: string) {
62
+ this.connection.window.showErrorMessage(message);
63
+ }
64
+ }
@@ -0,0 +1,399 @@
1
+ import path, { extname } from "path";
2
+ import { lstatSync, readFileSync } from "fs";
3
+ import URI from "vscode-uri";
4
+
5
+ import {
6
+ TypeSystemDefinitionNode,
7
+ isTypeSystemDefinitionNode,
8
+ TypeSystemExtensionNode,
9
+ isTypeSystemExtensionNode,
10
+ DefinitionNode,
11
+ GraphQLSchema,
12
+ Kind,
13
+ } from "graphql";
14
+
15
+ import {
16
+ TextDocument,
17
+ NotificationHandler,
18
+ PublishDiagnosticsParams,
19
+ Position,
20
+ } from "vscode-languageserver";
21
+
22
+ import { GraphQLDocument, extractGraphQLDocuments } from "../document";
23
+
24
+ import type { LoadingHandler } from "../loadingHandler";
25
+ import { FileSet } from "../fileSet";
26
+ import {
27
+ ApolloConfig,
28
+ ClientConfig,
29
+ isClientConfig,
30
+ isLocalServiceConfig,
31
+ isServiceConfig,
32
+ keyEnvVar,
33
+ ServiceConfig,
34
+ } from "../config";
35
+ import {
36
+ schemaProviderFromConfig,
37
+ GraphQLSchemaProvider,
38
+ SchemaResolveConfig,
39
+ } from "../providers/schema";
40
+ import { ApolloEngineClient, ClientIdentity } from "../engine";
41
+ import type { ProjectStats } from "src/messages";
42
+
43
+ export type DocumentUri = string;
44
+
45
+ const fileAssociations: { [extension: string]: string } = {
46
+ ".graphql": "graphql",
47
+ ".gql": "graphql",
48
+ ".js": "javascript",
49
+ ".ts": "typescript",
50
+ ".jsx": "javascriptreact",
51
+ ".tsx": "typescriptreact",
52
+ ".vue": "vue",
53
+ ".svelte": "svelte",
54
+ ".py": "python",
55
+ ".rb": "ruby",
56
+ ".dart": "dart",
57
+ ".re": "reason",
58
+ ".ex": "elixir",
59
+ ".exs": "elixir",
60
+ };
61
+
62
+ interface GraphQLProjectConfig {
63
+ clientIdentity?: ClientIdentity;
64
+ config: ClientConfig | ServiceConfig;
65
+ configFolderURI: URI;
66
+ loadingHandler: LoadingHandler;
67
+ }
68
+
69
+ export abstract class GraphQLProject implements GraphQLSchemaProvider {
70
+ public schemaProvider: GraphQLSchemaProvider;
71
+ protected _onDiagnostics?: NotificationHandler<PublishDiagnosticsParams>;
72
+
73
+ private _isReady: boolean;
74
+ private readyPromise: Promise<void>;
75
+ protected engineClient?: ApolloEngineClient;
76
+
77
+ private needsValidation = false;
78
+
79
+ protected documentsByFile: Map<DocumentUri, GraphQLDocument[]> = new Map();
80
+
81
+ public config: ApolloConfig;
82
+ public schema?: GraphQLSchema;
83
+ private fileSet: FileSet;
84
+ private rootURI: URI;
85
+ protected loadingHandler: LoadingHandler;
86
+
87
+ protected lastLoadDate?: number;
88
+
89
+ constructor({
90
+ config,
91
+ configFolderURI,
92
+ loadingHandler,
93
+ clientIdentity,
94
+ }: GraphQLProjectConfig) {
95
+ this.config = config;
96
+ this.loadingHandler = loadingHandler;
97
+ // the URI of the folder _containing_ the apollo.config.js is the true project's root.
98
+ // if a config doesn't have a uri associated, we can assume the `rootURI` is the project's root.
99
+ this.rootURI = config.configDirURI || configFolderURI;
100
+
101
+ const { includes, excludes } = config.isClient
102
+ ? config.client
103
+ : config.service;
104
+ const fileSet = new FileSet({
105
+ rootURI: this.rootURI,
106
+ includes: [...includes, ".env", "apollo.config.js", "apollo.config.cjs"],
107
+ // We do not want to include the local schema file in our list of documents
108
+ excludes: [...excludes, ...this.getRelativeLocalSchemaFilePaths()],
109
+ configURI: config.configURI,
110
+ });
111
+
112
+ this.fileSet = fileSet;
113
+ this.schemaProvider = schemaProviderFromConfig(config, clientIdentity);
114
+ const { engine } = config;
115
+ if (engine.apiKey) {
116
+ this.engineClient = new ApolloEngineClient(
117
+ engine.apiKey!,
118
+ engine.endpoint,
119
+ clientIdentity
120
+ );
121
+ }
122
+
123
+ this._isReady = false;
124
+ // FIXME: Instead of `Promise.all`, we should catch individual promise rejections
125
+ // so we can show multiple errors.
126
+ this.readyPromise = Promise.all(this.initialize())
127
+ .then(() => {
128
+ this._isReady = true;
129
+ })
130
+ .catch((error) => {
131
+ console.error(error);
132
+ this.loadingHandler.showError(
133
+ `Error initializing Apollo GraphQL project "${this.displayName}": ${error}`
134
+ );
135
+ });
136
+ }
137
+
138
+ abstract get displayName(): string;
139
+
140
+ protected abstract initialize(): Promise<void>[];
141
+
142
+ abstract getProjectStats(): ProjectStats;
143
+
144
+ get isReady(): boolean {
145
+ return this._isReady;
146
+ }
147
+
148
+ get engine(): ApolloEngineClient {
149
+ // handle error states for missing engine config
150
+ // all in the same place :tada:
151
+ if (!this.engineClient) {
152
+ throw new Error(`Unable to find ${keyEnvVar}`);
153
+ }
154
+ return this.engineClient!;
155
+ }
156
+
157
+ get whenReady(): Promise<void> {
158
+ return this.readyPromise;
159
+ }
160
+
161
+ public updateConfig(config: ApolloConfig) {
162
+ this.config = config;
163
+ return this.initialize();
164
+ }
165
+
166
+ public resolveSchema(config: SchemaResolveConfig): Promise<GraphQLSchema> {
167
+ this.lastLoadDate = +new Date();
168
+ return this.schemaProvider.resolveSchema(config);
169
+ }
170
+
171
+ public resolveFederatedServiceSDL() {
172
+ return this.schemaProvider.resolveFederatedServiceSDL();
173
+ }
174
+
175
+ public onSchemaChange(handler: NotificationHandler<GraphQLSchema>) {
176
+ this.lastLoadDate = +new Date();
177
+ return this.schemaProvider.onSchemaChange(handler);
178
+ }
179
+
180
+ onDiagnostics(handler: NotificationHandler<PublishDiagnosticsParams>) {
181
+ this._onDiagnostics = handler;
182
+ }
183
+
184
+ includesFile(uri: DocumentUri) {
185
+ return this.fileSet.includesFile(uri);
186
+ }
187
+
188
+ allIncludedFiles() {
189
+ return this.fileSet.allFiles();
190
+ }
191
+
192
+ async scanAllIncludedFiles() {
193
+ await this.loadingHandler.handle(
194
+ `Loading queries for ${this.displayName}`,
195
+ (async () => {
196
+ for (const filePath of this.allIncludedFiles()) {
197
+ const uri = URI.file(filePath).toString();
198
+
199
+ // If we already have query documents for this file, that means it was either
200
+ // opened or changed before we got a chance to read it.
201
+ if (this.documentsByFile.has(uri)) continue;
202
+
203
+ this.fileDidChange(uri);
204
+ }
205
+ })()
206
+ );
207
+ }
208
+
209
+ fileDidChange(uri: DocumentUri) {
210
+ const filePath = URI.parse(uri).fsPath;
211
+ const extension = extname(filePath);
212
+ const languageId = fileAssociations[extension];
213
+
214
+ // Don't process files of an unsupported filetype
215
+ if (!languageId) return;
216
+
217
+ // Don't process directories. Directories might be named like files so
218
+ // we have to explicitly check.
219
+ if (!lstatSync(filePath).isFile()) return;
220
+
221
+ const contents = readFileSync(filePath, "utf8");
222
+ const document = TextDocument.create(uri, languageId, -1, contents);
223
+ this.documentDidChange(document);
224
+ }
225
+
226
+ fileWasDeleted(uri: DocumentUri) {
227
+ this.removeGraphQLDocumentsFor(uri);
228
+ this.checkForDuplicateOperations();
229
+ }
230
+
231
+ documentDidChange(document: TextDocument) {
232
+ const documents = extractGraphQLDocuments(
233
+ document,
234
+ this.config.client && this.config.client.tagName
235
+ );
236
+ if (documents) {
237
+ this.documentsByFile.set(document.uri, documents);
238
+ this.invalidate();
239
+ } else {
240
+ this.removeGraphQLDocumentsFor(document.uri);
241
+ }
242
+ this.checkForDuplicateOperations();
243
+ }
244
+
245
+ checkForDuplicateOperations(): void {
246
+ const filePathForOperationName: Record<string, string> = {};
247
+ for (const [fileUri, documentsForFile] of this.documentsByFile.entries()) {
248
+ const filePath = URI.parse(fileUri).fsPath;
249
+ for (const document of documentsForFile) {
250
+ if (!document.ast) continue;
251
+ for (const definition of document.ast.definitions) {
252
+ if (
253
+ definition.kind === Kind.OPERATION_DEFINITION &&
254
+ definition.name
255
+ ) {
256
+ const operationName = definition.name.value;
257
+ if (operationName in filePathForOperationName) {
258
+ const conflictingFilePath =
259
+ filePathForOperationName[operationName];
260
+ throw new Error(
261
+ `️️There are multiple definitions for the \`${definition.name.value}\` operation. Please fix all naming conflicts before continuing.\nConflicting definitions found at ${filePath} and ${conflictingFilePath}.`
262
+ );
263
+ }
264
+ filePathForOperationName[operationName] = filePath;
265
+ }
266
+ }
267
+ }
268
+ }
269
+ }
270
+
271
+ private removeGraphQLDocumentsFor(uri: DocumentUri) {
272
+ if (this.documentsByFile.has(uri)) {
273
+ this.documentsByFile.delete(uri);
274
+
275
+ if (this._onDiagnostics) {
276
+ this._onDiagnostics({ uri: uri, diagnostics: [] });
277
+ }
278
+
279
+ this.invalidate();
280
+ }
281
+ }
282
+
283
+ protected invalidate() {
284
+ if (!this.needsValidation && this.isReady) {
285
+ setTimeout(() => {
286
+ this.validateIfNeeded();
287
+ }, 0);
288
+ this.needsValidation = true;
289
+ }
290
+ }
291
+
292
+ private validateIfNeeded() {
293
+ if (!this.needsValidation || !this.isReady) return;
294
+
295
+ this.validate();
296
+
297
+ this.needsValidation = false;
298
+ }
299
+
300
+ private getRelativeLocalSchemaFilePaths(): string[] {
301
+ const serviceConfig = isServiceConfig(this.config)
302
+ ? this.config.service
303
+ : isClientConfig(this.config) &&
304
+ typeof this.config.client.service === "object" &&
305
+ isLocalServiceConfig(this.config.client.service)
306
+ ? this.config.client.service
307
+ : undefined;
308
+ const localSchemaFile = serviceConfig?.localSchemaFile;
309
+ return (
310
+ localSchemaFile === undefined
311
+ ? []
312
+ : Array.isArray(localSchemaFile)
313
+ ? localSchemaFile
314
+ : [localSchemaFile]
315
+ ).map((filePath) =>
316
+ path.relative(this.rootURI.fsPath, path.join(process.cwd(), filePath))
317
+ );
318
+ }
319
+
320
+ abstract validate(): void;
321
+
322
+ clearAllDiagnostics() {
323
+ if (!this._onDiagnostics) return;
324
+
325
+ for (const uri of this.documentsByFile.keys()) {
326
+ this._onDiagnostics({ uri, diagnostics: [] });
327
+ }
328
+ }
329
+
330
+ documentsAt(uri: DocumentUri): GraphQLDocument[] | undefined {
331
+ return this.documentsByFile.get(uri);
332
+ }
333
+
334
+ documentAt(
335
+ uri: DocumentUri,
336
+ position: Position
337
+ ): GraphQLDocument | undefined {
338
+ const queryDocuments = this.documentsByFile.get(uri);
339
+ if (!queryDocuments) return undefined;
340
+
341
+ return queryDocuments.find((document) =>
342
+ document.containsPosition(position)
343
+ );
344
+ }
345
+
346
+ get documents(): GraphQLDocument[] {
347
+ const documents: GraphQLDocument[] = [];
348
+ for (const documentsForFile of this.documentsByFile.values()) {
349
+ documents.push(...documentsForFile);
350
+ }
351
+ return documents;
352
+ }
353
+
354
+ get definitions(): DefinitionNode[] {
355
+ const definitions = [];
356
+
357
+ for (const document of this.documents) {
358
+ if (!document.ast) continue;
359
+
360
+ definitions.push(...document.ast.definitions);
361
+ }
362
+
363
+ return definitions;
364
+ }
365
+
366
+ definitionsAt(uri: DocumentUri): DefinitionNode[] {
367
+ const documents = this.documentsAt(uri);
368
+ if (!documents) return [];
369
+
370
+ const definitions = [];
371
+
372
+ for (const document of documents) {
373
+ if (!document.ast) continue;
374
+
375
+ definitions.push(...document.ast.definitions);
376
+ }
377
+
378
+ return definitions;
379
+ }
380
+
381
+ get typeSystemDefinitionsAndExtensions(): (
382
+ | TypeSystemDefinitionNode
383
+ | TypeSystemExtensionNode
384
+ )[] {
385
+ const definitionsAndExtensions = [];
386
+ for (const document of this.documents) {
387
+ if (!document.ast) continue;
388
+ for (const definition of document.ast.definitions) {
389
+ if (
390
+ isTypeSystemDefinitionNode(definition) ||
391
+ isTypeSystemExtensionNode(definition)
392
+ ) {
393
+ definitionsAndExtensions.push(definition);
394
+ }
395
+ }
396
+ }
397
+ return definitionsAndExtensions;
398
+ }
399
+ }