@reqlan/language 1.4.0 → 1.5.0

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 (222) hide show
  1. package/README.md +121 -24
  2. package/README.template.md +32 -0
  3. package/out/generated/ast.d.ts +39 -1
  4. package/out/generated/ast.js +35 -1
  5. package/out/generated/ast.js.map +1 -1
  6. package/out/generated/grammar.js +365 -110
  7. package/out/generated/grammar.js.map +1 -1
  8. package/out/reqlan-definition-provider.js +2 -2
  9. package/out/reqlan-definition-provider.js.map +1 -1
  10. package/out/reqlan-file-link-resolver.js +6 -1
  11. package/out/reqlan-file-link-resolver.js.map +1 -1
  12. package/out/reqlan-import-bindings.d.ts +6 -1
  13. package/out/reqlan-import-bindings.js +18 -1
  14. package/out/reqlan-import-bindings.js.map +1 -1
  15. package/out/reqlan-namespace-import-links.js +4 -3
  16. package/out/reqlan-namespace-import-links.js.map +1 -1
  17. package/out/reqlan-path-resolve.d.ts +1 -0
  18. package/out/reqlan-path-resolve.js +3 -0
  19. package/out/reqlan-path-resolve.js.map +1 -1
  20. package/out/reqlan-references.js +3 -2
  21. package/out/reqlan-references.js.map +1 -1
  22. package/out/reqlan-scope.js +9 -4
  23. package/out/reqlan-scope.js.map +1 -1
  24. package/out/reqlan-semantic-token-provider.js +23 -5
  25. package/out/reqlan-semantic-token-provider.js.map +1 -1
  26. package/out/reqlan-validator.d.ts +7 -0
  27. package/out/reqlan-validator.js +35 -3
  28. package/out/reqlan-validator.js.map +1 -1
  29. package/out/reqlan-workspace-attribute-catalog.js +37 -15
  30. package/out/reqlan-workspace-attribute-catalog.js.map +1 -1
  31. package/package.json +2 -2
  32. package/src/generated/ast.ts +53 -2
  33. package/src/generated/grammar.ts +365 -110
  34. package/src/reqlan-definition-provider.ts +2 -1
  35. package/src/reqlan-file-link-resolver.ts +6 -1
  36. package/src/reqlan-import-bindings.ts +26 -1
  37. package/src/reqlan-namespace-import-links.ts +4 -3
  38. package/src/reqlan-path-resolve.ts +4 -0
  39. package/src/reqlan-references.ts +3 -2
  40. package/src/reqlan-scope.ts +9 -5
  41. package/src/reqlan-semantic-token-provider.ts +22 -4
  42. package/src/reqlan-validator.ts +50 -2
  43. package/src/reqlan-workspace-attribute-catalog.ts +50 -15
  44. package/src/reqlan.langium +18 -2
  45. package/out/src/file-path-rewrite.d.ts +0 -25
  46. package/out/src/file-path-rewrite.js +0 -56
  47. package/out/src/file-path-rewrite.js.map +0 -1
  48. package/out/src/generated/ast.d.ts +0 -1173
  49. package/out/src/generated/ast.js +0 -994
  50. package/out/src/generated/ast.js.map +0 -1
  51. package/out/src/generated/grammar.d.ts +0 -7
  52. package/out/src/generated/grammar.js +0 -3045
  53. package/out/src/generated/grammar.js.map +0 -1
  54. package/out/src/generated/module.d.ts +0 -20
  55. package/out/src/generated/module.js +0 -32
  56. package/out/src/generated/module.js.map +0 -1
  57. package/out/src/index.d.ts +0 -29
  58. package/out/src/index.js +0 -30
  59. package/out/src/index.js.map +0 -1
  60. package/out/src/reqlan-attribute-catalog.d.ts +0 -19
  61. package/out/src/reqlan-attribute-catalog.js +0 -87
  62. package/out/src/reqlan-attribute-catalog.js.map +0 -1
  63. package/out/src/reqlan-code-action-provider.d.ts +0 -34
  64. package/out/src/reqlan-code-action-provider.js +0 -206
  65. package/out/src/reqlan-code-action-provider.js.map +0 -1
  66. package/out/src/reqlan-comment-resolver.d.ts +0 -35
  67. package/out/src/reqlan-comment-resolver.js +0 -308
  68. package/out/src/reqlan-comment-resolver.js.map +0 -1
  69. package/out/src/reqlan-completion-context.d.ts +0 -46
  70. package/out/src/reqlan-completion-context.js +0 -244
  71. package/out/src/reqlan-completion-context.js.map +0 -1
  72. package/out/src/reqlan-completion-provider.d.ts +0 -41
  73. package/out/src/reqlan-completion-provider.js +0 -320
  74. package/out/src/reqlan-completion-provider.js.map +0 -1
  75. package/out/src/reqlan-definition-provider.d.ts +0 -31
  76. package/out/src/reqlan-definition-provider.js +0 -240
  77. package/out/src/reqlan-definition-provider.js.map +0 -1
  78. package/out/src/reqlan-document-highlight-provider.d.ts +0 -10
  79. package/out/src/reqlan-document-highlight-provider.js +0 -11
  80. package/out/src/reqlan-document-highlight-provider.js.map +0 -1
  81. package/out/src/reqlan-document-link-provider.d.ts +0 -14
  82. package/out/src/reqlan-document-link-provider.js +0 -24
  83. package/out/src/reqlan-document-link-provider.js.map +0 -1
  84. package/out/src/reqlan-embedded-file-references.d.ts +0 -11
  85. package/out/src/reqlan-embedded-file-references.js +0 -50
  86. package/out/src/reqlan-embedded-file-references.js.map +0 -1
  87. package/out/src/reqlan-file-link-resolver.d.ts +0 -44
  88. package/out/src/reqlan-file-link-resolver.js +0 -347
  89. package/out/src/reqlan-file-link-resolver.js.map +0 -1
  90. package/out/src/reqlan-file-references.d.ts +0 -15
  91. package/out/src/reqlan-file-references.js +0 -72
  92. package/out/src/reqlan-file-references.js.map +0 -1
  93. package/out/src/reqlan-grammar-config.d.ts +0 -5
  94. package/out/src/reqlan-grammar-config.js +0 -9
  95. package/out/src/reqlan-grammar-config.js.map +0 -1
  96. package/out/src/reqlan-idea-summary.d.ts +0 -6
  97. package/out/src/reqlan-idea-summary.js +0 -78
  98. package/out/src/reqlan-idea-summary.js.map +0 -1
  99. package/out/src/reqlan-ignore-error.d.ts +0 -10
  100. package/out/src/reqlan-ignore-error.js +0 -42
  101. package/out/src/reqlan-ignore-error.js.map +0 -1
  102. package/out/src/reqlan-import-bindings.d.ts +0 -12
  103. package/out/src/reqlan-import-bindings.js +0 -65
  104. package/out/src/reqlan-import-bindings.js.map +0 -1
  105. package/out/src/reqlan-import-edits.d.ts +0 -17
  106. package/out/src/reqlan-import-edits.js +0 -96
  107. package/out/src/reqlan-import-edits.js.map +0 -1
  108. package/out/src/reqlan-imports.d.ts +0 -22
  109. package/out/src/reqlan-imports.js +0 -61
  110. package/out/src/reqlan-imports.js.map +0 -1
  111. package/out/src/reqlan-inbound-reference-inlay-label.d.ts +0 -23
  112. package/out/src/reqlan-inbound-reference-inlay-label.js +0 -128
  113. package/out/src/reqlan-inbound-reference-inlay-label.js.map +0 -1
  114. package/out/src/reqlan-inlay-hint-provider.d.ts +0 -15
  115. package/out/src/reqlan-inlay-hint-provider.js +0 -54
  116. package/out/src/reqlan-inlay-hint-provider.js.map +0 -1
  117. package/out/src/reqlan-inlay-hint-settings.d.ts +0 -10
  118. package/out/src/reqlan-inlay-hint-settings.js +0 -10
  119. package/out/src/reqlan-inlay-hint-settings.js.map +0 -1
  120. package/out/src/reqlan-linker.d.ts +0 -26
  121. package/out/src/reqlan-linker.js +0 -86
  122. package/out/src/reqlan-linker.js.map +0 -1
  123. package/out/src/reqlan-markdown-links.d.ts +0 -28
  124. package/out/src/reqlan-markdown-links.js +0 -113
  125. package/out/src/reqlan-markdown-links.js.map +0 -1
  126. package/out/src/reqlan-module.d.ts +0 -41
  127. package/out/src/reqlan-module.js +0 -76
  128. package/out/src/reqlan-module.js.map +0 -1
  129. package/out/src/reqlan-name-catalog.d.ts +0 -23
  130. package/out/src/reqlan-name-catalog.js +0 -63
  131. package/out/src/reqlan-name-catalog.js.map +0 -1
  132. package/out/src/reqlan-name-provider.d.ts +0 -10
  133. package/out/src/reqlan-name-provider.js +0 -38
  134. package/out/src/reqlan-name-provider.js.map +0 -1
  135. package/out/src/reqlan-namespace-import-links.d.ts +0 -10
  136. package/out/src/reqlan-namespace-import-links.js +0 -81
  137. package/out/src/reqlan-namespace-import-links.js.map +0 -1
  138. package/out/src/reqlan-path-completion.d.ts +0 -50
  139. package/out/src/reqlan-path-completion.js +0 -304
  140. package/out/src/reqlan-path-completion.js.map +0 -1
  141. package/out/src/reqlan-path-references.d.ts +0 -5
  142. package/out/src/reqlan-path-references.js +0 -124
  143. package/out/src/reqlan-path-references.js.map +0 -1
  144. package/out/src/reqlan-path-resolve.d.ts +0 -59
  145. package/out/src/reqlan-path-resolve.js +0 -173
  146. package/out/src/reqlan-path-resolve.js.map +0 -1
  147. package/out/src/reqlan-quoted-strings.d.ts +0 -9
  148. package/out/src/reqlan-quoted-strings.js +0 -26
  149. package/out/src/reqlan-quoted-strings.js.map +0 -1
  150. package/out/src/reqlan-reference-at-position.d.ts +0 -20
  151. package/out/src/reqlan-reference-at-position.js +0 -89
  152. package/out/src/reqlan-reference-at-position.js.map +0 -1
  153. package/out/src/reqlan-references.d.ts +0 -16
  154. package/out/src/reqlan-references.js +0 -51
  155. package/out/src/reqlan-references.js.map +0 -1
  156. package/out/src/reqlan-scope.d.ts +0 -25
  157. package/out/src/reqlan-scope.js +0 -266
  158. package/out/src/reqlan-scope.js.map +0 -1
  159. package/out/src/reqlan-semantic-token-provider.d.ts +0 -8
  160. package/out/src/reqlan-semantic-token-provider.js +0 -97
  161. package/out/src/reqlan-semantic-token-provider.js.map +0 -1
  162. package/out/src/reqlan-token-builder.d.ts +0 -12
  163. package/out/src/reqlan-token-builder.js +0 -459
  164. package/out/src/reqlan-token-builder.js.map +0 -1
  165. package/out/src/reqlan-validator.d.ts +0 -25
  166. package/out/src/reqlan-validator.js +0 -119
  167. package/out/src/reqlan-validator.js.map +0 -1
  168. package/out/src/reqlan-workspace-attribute-catalog.d.ts +0 -6
  169. package/out/src/reqlan-workspace-attribute-catalog.js +0 -54
  170. package/out/src/reqlan-workspace-attribute-catalog.js.map +0 -1
  171. package/out/test/code-actions.test.d.ts +0 -1
  172. package/out/test/code-actions.test.js +0 -126
  173. package/out/test/code-actions.test.js.map +0 -1
  174. package/out/test/comment-in-string.test.d.ts +0 -1
  175. package/out/test/comment-in-string.test.js +0 -100
  176. package/out/test/comment-in-string.test.js.map +0 -1
  177. package/out/test/completion.test.d.ts +0 -1
  178. package/out/test/completion.test.js +0 -467
  179. package/out/test/completion.test.js.map +0 -1
  180. package/out/test/file-path-rewrite.test.d.ts +0 -1
  181. package/out/test/file-path-rewrite.test.js +0 -64
  182. package/out/test/file-path-rewrite.test.js.map +0 -1
  183. package/out/test/ignore-error.test.d.ts +0 -1
  184. package/out/test/ignore-error.test.js +0 -87
  185. package/out/test/ignore-error.test.js.map +0 -1
  186. package/out/test/implicit-import-extension.test.d.ts +0 -1
  187. package/out/test/implicit-import-extension.test.js +0 -203
  188. package/out/test/implicit-import-extension.test.js.map +0 -1
  189. package/out/test/import-edits.test.d.ts +0 -1
  190. package/out/test/import-edits.test.js +0 -20
  191. package/out/test/import-edits.test.js.map +0 -1
  192. package/out/test/inlay-hints.test.d.ts +0 -1
  193. package/out/test/inlay-hints.test.js +0 -238
  194. package/out/test/inlay-hints.test.js.map +0 -1
  195. package/out/test/linking.test.d.ts +0 -1
  196. package/out/test/linking.test.js +0 -754
  197. package/out/test/linking.test.js.map +0 -1
  198. package/out/test/naked-strings.test.d.ts +0 -1
  199. package/out/test/naked-strings.test.js +0 -50
  200. package/out/test/naked-strings.test.js.map +0 -1
  201. package/out/test/parsing.test.d.ts +0 -1
  202. package/out/test/parsing.test.js +0 -773
  203. package/out/test/parsing.test.js.map +0 -1
  204. package/out/test/path-resolve.test.d.ts +0 -1
  205. package/out/test/path-resolve.test.js +0 -88
  206. package/out/test/path-resolve.test.js.map +0 -1
  207. package/out/test/references.test.d.ts +0 -1
  208. package/out/test/references.test.js +0 -168
  209. package/out/test/references.test.js.map +0 -1
  210. package/out/test/rqconfig.test.d.ts +0 -1
  211. package/out/test/rqconfig.test.js +0 -275
  212. package/out/test/rqconfig.test.js.map +0 -1
  213. package/out/test/test-requirement-refs.d.ts +0 -8
  214. package/out/test/test-requirement-refs.js +0 -35
  215. package/out/test/test-requirement-refs.js.map +0 -1
  216. package/out/test/testing.test.d.ts +0 -1
  217. package/out/test/testing.test.js +0 -23
  218. package/out/test/testing.test.js.map +0 -1
  219. package/out/test/validating.test.d.ts +0 -1
  220. package/out/test/validating.test.js +0 -117
  221. package/out/test/validating.test.js.map +0 -1
  222. package/out/tsconfig.tsbuildinfo +0 -1
