@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,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publishes idea and ideaset declarations for file-local and cross-file reference resolution.
|
|
3
|
+
*/
|
|
4
|
+
import type { AstNodeDescription, LangiumDocument, ReferenceInfo } from 'langium';
|
|
5
|
+
import { AstUtils, DefaultScopeComputation, DefaultScopeProvider, StreamScope, stream, type Scope } from 'langium';
|
|
6
|
+
import {
|
|
7
|
+
isFromImport,
|
|
8
|
+
isFromImportSpecifier,
|
|
9
|
+
isIdea,
|
|
10
|
+
isIdeaSet,
|
|
11
|
+
isLocalReference,
|
|
12
|
+
isModel,
|
|
13
|
+
isNamespaceImport,
|
|
14
|
+
isOneLinerIdea,
|
|
15
|
+
isQualifiedImport,
|
|
16
|
+
isQualifiedReference,
|
|
17
|
+
type FromImportSpecifier,
|
|
18
|
+
type IdeaSet,
|
|
19
|
+
type Import,
|
|
20
|
+
type Model,
|
|
21
|
+
type QualifiedReference
|
|
22
|
+
} from './generated/ast.js';
|
|
23
|
+
import { findFromImportSpecifierByBinding, specifierBindingName } from './reqlan-import-bindings.js';
|
|
24
|
+
import { findImportedDocument } from './reqlan-imports.js';
|
|
25
|
+
import type { ReqlanServices } from './reqlan-module.js';
|
|
26
|
+
import { pathResolveContextFromServices } from './reqlan-path-resolve.js';
|
|
27
|
+
import { qualifiedReferenceImportPath } from './reqlan-references.js';
|
|
28
|
+
|
|
29
|
+
export class ReqlanScopeComputation extends DefaultScopeComputation {
|
|
30
|
+
|
|
31
|
+
override async collectExportedSymbols(document: LangiumDocument): Promise<AstNodeDescription[]> {
|
|
32
|
+
const exports: AstNodeDescription[] = [];
|
|
33
|
+
const model = document.parseResult.value;
|
|
34
|
+
if (isModel(model)) {
|
|
35
|
+
for (const element of model.elements) {
|
|
36
|
+
if (isIdea(element) || isOneLinerIdea(element) || isIdeaSet(element)) {
|
|
37
|
+
this.addExportedSymbol(element, exports, document);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return exports;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class ReqlanScopeProvider extends DefaultScopeProvider {
|
|
46
|
+
|
|
47
|
+
protected readonly documents: ReqlanServices['shared']['workspace']['LangiumDocuments'];
|
|
48
|
+
private readonly services: ReqlanServices;
|
|
49
|
+
|
|
50
|
+
constructor(services: ReqlanServices) {
|
|
51
|
+
super(services);
|
|
52
|
+
this.documents = services.shared.workspace.LangiumDocuments;
|
|
53
|
+
this.services = services;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
override getScope(context: ReferenceInfo): Scope {
|
|
57
|
+
const container = context.container;
|
|
58
|
+
if ((isFromImportSpecifier(container) || isQualifiedImport(container)) && context.property === 'idea') {
|
|
59
|
+
const document = AstUtils.getDocument(container);
|
|
60
|
+
const path = isFromImportSpecifier(container) ? container.$container.path : container.path;
|
|
61
|
+
const importScope = this.scopeForImportPath(path, document);
|
|
62
|
+
if (importScope) {
|
|
63
|
+
return importScope;
|
|
64
|
+
}
|
|
65
|
+
return new StreamScope(stream([]));
|
|
66
|
+
}
|
|
67
|
+
if (isQualifiedReference(container)) {
|
|
68
|
+
const document = AstUtils.getDocument(container);
|
|
69
|
+
if (context.property === 'qualifier') {
|
|
70
|
+
return this.scopeForReferenceQualifiers(document);
|
|
71
|
+
}
|
|
72
|
+
if (context.property === 'path') {
|
|
73
|
+
return this.scopeForImportPaths(document);
|
|
74
|
+
}
|
|
75
|
+
if (context.property === 'ideaset') {
|
|
76
|
+
const importedDocument = this.documentForQualifiedReference(container, document);
|
|
77
|
+
if (importedDocument) {
|
|
78
|
+
return this.scopeForIdeasets(importedDocument);
|
|
79
|
+
}
|
|
80
|
+
return this.scopeForIdeasets(document);
|
|
81
|
+
}
|
|
82
|
+
if (context.property === 'idea') {
|
|
83
|
+
const qualifier = container.qualifier?.ref;
|
|
84
|
+
if (qualifier && isIdeaSet(qualifier)) {
|
|
85
|
+
return this.scopeForIdeasetMembers(qualifier, document);
|
|
86
|
+
}
|
|
87
|
+
const importDecl = container.qualifier?.ref ?? container.path?.ref;
|
|
88
|
+
if (importDecl) {
|
|
89
|
+
const importScope = this.scopeForImportDeclaration(importDecl, document);
|
|
90
|
+
if (importScope) {
|
|
91
|
+
return importScope;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const path = qualifiedReferenceImportPath(container);
|
|
95
|
+
if (path) {
|
|
96
|
+
const importScope = this.scopeForImportPath(path, document);
|
|
97
|
+
if (importScope) {
|
|
98
|
+
return importScope;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const aliasScope = this.scopeForImportAliasName(context.reference.$refText, document);
|
|
102
|
+
if (aliasScope) {
|
|
103
|
+
return aliasScope;
|
|
104
|
+
}
|
|
105
|
+
return this.scopeForFileIdeas(document);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (isIdeaSet(container) && context.property === 'members') {
|
|
109
|
+
const document = AstUtils.getDocument(container);
|
|
110
|
+
return this.scopeForFileIdeas(document);
|
|
111
|
+
}
|
|
112
|
+
if (isLocalReference(container)) {
|
|
113
|
+
const document = AstUtils.getDocument(container);
|
|
114
|
+
if (context.property === 'idea') {
|
|
115
|
+
return this.scopeForFileIdeas(document);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return super.getScope(context);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private scopeForFileIdeas(document: LangiumDocument): Scope {
|
|
122
|
+
const model = document.parseResult.value as Model;
|
|
123
|
+
if (!isModel(model)) {
|
|
124
|
+
return new StreamScope(stream([]));
|
|
125
|
+
}
|
|
126
|
+
const descriptions = model.elements
|
|
127
|
+
.filter(element => isIdea(element) || isOneLinerIdea(element))
|
|
128
|
+
.map(idea => this.descriptions.createDescription(idea, idea.name, document));
|
|
129
|
+
for (const importDecl of model.imports) {
|
|
130
|
+
if (isFromImport(importDecl)) {
|
|
131
|
+
for (const specifier of importDecl.specifiers) {
|
|
132
|
+
const target = specifier.idea.ref;
|
|
133
|
+
if (!target || (!isIdea(target) && !isOneLinerIdea(target))) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const name = specifierBindingName(specifier) ?? target.name;
|
|
137
|
+
descriptions.push(this.descriptions.createDescription(target, name, AstUtils.getDocument(target)));
|
|
138
|
+
}
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (isQualifiedImport(importDecl)) {
|
|
142
|
+
const target = importDecl.idea.ref;
|
|
143
|
+
if (!target || (!isIdea(target) && !isOneLinerIdea(target))) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const name = importDecl.alias ?? target.name;
|
|
147
|
+
descriptions.push(this.descriptions.createDescription(target, name, AstUtils.getDocument(target)));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return new StreamScope(stream(descriptions));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private scopeForIdeasetMembers(ideaset: IdeaSet, document: LangiumDocument): Scope {
|
|
154
|
+
const descriptions = ideaset.members
|
|
155
|
+
.map(member => member.ref)
|
|
156
|
+
.filter((target): target is NonNullable<typeof target> =>
|
|
157
|
+
target !== undefined && (isIdea(target) || isOneLinerIdea(target))
|
|
158
|
+
)
|
|
159
|
+
.map(target => this.descriptions.createDescription(target, target.name, AstUtils.getDocument(target)));
|
|
160
|
+
if (descriptions.length > 0) {
|
|
161
|
+
return new StreamScope(stream(descriptions));
|
|
162
|
+
}
|
|
163
|
+
return this.scopeForFileIdeas(document);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private scopeForIdeasets(document: LangiumDocument): Scope {
|
|
167
|
+
const model = document.parseResult.value as Model;
|
|
168
|
+
if (!isModel(model)) {
|
|
169
|
+
return new StreamScope(stream([]));
|
|
170
|
+
}
|
|
171
|
+
const descriptions = model.elements
|
|
172
|
+
.filter(isIdeaSet)
|
|
173
|
+
.map(ideaset => this.descriptions.createDescription(ideaset, ideaset.name, document));
|
|
174
|
+
return new StreamScope(stream(descriptions));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private scopeForReferenceQualifiers(document: LangiumDocument): Scope {
|
|
178
|
+
const model = document.parseResult.value as Model;
|
|
179
|
+
if (!isModel(model)) {
|
|
180
|
+
return new StreamScope(stream([]));
|
|
181
|
+
}
|
|
182
|
+
const locals = model.elements
|
|
183
|
+
.filter(element => isIdea(element) || isOneLinerIdea(element) || isIdeaSet(element))
|
|
184
|
+
.map(element => this.descriptions.createDescription(element, element.name, document));
|
|
185
|
+
const namedImports = model.imports.flatMap(importDecl => {
|
|
186
|
+
if (isFromImport(importDecl)) {
|
|
187
|
+
return importDecl.specifiers.flatMap(specifier => {
|
|
188
|
+
const alias = specifierBindingName(specifier);
|
|
189
|
+
return alias
|
|
190
|
+
? [this.descriptions.createDescription(specifier, alias, document)]
|
|
191
|
+
: [];
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const alias = importAlias(importDecl);
|
|
195
|
+
return alias ? [this.descriptions.createDescription(importDecl, alias, document)] : [];
|
|
196
|
+
});
|
|
197
|
+
return new StreamScope(stream([...locals, ...namedImports]));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private scopeForImportPaths(document: LangiumDocument): Scope {
|
|
201
|
+
const model = document.parseResult.value as Model;
|
|
202
|
+
if (!isModel(model)) {
|
|
203
|
+
return new StreamScope(stream([]));
|
|
204
|
+
}
|
|
205
|
+
const descriptions = model.imports.map(importDecl =>
|
|
206
|
+
this.descriptions.createDescription(importDecl, importDecl.path, document)
|
|
207
|
+
);
|
|
208
|
+
return new StreamScope(stream(descriptions));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private scopeForImportDeclaration(importDecl: Import | FromImportSpecifier, document: LangiumDocument): Scope | undefined {
|
|
212
|
+
if (isFromImportSpecifier(importDecl)) {
|
|
213
|
+
const imported = this.findImportedDocument(importDecl.$container.path, document);
|
|
214
|
+
if (!imported) {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
const target = importDecl.idea.ref;
|
|
218
|
+
if (!target || (!isIdea(target) && !isOneLinerIdea(target))) {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
const description = this.descriptions.createDescription(target, target.name, imported);
|
|
222
|
+
return new StreamScope(stream([description]));
|
|
223
|
+
}
|
|
224
|
+
if (isFromImport(importDecl)) {
|
|
225
|
+
const imported = this.findImportedDocument(importDecl.path, document);
|
|
226
|
+
if (!imported) {
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
const descriptions = importDecl.specifiers
|
|
230
|
+
.map(specifier => specifier.idea.ref)
|
|
231
|
+
.filter((target): target is NonNullable<typeof target> =>
|
|
232
|
+
target !== undefined && (isIdea(target) || isOneLinerIdea(target))
|
|
233
|
+
)
|
|
234
|
+
.map(target => this.descriptions.createDescription(target, target.name, imported));
|
|
235
|
+
return new StreamScope(stream(descriptions));
|
|
236
|
+
}
|
|
237
|
+
if (isQualifiedImport(importDecl)) {
|
|
238
|
+
const imported = this.findImportedDocument(importDecl.path, document);
|
|
239
|
+
if (!imported) {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
const target = importDecl.idea.ref;
|
|
243
|
+
if (!target || (!isIdea(target) && !isOneLinerIdea(target))) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
const description = this.descriptions.createDescription(target, target.name, imported);
|
|
247
|
+
return new StreamScope(stream([description]));
|
|
248
|
+
}
|
|
249
|
+
if (isNamespaceImport(importDecl)) {
|
|
250
|
+
return this.scopeForImportPath(importDecl.path, document);
|
|
251
|
+
}
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
private scopeForImportAliasName(alias: string, document: LangiumDocument): Scope | undefined {
|
|
256
|
+
const model = document.parseResult.value as Model;
|
|
257
|
+
if (!isModel(model)) {
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
const specifier = findFromImportSpecifierByBinding(model.imports, alias);
|
|
261
|
+
if (specifier) {
|
|
262
|
+
return this.scopeForImportDeclaration(specifier, document);
|
|
263
|
+
}
|
|
264
|
+
const importDecl = model.imports.find(entry => importAlias(entry) === alias);
|
|
265
|
+
if (!importDecl) {
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
return this.scopeForImportDeclaration(importDecl, document);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private scopeForImportPath(path: string, document: LangiumDocument): Scope | undefined {
|
|
272
|
+
const imported = this.findImportedDocument(path, document);
|
|
273
|
+
if (!imported) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
const model = imported.parseResult.value;
|
|
277
|
+
if (!isModel(model)) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
const descriptions = model.elements
|
|
281
|
+
.filter(element => isIdea(element) || isOneLinerIdea(element))
|
|
282
|
+
.map(idea => this.descriptions.createDescription(idea, idea.name, imported));
|
|
283
|
+
return new StreamScope(stream(descriptions));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
private findImportedDocument(path: string, document: LangiumDocument): LangiumDocument | undefined {
|
|
287
|
+
return findImportedDocument(
|
|
288
|
+
path,
|
|
289
|
+
document,
|
|
290
|
+
this.documents,
|
|
291
|
+
pathResolveContextFromServices(this.services)
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private documentForQualifiedReference(
|
|
296
|
+
reference: QualifiedReference,
|
|
297
|
+
document: LangiumDocument
|
|
298
|
+
): LangiumDocument | undefined {
|
|
299
|
+
const path = qualifiedReferenceImportPath(reference);
|
|
300
|
+
if (!path) {
|
|
301
|
+
return undefined;
|
|
302
|
+
}
|
|
303
|
+
return this.findImportedDocument(path, document);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function importAlias(entry: Import): string | undefined {
|
|
308
|
+
if (isFromImport(entry)) {
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
return entry.alias;
|
|
312
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic highlighting for requirement graph syntax: attributes, ideas, and references.
|
|
3
|
+
*/
|
|
4
|
+
import type { AstNode } from 'langium';
|
|
5
|
+
import { AbstractSemanticTokenProvider, type SemanticTokenAcceptor } from 'langium/lsp';
|
|
6
|
+
import { SemanticTokenModifiers, SemanticTokenTypes } from 'vscode-languageserver';
|
|
7
|
+
import {
|
|
8
|
+
isAttribute,
|
|
9
|
+
isCodeSnippet,
|
|
10
|
+
isFileReference,
|
|
11
|
+
isFileSymbolReference,
|
|
12
|
+
isFromImport,
|
|
13
|
+
isFromImportSpecifier,
|
|
14
|
+
isIdea,
|
|
15
|
+
isIdeaSet,
|
|
16
|
+
isImport,
|
|
17
|
+
isLocalReference,
|
|
18
|
+
isMarkdownLink,
|
|
19
|
+
isQualifiedImport,
|
|
20
|
+
isQualifiedReference,
|
|
21
|
+
isOneLinerIdea,
|
|
22
|
+
type Import
|
|
23
|
+
} from './generated/ast.js';
|
|
24
|
+
|
|
25
|
+
export class ReqlanSemanticTokenProvider extends AbstractSemanticTokenProvider {
|
|
26
|
+
|
|
27
|
+
protected highlightElement(node: AstNode, acceptor: SemanticTokenAcceptor): void {
|
|
28
|
+
if (isAttribute(node)) {
|
|
29
|
+
acceptor({ node, keyword: '@', type: SemanticTokenTypes.operator });
|
|
30
|
+
acceptor({ node, property: 'name', type: SemanticTokenTypes.decorator });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (isIdea(node) || isOneLinerIdea(node)) {
|
|
34
|
+
acceptor({
|
|
35
|
+
node,
|
|
36
|
+
property: 'name',
|
|
37
|
+
type: SemanticTokenTypes.type,
|
|
38
|
+
modifier: SemanticTokenModifiers.definition
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (isIdeaSet(node)) {
|
|
43
|
+
acceptor({
|
|
44
|
+
node,
|
|
45
|
+
property: 'name',
|
|
46
|
+
type: SemanticTokenTypes.namespace,
|
|
47
|
+
modifier: SemanticTokenModifiers.definition
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (isQualifiedReference(node)) {
|
|
52
|
+
if (node.qualifier) {
|
|
53
|
+
acceptor({ node, property: 'qualifier', type: SemanticTokenTypes.namespace });
|
|
54
|
+
}
|
|
55
|
+
if (node.path) {
|
|
56
|
+
acceptor({ node, property: 'path', type: SemanticTokenTypes.string });
|
|
57
|
+
}
|
|
58
|
+
if (node.ideaset) {
|
|
59
|
+
acceptor({ node, property: 'ideaset', type: SemanticTokenTypes.namespace });
|
|
60
|
+
}
|
|
61
|
+
if (node.idea) {
|
|
62
|
+
acceptor({ node, property: 'idea', type: SemanticTokenTypes.variable });
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (isLocalReference(node)) {
|
|
67
|
+
if (node.idea) {
|
|
68
|
+
acceptor({ node, property: 'idea', type: SemanticTokenTypes.variable });
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (isFileReference(node) || isFileSymbolReference(node)) {
|
|
73
|
+
acceptor({ node, property: 'file', type: SemanticTokenTypes.string });
|
|
74
|
+
if (isFileSymbolReference(node)) {
|
|
75
|
+
acceptor({ node, property: 'symbols', type: SemanticTokenTypes.method });
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (isCodeSnippet(node)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (isMarkdownLink(node)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (isImport(node)) {
|
|
86
|
+
highlightImportKeywords(node, acceptor);
|
|
87
|
+
acceptor({ node, property: 'path', type: SemanticTokenTypes.string, modifier: SemanticTokenModifiers.declaration });
|
|
88
|
+
if (!isFromImport(node) && node.alias) {
|
|
89
|
+
acceptor({ node, property: 'alias', type: SemanticTokenTypes.namespace, modifier: SemanticTokenModifiers.declaration });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (isFromImportSpecifier(node)) {
|
|
93
|
+
acceptor({ node, property: 'idea', type: SemanticTokenTypes.variable });
|
|
94
|
+
if (node.alias) {
|
|
95
|
+
acceptor({ node, property: 'alias', type: SemanticTokenTypes.namespace, modifier: SemanticTokenModifiers.declaration });
|
|
96
|
+
acceptor({ node, keyword: 'as', type: SemanticTokenTypes.keyword });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (isQualifiedImport(node)) {
|
|
100
|
+
acceptor({ node, property: 'idea', type: SemanticTokenTypes.variable });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function highlightImportKeywords(node: Import, acceptor: SemanticTokenAcceptor): void {
|
|
106
|
+
if (isFromImport(node)) {
|
|
107
|
+
acceptor({ node, keyword: 'from', type: SemanticTokenTypes.keyword });
|
|
108
|
+
}
|
|
109
|
+
acceptor({ node, keyword: 'import', type: SemanticTokenTypes.keyword });
|
|
110
|
+
if (!isFromImport(node) && node.alias) {
|
|
111
|
+
acceptor({ node, keyword: 'as', type: SemanticTokenTypes.keyword });
|
|
112
|
+
}
|
|
113
|
+
}
|