@reqlan/language 1.4.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.
- package/README.md +24 -0
- package/out/file-path-rewrite.d.ts +25 -0
- package/out/file-path-rewrite.js +56 -0
- package/out/file-path-rewrite.js.map +1 -0
- package/out/generated/ast.d.ts +1157 -0
- package/out/generated/ast.js +980 -0
- package/out/generated/ast.js.map +1 -0
- package/out/generated/grammar.d.ts +7 -0
- package/out/generated/grammar.js +3071 -0
- package/out/generated/grammar.js.map +1 -0
- package/out/generated/module.d.ts +20 -0
- package/out/generated/module.js +32 -0
- package/out/generated/module.js.map +1 -0
- package/out/index.d.ts +34 -0
- package/out/index.js +35 -0
- package/out/index.js.map +1 -0
- package/out/reqlan-attribute-catalog.d.ts +19 -0
- package/out/reqlan-attribute-catalog.js +87 -0
- package/out/reqlan-attribute-catalog.js.map +1 -0
- package/out/reqlan-code-action-provider.d.ts +55 -0
- package/out/reqlan-code-action-provider.js +269 -0
- package/out/reqlan-code-action-provider.js.map +1 -0
- package/out/reqlan-code-lens-provider.d.ts +13 -0
- package/out/reqlan-code-lens-provider.js +27 -0
- package/out/reqlan-code-lens-provider.js.map +1 -0
- package/out/reqlan-code-lens-settings.d.ts +34 -0
- package/out/reqlan-code-lens-settings.js +12 -0
- package/out/reqlan-code-lens-settings.js.map +1 -0
- package/out/reqlan-comment-resolver.d.ts +35 -0
- package/out/reqlan-comment-resolver.js +308 -0
- package/out/reqlan-comment-resolver.js.map +1 -0
- package/out/reqlan-completion-context.d.ts +46 -0
- package/out/reqlan-completion-context.js +244 -0
- package/out/reqlan-completion-context.js.map +1 -0
- package/out/reqlan-completion-provider.d.ts +41 -0
- package/out/reqlan-completion-provider.js +317 -0
- package/out/reqlan-completion-provider.js.map +1 -0
- package/out/reqlan-definition-provider.d.ts +31 -0
- package/out/reqlan-definition-provider.js +240 -0
- package/out/reqlan-definition-provider.js.map +1 -0
- package/out/reqlan-document-highlight-provider.d.ts +10 -0
- package/out/reqlan-document-highlight-provider.js +11 -0
- package/out/reqlan-document-highlight-provider.js.map +1 -0
- package/out/reqlan-document-link-provider.d.ts +14 -0
- package/out/reqlan-document-link-provider.js +24 -0
- package/out/reqlan-document-link-provider.js.map +1 -0
- package/out/reqlan-embedded-file-references.d.ts +11 -0
- package/out/reqlan-embedded-file-references.js +50 -0
- package/out/reqlan-embedded-file-references.js.map +1 -0
- package/out/reqlan-file-link-resolver.d.ts +44 -0
- package/out/reqlan-file-link-resolver.js +347 -0
- package/out/reqlan-file-link-resolver.js.map +1 -0
- package/out/reqlan-file-references.d.ts +15 -0
- package/out/reqlan-file-references.js +72 -0
- package/out/reqlan-file-references.js.map +1 -0
- package/out/reqlan-grammar-config.d.ts +5 -0
- package/out/reqlan-grammar-config.js +9 -0
- package/out/reqlan-grammar-config.js.map +1 -0
- package/out/reqlan-idea-reference-site.d.ts +14 -0
- package/out/reqlan-idea-reference-site.js +47 -0
- package/out/reqlan-idea-reference-site.js.map +1 -0
- package/out/reqlan-idea-summary.d.ts +6 -0
- package/out/reqlan-idea-summary.js +134 -0
- package/out/reqlan-idea-summary.js.map +1 -0
- package/out/reqlan-ignore-error.d.ts +10 -0
- package/out/reqlan-ignore-error.js +42 -0
- package/out/reqlan-ignore-error.js.map +1 -0
- package/out/reqlan-import-bindings.d.ts +12 -0
- package/out/reqlan-import-bindings.js +65 -0
- package/out/reqlan-import-bindings.js.map +1 -0
- package/out/reqlan-import-edits.d.ts +17 -0
- package/out/reqlan-import-edits.js +96 -0
- package/out/reqlan-import-edits.js.map +1 -0
- package/out/reqlan-imports.d.ts +22 -0
- package/out/reqlan-imports.js +61 -0
- package/out/reqlan-imports.js.map +1 -0
- package/out/reqlan-inbound-reference-inlay-label.d.ts +27 -0
- package/out/reqlan-inbound-reference-inlay-label.js +142 -0
- package/out/reqlan-inbound-reference-inlay-label.js.map +1 -0
- package/out/reqlan-inlay-hint-provider.d.ts +15 -0
- package/out/reqlan-inlay-hint-provider.js +54 -0
- package/out/reqlan-inlay-hint-provider.js.map +1 -0
- package/out/reqlan-inlay-hint-settings.d.ts +10 -0
- package/out/reqlan-inlay-hint-settings.js +10 -0
- package/out/reqlan-inlay-hint-settings.js.map +1 -0
- package/out/reqlan-linker.d.ts +26 -0
- package/out/reqlan-linker.js +83 -0
- package/out/reqlan-linker.js.map +1 -0
- package/out/reqlan-markdown-links.d.ts +28 -0
- package/out/reqlan-markdown-links.js +113 -0
- package/out/reqlan-markdown-links.js.map +1 -0
- package/out/reqlan-module.d.ts +41 -0
- package/out/reqlan-module.js +78 -0
- package/out/reqlan-module.js.map +1 -0
- package/out/reqlan-name-catalog.d.ts +23 -0
- package/out/reqlan-name-catalog.js +63 -0
- package/out/reqlan-name-catalog.js.map +1 -0
- package/out/reqlan-name-provider.d.ts +10 -0
- package/out/reqlan-name-provider.js +38 -0
- package/out/reqlan-name-provider.js.map +1 -0
- package/out/reqlan-namespace-import-links.d.ts +10 -0
- package/out/reqlan-namespace-import-links.js +69 -0
- package/out/reqlan-namespace-import-links.js.map +1 -0
- package/out/reqlan-path-completion.d.ts +50 -0
- package/out/reqlan-path-completion.js +304 -0
- package/out/reqlan-path-completion.js.map +1 -0
- package/out/reqlan-path-references.d.ts +5 -0
- package/out/reqlan-path-references.js +124 -0
- package/out/reqlan-path-references.js.map +1 -0
- package/out/reqlan-path-resolve.d.ts +81 -0
- package/out/reqlan-path-resolve.js +245 -0
- package/out/reqlan-path-resolve.js.map +1 -0
- package/out/reqlan-quoted-strings.d.ts +9 -0
- package/out/reqlan-quoted-strings.js +26 -0
- package/out/reqlan-quoted-strings.js.map +1 -0
- package/out/reqlan-reference-at-position.d.ts +20 -0
- package/out/reqlan-reference-at-position.js +89 -0
- package/out/reqlan-reference-at-position.js.map +1 -0
- package/out/reqlan-reference-code-lens.d.ts +32 -0
- package/out/reqlan-reference-code-lens.js +240 -0
- package/out/reqlan-reference-code-lens.js.map +1 -0
- package/out/reqlan-reference-search-site.d.ts +34 -0
- package/out/reqlan-reference-search-site.js +136 -0
- package/out/reqlan-reference-search-site.js.map +1 -0
- package/out/reqlan-references.d.ts +16 -0
- package/out/reqlan-references.js +51 -0
- package/out/reqlan-references.js.map +1 -0
- package/out/reqlan-scope.d.ts +25 -0
- package/out/reqlan-scope.js +259 -0
- package/out/reqlan-scope.js.map +1 -0
- package/out/reqlan-semantic-token-provider.d.ts +8 -0
- package/out/reqlan-semantic-token-provider.js +91 -0
- package/out/reqlan-semantic-token-provider.js.map +1 -0
- package/out/reqlan-token-builder.d.ts +12 -0
- package/out/reqlan-token-builder.js +459 -0
- package/out/reqlan-token-builder.js.map +1 -0
- package/out/reqlan-validator.d.ts +25 -0
- package/out/reqlan-validator.js +119 -0
- package/out/reqlan-validator.js.map +1 -0
- package/out/reqlan-workspace-attribute-catalog.d.ts +6 -0
- package/out/reqlan-workspace-attribute-catalog.js +54 -0
- package/out/reqlan-workspace-attribute-catalog.js.map +1 -0
- package/out/src/file-path-rewrite.d.ts +25 -0
- package/out/src/file-path-rewrite.js +56 -0
- package/out/src/file-path-rewrite.js.map +1 -0
- package/out/src/generated/ast.d.ts +1173 -0
- package/out/src/generated/ast.js +994 -0
- package/out/src/generated/ast.js.map +1 -0
- package/out/src/generated/grammar.d.ts +7 -0
- package/out/src/generated/grammar.js +3045 -0
- package/out/src/generated/grammar.js.map +1 -0
- package/out/src/generated/module.d.ts +20 -0
- package/out/src/generated/module.js +32 -0
- package/out/src/generated/module.js.map +1 -0
- package/out/src/index.d.ts +29 -0
- package/out/src/index.js +30 -0
- package/out/src/index.js.map +1 -0
- package/out/src/reqlan-attribute-catalog.d.ts +19 -0
- package/out/src/reqlan-attribute-catalog.js +87 -0
- package/out/src/reqlan-attribute-catalog.js.map +1 -0
- package/out/src/reqlan-code-action-provider.d.ts +34 -0
- package/out/src/reqlan-code-action-provider.js +206 -0
- package/out/src/reqlan-code-action-provider.js.map +1 -0
- package/out/src/reqlan-comment-resolver.d.ts +35 -0
- package/out/src/reqlan-comment-resolver.js +308 -0
- package/out/src/reqlan-comment-resolver.js.map +1 -0
- package/out/src/reqlan-completion-context.d.ts +46 -0
- package/out/src/reqlan-completion-context.js +244 -0
- package/out/src/reqlan-completion-context.js.map +1 -0
- package/out/src/reqlan-completion-provider.d.ts +41 -0
- package/out/src/reqlan-completion-provider.js +320 -0
- package/out/src/reqlan-completion-provider.js.map +1 -0
- package/out/src/reqlan-definition-provider.d.ts +31 -0
- package/out/src/reqlan-definition-provider.js +240 -0
- package/out/src/reqlan-definition-provider.js.map +1 -0
- package/out/src/reqlan-document-highlight-provider.d.ts +10 -0
- package/out/src/reqlan-document-highlight-provider.js +11 -0
- package/out/src/reqlan-document-highlight-provider.js.map +1 -0
- package/out/src/reqlan-document-link-provider.d.ts +14 -0
- package/out/src/reqlan-document-link-provider.js +24 -0
- package/out/src/reqlan-document-link-provider.js.map +1 -0
- package/out/src/reqlan-embedded-file-references.d.ts +11 -0
- package/out/src/reqlan-embedded-file-references.js +50 -0
- package/out/src/reqlan-embedded-file-references.js.map +1 -0
- package/out/src/reqlan-file-link-resolver.d.ts +44 -0
- package/out/src/reqlan-file-link-resolver.js +347 -0
- package/out/src/reqlan-file-link-resolver.js.map +1 -0
- package/out/src/reqlan-file-references.d.ts +15 -0
- package/out/src/reqlan-file-references.js +72 -0
- package/out/src/reqlan-file-references.js.map +1 -0
- package/out/src/reqlan-grammar-config.d.ts +5 -0
- package/out/src/reqlan-grammar-config.js +9 -0
- package/out/src/reqlan-grammar-config.js.map +1 -0
- package/out/src/reqlan-idea-summary.d.ts +6 -0
- package/out/src/reqlan-idea-summary.js +78 -0
- package/out/src/reqlan-idea-summary.js.map +1 -0
- package/out/src/reqlan-ignore-error.d.ts +10 -0
- package/out/src/reqlan-ignore-error.js +42 -0
- package/out/src/reqlan-ignore-error.js.map +1 -0
- package/out/src/reqlan-import-bindings.d.ts +12 -0
- package/out/src/reqlan-import-bindings.js +65 -0
- package/out/src/reqlan-import-bindings.js.map +1 -0
- package/out/src/reqlan-import-edits.d.ts +17 -0
- package/out/src/reqlan-import-edits.js +96 -0
- package/out/src/reqlan-import-edits.js.map +1 -0
- package/out/src/reqlan-imports.d.ts +22 -0
- package/out/src/reqlan-imports.js +61 -0
- package/out/src/reqlan-imports.js.map +1 -0
- package/out/src/reqlan-inbound-reference-inlay-label.d.ts +23 -0
- package/out/src/reqlan-inbound-reference-inlay-label.js +128 -0
- package/out/src/reqlan-inbound-reference-inlay-label.js.map +1 -0
- package/out/src/reqlan-inlay-hint-provider.d.ts +15 -0
- package/out/src/reqlan-inlay-hint-provider.js +54 -0
- package/out/src/reqlan-inlay-hint-provider.js.map +1 -0
- package/out/src/reqlan-inlay-hint-settings.d.ts +10 -0
- package/out/src/reqlan-inlay-hint-settings.js +10 -0
- package/out/src/reqlan-inlay-hint-settings.js.map +1 -0
- package/out/src/reqlan-linker.d.ts +26 -0
- package/out/src/reqlan-linker.js +86 -0
- package/out/src/reqlan-linker.js.map +1 -0
- package/out/src/reqlan-markdown-links.d.ts +28 -0
- package/out/src/reqlan-markdown-links.js +113 -0
- package/out/src/reqlan-markdown-links.js.map +1 -0
- package/out/src/reqlan-module.d.ts +41 -0
- package/out/src/reqlan-module.js +76 -0
- package/out/src/reqlan-module.js.map +1 -0
- package/out/src/reqlan-name-catalog.d.ts +23 -0
- package/out/src/reqlan-name-catalog.js +63 -0
- package/out/src/reqlan-name-catalog.js.map +1 -0
- package/out/src/reqlan-name-provider.d.ts +10 -0
- package/out/src/reqlan-name-provider.js +38 -0
- package/out/src/reqlan-name-provider.js.map +1 -0
- package/out/src/reqlan-namespace-import-links.d.ts +10 -0
- package/out/src/reqlan-namespace-import-links.js +81 -0
- package/out/src/reqlan-namespace-import-links.js.map +1 -0
- package/out/src/reqlan-path-completion.d.ts +50 -0
- package/out/src/reqlan-path-completion.js +304 -0
- package/out/src/reqlan-path-completion.js.map +1 -0
- package/out/src/reqlan-path-references.d.ts +5 -0
- package/out/src/reqlan-path-references.js +124 -0
- package/out/src/reqlan-path-references.js.map +1 -0
- package/out/src/reqlan-path-resolve.d.ts +59 -0
- package/out/src/reqlan-path-resolve.js +173 -0
- package/out/src/reqlan-path-resolve.js.map +1 -0
- package/out/src/reqlan-quoted-strings.d.ts +9 -0
- package/out/src/reqlan-quoted-strings.js +26 -0
- package/out/src/reqlan-quoted-strings.js.map +1 -0
- package/out/src/reqlan-reference-at-position.d.ts +20 -0
- package/out/src/reqlan-reference-at-position.js +89 -0
- package/out/src/reqlan-reference-at-position.js.map +1 -0
- package/out/src/reqlan-references.d.ts +16 -0
- package/out/src/reqlan-references.js +51 -0
- package/out/src/reqlan-references.js.map +1 -0
- package/out/src/reqlan-scope.d.ts +25 -0
- package/out/src/reqlan-scope.js +266 -0
- package/out/src/reqlan-scope.js.map +1 -0
- package/out/src/reqlan-semantic-token-provider.d.ts +8 -0
- package/out/src/reqlan-semantic-token-provider.js +97 -0
- package/out/src/reqlan-semantic-token-provider.js.map +1 -0
- package/out/src/reqlan-token-builder.d.ts +12 -0
- package/out/src/reqlan-token-builder.js +459 -0
- package/out/src/reqlan-token-builder.js.map +1 -0
- package/out/src/reqlan-validator.d.ts +25 -0
- package/out/src/reqlan-validator.js +119 -0
- package/out/src/reqlan-validator.js.map +1 -0
- package/out/src/reqlan-workspace-attribute-catalog.d.ts +6 -0
- package/out/src/reqlan-workspace-attribute-catalog.js +54 -0
- package/out/src/reqlan-workspace-attribute-catalog.js.map +1 -0
- package/out/test/code-actions.test.d.ts +1 -0
- package/out/test/code-actions.test.js +126 -0
- package/out/test/code-actions.test.js.map +1 -0
- package/out/test/comment-in-string.test.d.ts +1 -0
- package/out/test/comment-in-string.test.js +100 -0
- package/out/test/comment-in-string.test.js.map +1 -0
- package/out/test/completion.test.d.ts +1 -0
- package/out/test/completion.test.js +467 -0
- package/out/test/completion.test.js.map +1 -0
- package/out/test/file-path-rewrite.test.d.ts +1 -0
- package/out/test/file-path-rewrite.test.js +64 -0
- package/out/test/file-path-rewrite.test.js.map +1 -0
- package/out/test/ignore-error.test.d.ts +1 -0
- package/out/test/ignore-error.test.js +87 -0
- package/out/test/ignore-error.test.js.map +1 -0
- package/out/test/implicit-import-extension.test.d.ts +1 -0
- package/out/test/implicit-import-extension.test.js +203 -0
- package/out/test/implicit-import-extension.test.js.map +1 -0
- package/out/test/import-edits.test.d.ts +1 -0
- package/out/test/import-edits.test.js +20 -0
- package/out/test/import-edits.test.js.map +1 -0
- package/out/test/inlay-hints.test.d.ts +1 -0
- package/out/test/inlay-hints.test.js +238 -0
- package/out/test/inlay-hints.test.js.map +1 -0
- package/out/test/linking.test.d.ts +1 -0
- package/out/test/linking.test.js +754 -0
- package/out/test/linking.test.js.map +1 -0
- package/out/test/naked-strings.test.d.ts +1 -0
- package/out/test/naked-strings.test.js +50 -0
- package/out/test/naked-strings.test.js.map +1 -0
- package/out/test/parsing.test.d.ts +1 -0
- package/out/test/parsing.test.js +773 -0
- package/out/test/parsing.test.js.map +1 -0
- package/out/test/path-resolve.test.d.ts +1 -0
- package/out/test/path-resolve.test.js +88 -0
- package/out/test/path-resolve.test.js.map +1 -0
- package/out/test/references.test.d.ts +1 -0
- package/out/test/references.test.js +168 -0
- package/out/test/references.test.js.map +1 -0
- package/out/test/rqconfig.test.d.ts +1 -0
- package/out/test/rqconfig.test.js +275 -0
- package/out/test/rqconfig.test.js.map +1 -0
- package/out/test/test-requirement-refs.d.ts +8 -0
- package/out/test/test-requirement-refs.js +35 -0
- package/out/test/test-requirement-refs.js.map +1 -0
- package/out/test/testing.test.d.ts +1 -0
- package/out/test/testing.test.js +23 -0
- package/out/test/testing.test.js.map +1 -0
- package/out/test/validating.test.d.ts +1 -0
- package/out/test/validating.test.js +117 -0
- package/out/test/validating.test.js.map +1 -0
- package/out/tsconfig.tsbuildinfo +1 -0
- package/package.json +54 -0
- package/src/chevrotain.d.ts +8 -0
- package/src/file-path-rewrite.ts +96 -0
- package/src/generated/ast.ts +1481 -0
- package/src/generated/grammar.ts +3074 -0
- package/src/generated/module.ts +38 -0
- package/src/index.ts +34 -0
- package/src/reqlan-attribute-catalog.ts +100 -0
- package/src/reqlan-code-action-provider.ts +385 -0
- package/src/reqlan-code-lens-provider.ts +54 -0
- package/src/reqlan-code-lens-settings.ts +42 -0
- package/src/reqlan-comment-resolver.ts +372 -0
- package/src/reqlan-comment.langium +23 -0
- package/src/reqlan-completion-context.ts +330 -0
- package/src/reqlan-completion-provider.ts +400 -0
- package/src/reqlan-definition-provider.ts +319 -0
- package/src/reqlan-document-highlight-provider.ts +21 -0
- package/src/reqlan-document-link-provider.ts +45 -0
- package/src/reqlan-embedded-file-references.ts +72 -0
- package/src/reqlan-file-link-resolver.ts +485 -0
- package/src/reqlan-file-references.ts +84 -0
- package/src/reqlan-grammar-config.ts +14 -0
- package/src/reqlan-idea-reference-site.ts +74 -0
- package/src/reqlan-idea-summary.ts +162 -0
- package/src/reqlan-ignore-error.ts +50 -0
- package/src/reqlan-import-bindings.ts +87 -0
- package/src/reqlan-import-edits.ts +124 -0
- package/src/reqlan-imports.ts +115 -0
- package/src/reqlan-inbound-reference-inlay-label.ts +194 -0
- package/src/reqlan-inlay-hint-provider.ts +88 -0
- package/src/reqlan-inlay-hint-settings.ts +15 -0
- package/src/reqlan-linker.ts +108 -0
- package/src/reqlan-markdown-links.ts +136 -0
- package/src/reqlan-module.ts +104 -0
- package/src/reqlan-name-catalog.ts +81 -0
- package/src/reqlan-name-provider.ts +56 -0
- package/src/reqlan-namespace-import-links.ts +92 -0
- package/src/reqlan-path-completion.ts +420 -0
- package/src/reqlan-path-references.ts +140 -0
- package/src/reqlan-path-resolve.ts +346 -0
- package/src/reqlan-quoted-strings.ts +30 -0
- package/src/reqlan-reference-at-position.ts +154 -0
- package/src/reqlan-reference-code-lens.ts +323 -0
- package/src/reqlan-reference-search-site.ts +202 -0
- package/src/reqlan-references.ts +76 -0
- package/src/reqlan-scope.ts +312 -0
- package/src/reqlan-semantic-token-provider.ts +113 -0
- package/src/reqlan-token-builder.ts +492 -0
- package/src/reqlan-validator.ts +149 -0
- package/src/reqlan-workspace-attribute-catalog.ts +62 -0
- package/src/reqlan.langium +236 -0
|
@@ -0,0 +1,400 @@
|
|
|
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 { AstNode, AstNodeDescription, FileSystemProvider, LangiumDocument, LangiumDocuments } from 'langium';
|
|
12
|
+
import { AstUtils, stream } from 'langium';
|
|
13
|
+
import type { MaybePromise } from 'langium';
|
|
14
|
+
import {
|
|
15
|
+
DefaultCompletionProvider,
|
|
16
|
+
type CompletionAcceptor,
|
|
17
|
+
type CompletionContext,
|
|
18
|
+
type CompletionProviderOptions
|
|
19
|
+
} from 'langium/lsp';
|
|
20
|
+
import { reqlanStringDelimiter } from './reqlan-quoted-strings.js';
|
|
21
|
+
import type { CompletionList, CompletionParams } from 'vscode-languageserver';
|
|
22
|
+
import { CompletionItemKind, CompletionList as LspCompletionList } from 'vscode-languageserver';
|
|
23
|
+
import {
|
|
24
|
+
isAttribute,
|
|
25
|
+
isBracketReference,
|
|
26
|
+
isIdea,
|
|
27
|
+
isIdeaSet,
|
|
28
|
+
isModel,
|
|
29
|
+
isOneLinerIdea,
|
|
30
|
+
isQualifiedReference,
|
|
31
|
+
isWikiLink
|
|
32
|
+
} from './generated/ast.js';
|
|
33
|
+
import { AttributeCatalogStore, ENDORSED_ATTRIBUTE_KEYS } from './reqlan-attribute-catalog.js';
|
|
34
|
+
import {
|
|
35
|
+
findContainingIdea,
|
|
36
|
+
getAnonymousImportPathContext,
|
|
37
|
+
getAttributeKeyContext,
|
|
38
|
+
getAttributeValueContext,
|
|
39
|
+
getCompletionSite,
|
|
40
|
+
getReferencePrefixContext
|
|
41
|
+
} from './reqlan-completion-context.js';
|
|
42
|
+
import {
|
|
43
|
+
collectPathCompletionCandidates,
|
|
44
|
+
comparePathCompletionCandidates,
|
|
45
|
+
pathCompletionFilterText,
|
|
46
|
+
pathCompletionSortText,
|
|
47
|
+
type PathCompletionCandidate
|
|
48
|
+
} from './reqlan-path-completion.js';
|
|
49
|
+
import { pathResolveContextFromServices } from './reqlan-path-resolve.js';
|
|
50
|
+
import { referenceIdea } from './reqlan-references.js';
|
|
51
|
+
import { collectWorkspaceAttributeCatalog } from './reqlan-workspace-attribute-catalog.js';
|
|
52
|
+
import type { ReqlanServices } from './reqlan-module.js';
|
|
53
|
+
|
|
54
|
+
const UNREACHABLE_DISTANCE = 9999;
|
|
55
|
+
|
|
56
|
+
export class ReqlanCompletionProvider extends DefaultCompletionProvider {
|
|
57
|
+
|
|
58
|
+
private readonly documents: LangiumDocuments;
|
|
59
|
+
private readonly fileSystem: FileSystemProvider;
|
|
60
|
+
private readonly descriptions: ReqlanServices['workspace']['AstNodeDescriptionProvider'];
|
|
61
|
+
private readonly services: ReqlanServices;
|
|
62
|
+
readonly attributeCatalog: AttributeCatalogStore;
|
|
63
|
+
override readonly completionOptions: CompletionProviderOptions = {
|
|
64
|
+
triggerCharacters: ['@', '[', '.', '/', '"']
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
constructor(services: ReqlanServices, attributeCatalog = new AttributeCatalogStore()) {
|
|
68
|
+
super(services);
|
|
69
|
+
this.documents = services.shared.workspace.LangiumDocuments;
|
|
70
|
+
this.fileSystem = services.shared.workspace.FileSystemProvider;
|
|
71
|
+
this.descriptions = services.workspace.AstNodeDescriptionProvider;
|
|
72
|
+
this.services = services;
|
|
73
|
+
this.attributeCatalog = attributeCatalog;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override async getCompletion(
|
|
77
|
+
document: LangiumDocument,
|
|
78
|
+
params: CompletionParams
|
|
79
|
+
): Promise<CompletionList | undefined> {
|
|
80
|
+
const site = getCompletionSite(document, params.position);
|
|
81
|
+
if (site === 'main_description') {
|
|
82
|
+
return LspCompletionList.create([], true);
|
|
83
|
+
}
|
|
84
|
+
if (site === 'attribute_key') {
|
|
85
|
+
return this.completeAttributeKeys(document, params);
|
|
86
|
+
}
|
|
87
|
+
if (site === 'attribute_value') {
|
|
88
|
+
return this.completeAttributeValues(document, params);
|
|
89
|
+
}
|
|
90
|
+
if (site === 'anonymous_import_path') {
|
|
91
|
+
return this.completeAnonymousImportPath(document, params);
|
|
92
|
+
}
|
|
93
|
+
if (site === 'reference') {
|
|
94
|
+
return this.completeReferenceNames(document, params);
|
|
95
|
+
}
|
|
96
|
+
this.refreshWorkspaceAttributeCatalog();
|
|
97
|
+
return super.getCompletion(document, params);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
protected override completionFor(
|
|
101
|
+
context: CompletionContext,
|
|
102
|
+
next: Parameters<DefaultCompletionProvider['completionFor']>[1],
|
|
103
|
+
acceptor: CompletionAcceptor
|
|
104
|
+
): MaybePromise<void> {
|
|
105
|
+
if (next.property === 'path' || next.property === 'file') {
|
|
106
|
+
// Import paths and anonymous bracket paths share the same candidate logic.
|
|
107
|
+
this.completeImportPath(context, acceptor);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
return super.completionFor(context, next, acceptor);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
protected override getReferenceCandidates(
|
|
114
|
+
refInfo: Parameters<DefaultCompletionProvider['getReferenceCandidates']>[0],
|
|
115
|
+
context: CompletionContext
|
|
116
|
+
) {
|
|
117
|
+
const candidates = super.getReferenceCandidates(refInfo, context);
|
|
118
|
+
if (refInfo.property !== 'idea' && refInfo.property !== 'ideaset' && refInfo.property !== 'members') {
|
|
119
|
+
return candidates;
|
|
120
|
+
}
|
|
121
|
+
const descriptions = this.documents.all.toArray().flatMap(doc => {
|
|
122
|
+
const model = doc.parseResult.value;
|
|
123
|
+
if (!isModel(model)) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
return model.elements
|
|
127
|
+
.filter(element => {
|
|
128
|
+
if (refInfo.property === 'ideaset') {
|
|
129
|
+
return isIdeaSet(element);
|
|
130
|
+
}
|
|
131
|
+
return isIdea(element) || isOneLinerIdea(element);
|
|
132
|
+
})
|
|
133
|
+
.map(element => this.descriptions.createDescription(element, element.name, doc));
|
|
134
|
+
});
|
|
135
|
+
return stream([...candidates, ...descriptions]).distinct((description: AstNodeDescription) => description.name);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private completeAttributeKeys(document: LangiumDocument, params: CompletionParams): CompletionList {
|
|
139
|
+
const context = getAttributeKeyContext(document, params.position);
|
|
140
|
+
if (!context) {
|
|
141
|
+
return LspCompletionList.create([], true);
|
|
142
|
+
}
|
|
143
|
+
this.refreshWorkspaceAttributeCatalog();
|
|
144
|
+
const usedKeys = new Set(this.collectUsedAttributeKeys(document));
|
|
145
|
+
const endorsed = new Set<string>(ENDORSED_ATTRIBUTE_KEYS);
|
|
146
|
+
const items = this.attributeCatalog.get().keys.flatMap(key => {
|
|
147
|
+
if (context.prefix && !key.startsWith(context.prefix)) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
if (usedKeys.has(key)) {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
return [{
|
|
154
|
+
label: key,
|
|
155
|
+
kind: CompletionItemKind.Property,
|
|
156
|
+
insertText: key,
|
|
157
|
+
range: {
|
|
158
|
+
start: context.replaceStart,
|
|
159
|
+
end: context.replaceEnd
|
|
160
|
+
},
|
|
161
|
+
detail: endorsed.has(key) ? 'endorsed attribute' : 'workspace attribute'
|
|
162
|
+
}];
|
|
163
|
+
});
|
|
164
|
+
return LspCompletionList.create(items, true);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private completeAttributeValues(document: LangiumDocument, params: CompletionParams): CompletionList {
|
|
168
|
+
const context = getAttributeValueContext(document, params.position);
|
|
169
|
+
if (!context) {
|
|
170
|
+
return LspCompletionList.create([], true);
|
|
171
|
+
}
|
|
172
|
+
this.refreshWorkspaceAttributeCatalog();
|
|
173
|
+
const values = this.attributeCatalog.get().valuesByKey[context.attributeName] ?? [];
|
|
174
|
+
const items = values.flatMap(value => {
|
|
175
|
+
if (context.prefix && !value.startsWith(context.prefix)) {
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
return [{
|
|
179
|
+
label: value,
|
|
180
|
+
kind: CompletionItemKind.Value,
|
|
181
|
+
insertText: value,
|
|
182
|
+
range: {
|
|
183
|
+
start: context.replaceStart,
|
|
184
|
+
end: context.replaceEnd
|
|
185
|
+
},
|
|
186
|
+
detail: `@${context.attributeName}`
|
|
187
|
+
}];
|
|
188
|
+
});
|
|
189
|
+
return LspCompletionList.create(items, true);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private completeReferenceNames(document: LangiumDocument, params: CompletionParams): CompletionList {
|
|
193
|
+
const context = getReferencePrefixContext(document, params.position);
|
|
194
|
+
if (!context) {
|
|
195
|
+
return LspCompletionList.create([], true);
|
|
196
|
+
}
|
|
197
|
+
const names = new Set<string>();
|
|
198
|
+
const docs = this.documents.all.toArray();
|
|
199
|
+
if (!docs.some(doc => doc.uri.toString() === document.uri.toString())) {
|
|
200
|
+
docs.push(document);
|
|
201
|
+
}
|
|
202
|
+
for (const doc of docs) {
|
|
203
|
+
const model = doc.parseResult.value;
|
|
204
|
+
if (!isModel(model)) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
for (const element of model.elements) {
|
|
208
|
+
if (isIdea(element) || isOneLinerIdea(element) || isIdeaSet(element)) {
|
|
209
|
+
names.add(element.name);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const center = findContainingIdea(document, params.position)?.name;
|
|
214
|
+
const distances = center
|
|
215
|
+
? hopDistancesFromCenter(center, buildIdeaReferenceAdjacency(docs))
|
|
216
|
+
: new Map<string, number>();
|
|
217
|
+
const items = [...names].flatMap(name => {
|
|
218
|
+
if (context.prefix && !name.startsWith(context.prefix)) {
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
const distance = distances.get(name) ?? UNREACHABLE_DISTANCE;
|
|
222
|
+
return [{
|
|
223
|
+
label: name,
|
|
224
|
+
kind: CompletionItemKind.Reference,
|
|
225
|
+
insertText: name,
|
|
226
|
+
sortText: `${String(distance).padStart(4, '0')}_${name}`,
|
|
227
|
+
range: {
|
|
228
|
+
start: context.replaceStart,
|
|
229
|
+
end: context.replaceEnd
|
|
230
|
+
}
|
|
231
|
+
}];
|
|
232
|
+
}).sort((left, right) => {
|
|
233
|
+
const leftDistance = distances.get(String(left.label)) ?? UNREACHABLE_DISTANCE;
|
|
234
|
+
const rightDistance = distances.get(String(right.label)) ?? UNREACHABLE_DISTANCE;
|
|
235
|
+
return leftDistance - rightDistance || String(left.label).localeCompare(String(right.label));
|
|
236
|
+
});
|
|
237
|
+
return LspCompletionList.create(items, true);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private completeAnonymousImportPath(document: LangiumDocument, params: CompletionParams): CompletionList {
|
|
241
|
+
const context = getAnonymousImportPathContext(document, params.position);
|
|
242
|
+
if (!context) {
|
|
243
|
+
return LspCompletionList.create([], true);
|
|
244
|
+
}
|
|
245
|
+
const candidates = this.collectImportPathCandidates(document, context.prefix)
|
|
246
|
+
.sort((left, right) => comparePathCompletionCandidates(document, left, right));
|
|
247
|
+
const items = candidates.map(candidate => ({
|
|
248
|
+
label: candidate.path,
|
|
249
|
+
kind: candidate.isDirectory ? CompletionItemKind.Folder : CompletionItemKind.File,
|
|
250
|
+
textEdit: {
|
|
251
|
+
newText: candidate.path,
|
|
252
|
+
range: {
|
|
253
|
+
start: context.replaceStart,
|
|
254
|
+
end: context.replaceEnd
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
sortText: pathCompletionSortText(document, candidate),
|
|
258
|
+
filterText: pathCompletionFilterText(context.prefix, candidate)
|
|
259
|
+
}));
|
|
260
|
+
return LspCompletionList.create(items, true);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
private completeImportPath(context: CompletionContext, acceptor: CompletionAcceptor): void {
|
|
264
|
+
const text = context.textDocument.getText();
|
|
265
|
+
const existingText = text.substring(context.tokenOffset, context.offset);
|
|
266
|
+
let range = {
|
|
267
|
+
start: context.position,
|
|
268
|
+
end: context.position
|
|
269
|
+
};
|
|
270
|
+
let prefix = '';
|
|
271
|
+
if (existingText.length > 0) {
|
|
272
|
+
const delimiter = reqlanStringDelimiter(existingText);
|
|
273
|
+
prefix = delimiter
|
|
274
|
+
? existingText.slice(1, existingText.endsWith(delimiter) ? -1 : undefined)
|
|
275
|
+
: existingText;
|
|
276
|
+
const quoteOffset = delimiter ? 1 : 0;
|
|
277
|
+
const start = context.textDocument.positionAt(context.tokenOffset + quoteOffset);
|
|
278
|
+
const end = context.textDocument.positionAt(
|
|
279
|
+
context.tokenEndOffset - (delimiter && existingText.endsWith(delimiter) ? 1 : 0)
|
|
280
|
+
);
|
|
281
|
+
range = { start, end };
|
|
282
|
+
}
|
|
283
|
+
const candidates = this.collectImportPathCandidates(context.document, prefix)
|
|
284
|
+
.sort((left, right) => comparePathCompletionCandidates(context.document, left, right));
|
|
285
|
+
for (const candidate of candidates) {
|
|
286
|
+
const delimiter = reqlanStringDelimiter(existingText);
|
|
287
|
+
const opening = delimiter ?? '"';
|
|
288
|
+
const needsClosing = !delimiter || !existingText.endsWith(delimiter);
|
|
289
|
+
const closing = needsClosing ? opening : '';
|
|
290
|
+
acceptor(context, {
|
|
291
|
+
label: candidate.path,
|
|
292
|
+
textEdit: {
|
|
293
|
+
newText: `${delimiter ? '' : opening}${candidate.path}${closing}`,
|
|
294
|
+
range
|
|
295
|
+
},
|
|
296
|
+
kind: candidate.isDirectory ? CompletionItemKind.Folder : CompletionItemKind.File,
|
|
297
|
+
sortText: pathCompletionSortText(context.document, candidate),
|
|
298
|
+
filterText: pathCompletionFilterText(prefix, candidate)
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Shared candidate set for `import "…"` / `from "…"` and anonymous `["…"]` paths. */
|
|
304
|
+
private collectImportPathCandidates(document: LangiumDocument, prefix: string): PathCompletionCandidate[] {
|
|
305
|
+
return collectPathCompletionCandidates(
|
|
306
|
+
document,
|
|
307
|
+
this.documents,
|
|
308
|
+
this.fileSystem,
|
|
309
|
+
pathResolveContextFromServices(this.services),
|
|
310
|
+
{ extensionFilter: '.rq', prefix }
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
private collectUsedAttributeKeys(document: LangiumDocument): string[] {
|
|
315
|
+
return AstUtils.streamAst(document.parseResult.value)
|
|
316
|
+
.filter(isAttribute)
|
|
317
|
+
.map(attribute => attribute.name)
|
|
318
|
+
.toArray();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private refreshWorkspaceAttributeCatalog(): void {
|
|
322
|
+
const workspaceCatalog = collectWorkspaceAttributeCatalog(this.documents);
|
|
323
|
+
this.attributeCatalog.mergeWorkspaceKeys(workspaceCatalog.keys, workspaceCatalog.valuesByKey);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** Undirected idea↔idea edges from bracket/wikilink references in the given documents. */
|
|
328
|
+
export function buildIdeaReferenceAdjacency(documents: LangiumDocument[]): Map<string, Set<string>> {
|
|
329
|
+
const adjacency = new Map<string, Set<string>>();
|
|
330
|
+
const addEdge = (left: string, right: string) => {
|
|
331
|
+
if (!left || !right || left === right) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (!adjacency.has(left)) {
|
|
335
|
+
adjacency.set(left, new Set());
|
|
336
|
+
}
|
|
337
|
+
if (!adjacency.has(right)) {
|
|
338
|
+
adjacency.set(right, new Set());
|
|
339
|
+
}
|
|
340
|
+
adjacency.get(left)!.add(right);
|
|
341
|
+
adjacency.get(right)!.add(left);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
for (const document of documents) {
|
|
345
|
+
for (const node of AstUtils.streamAst(document.parseResult.value)) {
|
|
346
|
+
if (!isBracketReference(node) && !isWikiLink(node)) {
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
const source = enclosingIdeaName(node);
|
|
350
|
+
if (!source) {
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
for (const target of referencedNames(node.target)) {
|
|
354
|
+
addEdge(source, target);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return adjacency;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** BFS hop distances from `center` over an undirected adjacency map. */
|
|
362
|
+
export function hopDistancesFromCenter(center: string, adjacency: Map<string, Set<string>>): Map<string, number> {
|
|
363
|
+
const distances = new Map<string, number>();
|
|
364
|
+
const queue: string[] = [center];
|
|
365
|
+
distances.set(center, 0);
|
|
366
|
+
while (queue.length > 0) {
|
|
367
|
+
const current = queue.shift()!;
|
|
368
|
+
const nextDist = (distances.get(current) ?? 0) + 1;
|
|
369
|
+
for (const neighbour of adjacency.get(current) ?? []) {
|
|
370
|
+
if (!distances.has(neighbour)) {
|
|
371
|
+
distances.set(neighbour, nextDist);
|
|
372
|
+
queue.push(neighbour);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return distances;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function enclosingIdeaName(node: AstNode): string | undefined {
|
|
380
|
+
let current: AstNode | undefined = node;
|
|
381
|
+
while (current) {
|
|
382
|
+
if (isIdea(current) || isOneLinerIdea(current) || isIdeaSet(current)) {
|
|
383
|
+
return current.name;
|
|
384
|
+
}
|
|
385
|
+
current = current.$container;
|
|
386
|
+
}
|
|
387
|
+
return undefined;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function referencedNames(target: Parameters<typeof referenceIdea>[0]): string[] {
|
|
391
|
+
const names: string[] = [];
|
|
392
|
+
const idea = referenceIdea(target);
|
|
393
|
+
if (idea) {
|
|
394
|
+
names.push(idea.ref?.name ?? idea.$refText);
|
|
395
|
+
}
|
|
396
|
+
if (isQualifiedReference(target) && target.ideaset) {
|
|
397
|
+
names.push(target.ideaset.ref?.name ?? target.ideaset.$refText);
|
|
398
|
+
}
|
|
399
|
+
return names.filter(Boolean);
|
|
400
|
+
}
|