@@ -1,41 +0,0 @@
1
- /**
2
- * Code completion for references, import paths, file paths, and attributes.
3
- * rq:["../../../reqlan rq/extension/configuration.rq".configuration_import_roots]
4
- * rq:["../../../reqlan rq/language/imports.rq".configuration_import_root_alias]
5
- * rq:["../../../reqlan rq/extension/features-syntax-highlighting.rq".reference_code_completion]
6
- * rq:["../../../reqlan rq/extension/features-syntax-highlighting.rq".reference_code_completion_sequencing]
7
- * rq:["../../../reqlan rq/extension/language-support/features-imports.rq".import_code_completion]
8
- * rq:["../../../reqlan rq/extension/language-support/features-imports.rq".import_code_completion_ranking]
9
- * rq:["../../../reqlan rq/extension/language-support/features-imports.rq".anonymous_reference_code_completion]
10
- */
11
- import type { AstNodeDescription, LangiumDocument } from 'langium';
12
- import type { MaybePromise } from 'langium';
13
- import { DefaultCompletionProvider, type CompletionAcceptor, type CompletionContext, type CompletionProviderOptions } from 'langium/lsp';
14
- import type { CompletionList, CompletionParams } from 'vscode-languageserver';
15
- import { AttributeCatalogStore } from './reqlan-attribute-catalog.js';
16
- import type { ReqlanServices } from './reqlan-module.js';
17
- export declare class ReqlanCompletionProvider extends DefaultCompletionProvider {
18
- private readonly documents;
19
- private readonly fileSystem;
20
- private readonly descriptions;
21
- private readonly services;
22
- readonly attributeCatalog: AttributeCatalogStore;
23
- readonly completionOptions: CompletionProviderOptions;
24
- constructor(services: ReqlanServices, attributeCatalog?: AttributeCatalogStore);
25
- getCompletion(document: LangiumDocument, params: CompletionParams): Promise<CompletionList | undefined>;
26
- protected completionFor(context: CompletionContext, next: Parameters<DefaultCompletionProvider['completionFor']>[1], acceptor: CompletionAcceptor): MaybePromise<void>;
27
- protected getReferenceCandidates(refInfo: Parameters<DefaultCompletionProvider['getReferenceCandidates']>[0], context: CompletionContext): import("langium").Stream<AstNodeDescription>;
28
- private completeAttributeKeys;
29
- private completeAttributeValues;
30
- private completeReferenceNames;
31
- private completeAnonymousImportPath;
32
- private completeImportPath;
33
- /** Shared candidate set for `import "…"` / `from "…"` and anonymous `["…"]` paths. */
34
- private collectImportPathCandidates;
35
- private collectUsedAttributeKeys;
36
- private refreshWorkspaceAttributeCatalog;
37
- }
38
- /** Undirected idea↔idea edges from bracket/wikilink references in the given documents. */
39
- export declare function buildIdeaReferenceAdjacency(documents: LangiumDocument[]): Map<string, Set<string>>;
40
- /** BFS hop distances from `center` over an undirected adjacency map. */
41
- export declare function hopDistancesFromCenter(center: string, adjacency: Map<string, Set<string>>): Map<string, number>;
@@ -1,320 +0,0 @@
1
- import { AstUtils, stream } from 'langium';
2
- import { DefaultCompletionProvider } from 'langium/lsp';
3
- import { reqlanStringDelimiter } from './reqlan-quoted-strings.js';
4
- import { CompletionItemKind, CompletionList as LspCompletionList } from 'vscode-languageserver';
5
- import { isAttribute, isBracketReference, isIdea, isIdeaSet, isLocalReference, isModel, isOneLinerIdea, isQualifiedReference, isWikiLink } from './generated/ast.js';
6
- import { AttributeCatalogStore, ENDORSED_ATTRIBUTE_KEYS } from './reqlan-attribute-catalog.js';
7
- import { findContainingIdea, getAnonymousImportPathContext, getAttributeKeyContext, getAttributeValueContext, getCompletionSite, getReferencePrefixContext } from './reqlan-completion-context.js';
8
- import { collectPathCompletionCandidates, comparePathCompletionCandidates, pathCompletionFilterText, pathCompletionSortText } from './reqlan-path-completion.js';
9
- import { pathResolveContextFromServices } from './reqlan-path-resolve.js';
10
- import { referenceIdea } from './reqlan-references.js';
11
- import { collectWorkspaceAttributeCatalog } from './reqlan-workspace-attribute-catalog.js';
12
- const UNREACHABLE_DISTANCE = 9999;
13
- export class ReqlanCompletionProvider extends DefaultCompletionProvider {
14
- constructor(services, attributeCatalog = new AttributeCatalogStore()) {
15
- super(services);
16
- this.completionOptions = {
17
- triggerCharacters: ['@', '[', '.', '/', '"']
18
- };
19
- this.documents = services.shared.workspace.LangiumDocuments;
20
- this.fileSystem = services.shared.workspace.FileSystemProvider;
21
- this.descriptions = services.workspace.AstNodeDescriptionProvider;
22
- this.services = services;
23
- this.attributeCatalog = attributeCatalog;
24
- }
25
- async getCompletion(document, params) {
26
- const site = getCompletionSite(document, params.position);
27
- if (site === 'main_description') {
28
- return LspCompletionList.create([], true);
29
- }
30
- if (site === 'attribute_key') {
31
- return this.completeAttributeKeys(document, params);
32
- }
33
- if (site === 'attribute_value') {
34
- return this.completeAttributeValues(document, params);
35
- }
36
- if (site === 'anonymous_import_path') {
37
- return this.completeAnonymousImportPath(document, params);
38
- }
39
- if (site === 'reference') {
40
- return this.completeReferenceNames(document, params);
41
- }
42
- this.refreshWorkspaceAttributeCatalog();
43
- return super.getCompletion(document, params);
44
- }
45
- completionFor(context, next, acceptor) {
46
- if (next.property === 'path' || next.property === 'file') {
47
- // Import paths and anonymous bracket paths share the same candidate logic.
48
- this.completeImportPath(context, acceptor);
49
- return;
50
- }
51
- return super.completionFor(context, next, acceptor);
52
- }
53
- getReferenceCandidates(refInfo, context) {
54
- const candidates = super.getReferenceCandidates(refInfo, context);
55
- if (refInfo.property !== 'idea' && refInfo.property !== 'ideaset' && refInfo.property !== 'members') {
56
- return candidates;
57
- }
58
- const descriptions = this.documents.all.toArray().flatMap(doc => {
59
- const model = doc.parseResult.value;
60
- if (!isModel(model)) {
61
- return [];
62
- }
63
- return model.elements
64
- .filter(element => {
65
- if (refInfo.property === 'ideaset') {
66
- return isIdeaSet(element);
67
- }
68
- return isIdea(element) || isOneLinerIdea(element);
69
- })
70
- .map(element => this.descriptions.createDescription(element, element.name, doc));
71
- });
72
- return stream([...candidates, ...descriptions]).distinct((description) => description.name);
73
- }
74
- completeAttributeKeys(document, params) {
75
- const context = getAttributeKeyContext(document, params.position);
76
- if (!context) {
77
- return LspCompletionList.create([], true);
78
- }
79
- this.refreshWorkspaceAttributeCatalog();
80
- const usedKeys = new Set(this.collectUsedAttributeKeys(document));
81
- const endorsed = new Set(ENDORSED_ATTRIBUTE_KEYS);
82
- const items = this.attributeCatalog.get().keys.flatMap(key => {
83
- if (context.prefix && !key.startsWith(context.prefix)) {
84
- return [];
85
- }
86
- if (usedKeys.has(key)) {
87
- return [];
88
- }
89
- return [{
90
- label: key,
91
- kind: CompletionItemKind.Property,
92
- insertText: key,
93
- range: {
94
- start: context.replaceStart,
95
- end: context.replaceEnd
96
- },
97
- detail: endorsed.has(key) ? 'endorsed attribute' : 'workspace attribute'
98
- }];
99
- });
100
- return LspCompletionList.create(items, true);
101
- }
102
- completeAttributeValues(document, params) {
103
- const context = getAttributeValueContext(document, params.position);
104
- if (!context) {
105
- return LspCompletionList.create([], true);
106
- }
107
- this.refreshWorkspaceAttributeCatalog();
108
- const values = this.attributeCatalog.get().valuesByKey[context.attributeName] ?? [];
109
- const items = values.flatMap(value => {
110
- if (context.prefix && !value.startsWith(context.prefix)) {
111
- return [];
112
- }
113
- return [{
114
- label: value,
115
- kind: CompletionItemKind.Value,
116
- insertText: value,
117
- range: {
118
- start: context.replaceStart,
119
- end: context.replaceEnd
120
- },
121
- detail: `@${context.attributeName}`
122
- }];
123
- });
124
- return LspCompletionList.create(items, true);
125
- }
126
- completeReferenceNames(document, params) {
127
- const context = getReferencePrefixContext(document, params.position);
128
- if (!context) {
129
- return LspCompletionList.create([], true);
130
- }
131
- const names = new Set();
132
- const docs = this.documents.all.toArray();
133
- if (!docs.some(doc => doc.uri.toString() === document.uri.toString())) {
134
- docs.push(document);
135
- }
136
- for (const doc of docs) {
137
- const model = doc.parseResult.value;
138
- if (!isModel(model)) {
139
- continue;
140
- }
141
- for (const element of model.elements) {
142
- if (isIdea(element) || isOneLinerIdea(element) || isIdeaSet(element)) {
143
- names.add(element.name);
144
- }
145
- }
146
- }
147
- const center = findContainingIdea(document, params.position)?.name;
148
- const distances = center
149
- ? hopDistancesFromCenter(center, buildIdeaReferenceAdjacency(docs))
150
- : new Map();
151
- const items = [...names].flatMap(name => {
152
- if (context.prefix && !name.startsWith(context.prefix)) {
153
- return [];
154
- }
155
- const distance = distances.get(name) ?? UNREACHABLE_DISTANCE;
156
- return [{
157
- label: name,
158
- kind: CompletionItemKind.Reference,
159
- insertText: name,
160
- sortText: `${String(distance).padStart(4, '0')}_${name}`,
161
- range: {
162
- start: context.replaceStart,
163
- end: context.replaceEnd
164
- }
165
- }];
166
- }).sort((left, right) => {
167
- const leftDistance = distances.get(String(left.label)) ?? UNREACHABLE_DISTANCE;
168
- const rightDistance = distances.get(String(right.label)) ?? UNREACHABLE_DISTANCE;
169
- return leftDistance - rightDistance || String(left.label).localeCompare(String(right.label));
170
- });
171
- return LspCompletionList.create(items, true);
172
- }
173
- completeAnonymousImportPath(document, params) {
174
- const context = getAnonymousImportPathContext(document, params.position);
175
- if (!context) {
176
- return LspCompletionList.create([], true);
177
- }
178
- const candidates = this.collectImportPathCandidates(document, context.prefix)
179
- .sort((left, right) => comparePathCompletionCandidates(document, left, right));
180
- const items = candidates.map(candidate => ({
181
- label: candidate.path,
182
- kind: candidate.isDirectory ? CompletionItemKind.Folder : CompletionItemKind.File,
183
- textEdit: {
184
- newText: candidate.path,
185
- range: {
186
- start: context.replaceStart,
187
- end: context.replaceEnd
188
- }
189
- },
190
- sortText: pathCompletionSortText(document, candidate),
191
- filterText: pathCompletionFilterText(context.prefix, candidate)
192
- }));
193
- return LspCompletionList.create(items, true);
194
- }
195
- completeImportPath(context, acceptor) {
196
- const text = context.textDocument.getText();
197
- const existingText = text.substring(context.tokenOffset, context.offset);
198
- let range = {
199
- start: context.position,
200
- end: context.position
201
- };
202
- let prefix = '';
203
- if (existingText.length > 0) {
204
- const delimiter = reqlanStringDelimiter(existingText);
205
- prefix = delimiter
206
- ? existingText.slice(1, existingText.endsWith(delimiter) ? -1 : undefined)
207
- : existingText;
208
- const quoteOffset = delimiter ? 1 : 0;
209
- const start = context.textDocument.positionAt(context.tokenOffset + quoteOffset);
210
- const end = context.textDocument.positionAt(context.tokenEndOffset - (delimiter && existingText.endsWith(delimiter) ? 1 : 0));
211
- range = { start, end };
212
- }
213
- const candidates = this.collectImportPathCandidates(context.document, prefix)
214
- .sort((left, right) => comparePathCompletionCandidates(context.document, left, right));
215
- for (const candidate of candidates) {
216
- const delimiter = reqlanStringDelimiter(existingText);
217
- const opening = delimiter ?? '"';
218
- const needsClosing = !delimiter || !existingText.endsWith(delimiter);
219
- const closing = needsClosing ? opening : '';
220
- acceptor(context, {
221
- label: candidate.path,
222
- textEdit: {
223
- newText: `${delimiter ? '' : opening}${candidate.path}${closing}`,
224
- range
225
- },
226
- kind: candidate.isDirectory ? CompletionItemKind.Folder : CompletionItemKind.File,
227
- sortText: pathCompletionSortText(context.document, candidate),
228
- filterText: pathCompletionFilterText(prefix, candidate)
229
- });
230
- }
231
- }
232
- /** Shared candidate set for `import "…"` / `from "…"` and anonymous `["…"]` paths. */
233
- collectImportPathCandidates(document, prefix) {
234
- return collectPathCompletionCandidates(document, this.documents, this.fileSystem, pathResolveContextFromServices(this.services), { extensionFilter: '.rq', prefix });
235
- }
236
- collectUsedAttributeKeys(document) {
237
- return AstUtils.streamAst(document.parseResult.value)
238
- .filter(isAttribute)
239
- .map(attribute => attribute.name)
240
- .toArray();
241
- }
242
- refreshWorkspaceAttributeCatalog() {
243
- const workspaceCatalog = collectWorkspaceAttributeCatalog(this.documents);
244
- this.attributeCatalog.mergeWorkspaceKeys(workspaceCatalog.keys, workspaceCatalog.valuesByKey);
245
- }
246
- }
247
- /** Undirected idea↔idea edges from bracket/wikilink references in the given documents. */
248
- export function buildIdeaReferenceAdjacency(documents) {
249
- const adjacency = new Map();
250
- const addEdge = (left, right) => {
251
- if (!left || !right || left === right) {
252
- return;
253
- }
254
- if (!adjacency.has(left)) {
255
- adjacency.set(left, new Set());
256
- }
257
- if (!adjacency.has(right)) {
258
- adjacency.set(right, new Set());
259
- }
260
- adjacency.get(left).add(right);
261
- adjacency.get(right).add(left);
262
- };
263
- for (const document of documents) {
264
- for (const node of AstUtils.streamAst(document.parseResult.value)) {
265
- if (!isBracketReference(node) && !isWikiLink(node)) {
266
- continue;
267
- }
268
- const source = enclosingIdeaName(node);
269
- if (!source) {
270
- continue;
271
- }
272
- for (const target of referencedNames(node.target)) {
273
- addEdge(source, target);
274
- }
275
- }
276
- }
277
- return adjacency;
278
- }
279
- /** BFS hop distances from `center` over an undirected adjacency map. */
280
- export function hopDistancesFromCenter(center, adjacency) {
281
- const distances = new Map();
282
- const queue = [center];
283
- distances.set(center, 0);
284
- while (queue.length > 0) {
285
- const current = queue.shift();
286
- const nextDist = (distances.get(current) ?? 0) + 1;
287
- for (const neighbour of adjacency.get(current) ?? []) {
288
- if (!distances.has(neighbour)) {
289
- distances.set(neighbour, nextDist);
290
- queue.push(neighbour);
291
- }
292
- }
293
- }
294
- return distances;
295
- }
296
- function enclosingIdeaName(node) {
297
- let current = node;
298
- while (current) {
299
- if (isIdea(current) || isOneLinerIdea(current) || isIdeaSet(current)) {
300
- return current.name;
301
- }
302
- current = current.$container;
303
- }
304
- return undefined;
305
- }
306
- function referencedNames(target) {
307
- const names = [];
308
- const idea = referenceIdea(target);
309
- if (idea) {
310
- names.push(idea.ref?.name ?? idea.$refText);
311
- }
312
- if (isLocalReference(target) && target.ideaset) {
313
- names.push(target.ideaset.ref?.name ?? target.ideaset.$refText);
314
- }
315
- if (isQualifiedReference(target) && target.ideaset) {
316
- names.push(target.ideaset.ref?.name ?? target.ideaset.$refText);
317
- }
318
- return names.filter(Boolean);
319
- }
320
- //# sourceMappingURL=reqlan-completion-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reqlan-completion-provider.js","sourceRoot":"","sources":["../../src/reqlan-completion-provider.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EACH,yBAAyB,EAI5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,cAAc,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,oBAAoB,EACpB,UAAU,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAA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AC;IACD,IAAI,gBAAgB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,oBAAoB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACjD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC"}
@@ -1,31 +0,0 @@
1
- /**
2
- * Go-to-definition for imports, file references, symbols, and embedded comment references.
3
- */
4
- import type { CstNode, LangiumDocument, MaybePromise } from 'langium';
5
- import { DefaultDefinitionProvider, type GoToLink } from 'langium/lsp';
6
- import type { DefinitionParams } from 'vscode-languageserver';
7
- import { LocationLink } from 'vscode-languageserver';
8
- import type { ReqlanServices } from './reqlan-module.js';
9
- export declare class ReqlanDefinitionProvider extends DefaultDefinitionProvider {
10
- private readonly documents;
11
- private readonly fileSystem;
12
- private readonly services;
13
- constructor(services: ReqlanServices);
14
- private pathContext;
15
- getDefinition(document: LangiumDocument, params: DefinitionParams): MaybePromise<LocationLink[] | undefined>;
16
- protected findLinks(source: CstNode): GoToLink[];
17
- private linkForFileReference;
18
- private createNamespaceImportLink;
19
- private linkForNamespaceImportReference;
20
- private linkForImportPath;
21
- private isOnQualifiedReferencePath;
22
- private redirectImportPathLink;
23
- private createImportedFileLink;
24
- private createFileLink;
25
- private createCommentIdeaReferenceLinks;
26
- private findAnonymousImportPathLinkAtPosition;
27
- private findImportPathLinkAtPosition;
28
- private findFileReferenceLinkAtPosition;
29
- private toLocationLink;
30
- private resolvedFileLinkToLocationLink;
31
- }
@@ -1,240 +0,0 @@
1
- import { AstUtils, CstUtils, GrammarUtils, URI } from 'langium';
2
- import { DefaultDefinitionProvider } from 'langium/lsp';
3
- import { LocationLink } from 'vscode-languageserver';
4
- import { findCommentReferencePartAt, resolveCommentDefinitionLinks } from './reqlan-comment-resolver.js';
5
- import { resolveFileReferenceLink, resolveImportPathLink, resolveQualifiedReferencePathLink, resolvedFileLinkToGoToTarget, resolvedFileLinkToGoToTargetFromFilesystem } from './reqlan-file-link-resolver.js';
6
- import { isNamespaceImportOnlyReference, resolveNamespaceImportReferenceLink } from './reqlan-namespace-import-links.js';
7
- import { findFileReferenceAtPosition } from './reqlan-reference-at-position.js';
8
- import { isMarkdownLinkLabelPosition } from './reqlan-markdown-links.js';
9
- import { isFileReference, isFileSymbolReference, isFromImport, isImport, isLocalReference, isQualifiedReference } from './generated/ast.js';
10
- import { pathResolveContextFromServices } from './reqlan-path-resolve.js';
11
- export class ReqlanDefinitionProvider extends DefaultDefinitionProvider {
12
- constructor(services) {
13
- super(services);
14
- this.documents = services.shared.workspace.LangiumDocuments;
15
- this.fileSystem = services.shared.workspace.FileSystemProvider;
16
- this.services = services;
17
- }
18
- pathContext() {
19
- return pathResolveContextFromServices(this.services);
20
- }
21
- getDefinition(document, params) {
22
- if (isMarkdownLinkLabelPosition(document, params.position)) {
23
- return undefined;
24
- }
25
- const commentPart = findCommentReferencePartAt(document, params.position);
26
- if (commentPart?.property === 'idea') {
27
- return this.createCommentIdeaReferenceLinks(document, commentPart.reference);
28
- }
29
- const fileReference = findFileReferenceAtPosition(document, params.position, this.documents, this.fileSystem, this.pathContext());
30
- if (fileReference) {
31
- if (fileReference.resolution === 'folder' || fileReference.resolution === 'missing') {
32
- return undefined;
33
- }
34
- return [this.resolvedFileLinkToLocationLink(fileReference)];
35
- }
36
- const fileLink = this.findFileReferenceLinkAtPosition(document, params.position);
37
- if (fileLink) {
38
- return [this.toLocationLink(fileLink)];
39
- }
40
- const anonymousImportPathLink = this.findAnonymousImportPathLinkAtPosition(document, params.position);
41
- if (anonymousImportPathLink) {
42
- return [this.toLocationLink(anonymousImportPathLink)];
43
- }
44
- const importPathLink = this.findImportPathLinkAtPosition(document, params.position);
45
- if (importPathLink) {
46
- return [this.toLocationLink(importPathLink)];
47
- }
48
- return super.getDefinition(document, params);
49
- }
50
- findLinks(source) {
51
- const fileLink = this.linkForFileReference(source) ?? this.linkForNamespaceImportReference(source);
52
- if (fileLink) {
53
- return [fileLink];
54
- }
55
- const importPathLink = this.linkForImportPath(source);
56
- if (importPathLink) {
57
- return [importPathLink];
58
- }
59
- return super.findLinks(source).map(link => this.redirectImportPathLink(link) ?? link);
60
- }
61
- linkForFileReference(source) {
62
- const assignment = GrammarUtils.findAssignment(source);
63
- if (!assignment) {
64
- return undefined;
65
- }
66
- const container = source.astNode;
67
- if ((isFileReference(container) || isFileSymbolReference(container)) && assignment.feature === 'file') {
68
- return this.createFileLink(source, container);
69
- }
70
- return undefined;
71
- }
72
- createNamespaceImportLink(source, reference) {
73
- const resolved = resolveNamespaceImportReferenceLink(reference, this.documents, this.fileSystem, this.pathContext());
74
- if (!resolved) {
75
- return undefined;
76
- }
77
- const targetDocument = this.documents.getDocument(URI.parse(resolved.targetUri));
78
- if (targetDocument) {
79
- return resolvedFileLinkToGoToTarget(resolved, source, targetDocument);
80
- }
81
- return resolvedFileLinkToGoToTargetFromFilesystem(resolved, source);
82
- }
83
- linkForNamespaceImportReference(source) {
84
- const assignment = GrammarUtils.findAssignment(source);
85
- if (!assignment) {
86
- return undefined;
87
- }
88
- const container = source.astNode;
89
- if (!(isLocalReference(container) || isQualifiedReference(container))) {
90
- return undefined;
91
- }
92
- if (!isNamespaceImportOnlyReference(container)) {
93
- return undefined;
94
- }
95
- const property = assignment.feature;
96
- if (property !== 'idea' && property !== 'ideaset' && property !== 'qualifier') {
97
- return undefined;
98
- }
99
- return this.createNamespaceImportLink(source, container);
100
- }
101
- linkForImportPath(source) {
102
- let current = source;
103
- while (current) {
104
- const container = current.astNode;
105
- const assignment = GrammarUtils.findAssignment(current);
106
- if (isImport(container) && assignment?.feature === 'path') {
107
- return this.createImportedFileLink(current, container);
108
- }
109
- if (isQualifiedReference(container) && this.isOnQualifiedReferencePath(current, container)) {
110
- const importDecl = container.path?.ref;
111
- if (importDecl) {
112
- return this.createImportedFileLink(current, importDecl);
113
- }
114
- const resolved = resolveQualifiedReferencePathLink(container, this.documents, this.pathContext());
115
- if (resolved) {
116
- const targetDocument = this.documents.getDocument(URI.parse(resolved.targetUri.split('#')[0]));
117
- if (targetDocument) {
118
- return resolvedFileLinkToGoToTarget(resolved, current, targetDocument);
119
- }
120
- }
121
- }
122
- current = current.container;
123
- }
124
- return undefined;
125
- }
126
- isOnQualifiedReferencePath(source, reference) {
127
- const pathNode = reference.path?.$refNode ?? GrammarUtils.findNodeForProperty(reference.$cstNode, 'path');
128
- if (!pathNode) {
129
- return false;
130
- }
131
- return source.offset >= pathNode.offset && source.end <= pathNode.end;
132
- }
133
- redirectImportPathLink(link) {
134
- const importDecl = link.target.astNode;
135
- if (!isImportPathTarget(importDecl, link.target)) {
136
- return undefined;
137
- }
138
- return this.createImportedFileLink(link.source, importDecl);
139
- }
140
- createImportedFileLink(source, importDecl) {
141
- const resolved = resolveImportPathLink(importDecl, this.documents, this.pathContext());
142
- if (!resolved) {
143
- return undefined;
144
- }
145
- const targetDocument = this.documents.getDocument(URI.parse(resolved.targetUri.split('#')[0]));
146
- if (!targetDocument) {
147
- return undefined;
148
- }
149
- return resolvedFileLinkToGoToTarget(resolved, source, targetDocument);
150
- }
151
- createFileLink(source, reference) {
152
- const resolved = resolveFileReferenceLink(reference, this.documents, this.fileSystem, this.pathContext());
153
- if (!resolved) {
154
- return undefined;
155
- }
156
- const targetDocument = this.documents.getDocument(URI.parse(resolved.targetUri));
157
- if (targetDocument) {
158
- return resolvedFileLinkToGoToTarget(resolved, source, targetDocument);
159
- }
160
- return resolvedFileLinkToGoToTargetFromFilesystem(resolved, source);
161
- }
162
- createCommentIdeaReferenceLinks(document, reference) {
163
- return resolveCommentDefinitionLinks(reference, document, this.documents, this.pathContext());
164
- }
165
- findAnonymousImportPathLinkAtPosition(document, position) {
166
- const offset = document.textDocument.offsetAt(position);
167
- for (const node of AstUtils.streamAst(document.parseResult.value)) {
168
- if (!isQualifiedReference(node) || node.path?.ref) {
169
- continue;
170
- }
171
- const pathNode = node.path?.$refNode ?? GrammarUtils.findNodeForProperty(node.$cstNode, 'path');
172
- if (!pathNode || offset < pathNode.offset || offset >= pathNode.end) {
173
- continue;
174
- }
175
- const resolved = resolveQualifiedReferencePathLink(node, this.documents, this.pathContext());
176
- if (!resolved) {
177
- continue;
178
- }
179
- const targetDocument = this.documents.getDocument(URI.parse(resolved.targetUri.split('#')[0]));
180
- if (!targetDocument) {
181
- continue;
182
- }
183
- return resolvedFileLinkToGoToTarget(resolved, pathNode, targetDocument);
184
- }
185
- return undefined;
186
- }
187
- findImportPathLinkAtPosition(document, position) {
188
- const root = document.parseResult.value.$cstNode;
189
- if (!root) {
190
- return undefined;
191
- }
192
- const offset = document.textDocument.offsetAt(position);
193
- let current = CstUtils.findLeafNodeAtOffset(root, offset);
194
- while (current) {
195
- const link = this.linkForImportPath(current) ?? this.linkForFileReference(current) ?? this.linkForNamespaceImportReference(current);
196
- if (link) {
197
- return link;
198
- }
199
- current = current.container;
200
- }
201
- return undefined;
202
- }
203
- findFileReferenceLinkAtPosition(document, position) {
204
- const root = document.parseResult.value.$cstNode;
205
- if (!root) {
206
- return undefined;
207
- }
208
- const offset = document.textDocument.offsetAt(position);
209
- let current = CstUtils.findLeafNodeAtOffset(root, offset);
210
- while (current) {
211
- const link = this.linkForFileReference(current) ?? this.linkForNamespaceImportReference(current);
212
- if (link) {
213
- return link;
214
- }
215
- current = current.container;
216
- }
217
- return undefined;
218
- }
219
- toLocationLink(link) {
220
- return LocationLink.create(link.targetDocument.textDocument.uri, (link.target.astNode?.$cstNode ?? link.target).range, link.target.range, link.source.range);
221
- }
222
- resolvedFileLinkToLocationLink(link) {
223
- const targetRange = link.targetRange ?? {
224
- start: { line: 0, character: 0 },
225
- end: { line: 0, character: 0 }
226
- };
227
- return LocationLink.create(link.targetUri, targetRange, targetRange, link.sourceRange);
228
- }
229
- }
230
- function isImportPathTarget(node, targetCst) {
231
- if (!isImport(node)) {
232
- return false;
233
- }
234
- if (isFromImport(node) || !node.alias) {
235
- return true;
236
- }
237
- const pathNode = GrammarUtils.findNodeForProperty(node.$cstNode, 'path');
238
- return pathNode === targetCst || (pathNode !== undefined && targetCst.offset >= pathNode.offset && targetCst.end <= pathNode.end);
239
- }
240
- //# sourceMappingURL=reqlan-definition-provider.js.map