@likec4/language-server 1.18.0 → 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LikeC4FileSystem.d.ts +13 -0
- package/dist/LikeC4FileSystem.js +27 -0
- package/dist/Rpc.d.ts +9 -0
- package/dist/Rpc.js +132 -0
- package/dist/ast.d.ts +200 -0
- package/dist/ast.js +276 -0
- package/dist/browser.d.ts +7 -20
- package/dist/browser.js +13 -0
- package/dist/documentation/documentation-provider.d.ts +8 -0
- package/dist/documentation/documentation-provider.js +46 -0
- package/dist/documentation/index.d.ts +1 -0
- package/dist/documentation/index.js +1 -0
- package/dist/formatting/LikeC4Formatter.d.ts +27 -0
- package/dist/formatting/LikeC4Formatter.js +261 -0
- package/dist/formatting/utils.d.ts +6 -0
- package/dist/formatting/utils.js +15 -0
- package/dist/generated/ast.d.ts +1242 -0
- package/dist/generated/ast.js +1945 -0
- package/dist/generated/grammar.d.ts +6 -0
- package/dist/generated/grammar.js +3 -0
- package/dist/generated/module.d.ts +9 -0
- package/dist/generated/module.js +23 -0
- package/dist/generated-lib/icons.d.ts +1 -0
- package/dist/{likec4lib.mjs → generated-lib/icons.js} +1 -6
- package/dist/index.d.ts +9 -31
- package/dist/index.js +14 -0
- package/dist/like-c4.langium +845 -0
- package/dist/likec4lib.d.ts +4 -6
- package/dist/likec4lib.js +4 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.js +73 -0
- package/dist/lsp/CodeLensProvider.d.ts +9 -0
- package/dist/lsp/CodeLensProvider.js +40 -0
- package/dist/lsp/CompletionProvider.d.ts +6 -0
- package/dist/lsp/CompletionProvider.js +135 -0
- package/dist/lsp/DocumentHighlightProvider.d.ts +9 -0
- package/dist/lsp/DocumentHighlightProvider.js +10 -0
- package/dist/lsp/DocumentLinkProvider.d.ts +11 -0
- package/dist/lsp/DocumentLinkProvider.js +49 -0
- package/dist/lsp/DocumentSymbolProvider.d.ts +32 -0
- package/dist/lsp/DocumentSymbolProvider.js +274 -0
- package/dist/lsp/HoverProvider.d.ts +10 -0
- package/dist/lsp/HoverProvider.js +69 -0
- package/dist/lsp/RenameProvider.d.ts +5 -0
- package/dist/lsp/RenameProvider.js +6 -0
- package/dist/lsp/SemanticTokenProvider.d.ts +7 -0
- package/dist/lsp/SemanticTokenProvider.js +297 -0
- package/dist/lsp/index.d.ts +7 -0
- package/dist/lsp/index.js +7 -0
- package/dist/model/deployments-index.d.ts +60 -0
- package/dist/model/deployments-index.js +181 -0
- package/dist/model/fqn-computation.d.ts +3 -0
- package/dist/model/fqn-computation.js +72 -0
- package/dist/model/fqn-index.d.ts +25 -0
- package/dist/model/fqn-index.js +96 -0
- package/dist/model/index.d.ts +6 -0
- package/dist/model/index.js +6 -0
- package/dist/model/model-builder.d.ts +32 -0
- package/dist/model/model-builder.js +598 -0
- package/dist/model/model-locator.d.ts +23 -0
- package/dist/model/model-locator.js +126 -0
- package/dist/model/model-parser-where.d.ts +3 -0
- package/dist/model/model-parser-where.js +70 -0
- package/dist/model/model-parser.d.ts +292 -0
- package/dist/model/model-parser.js +72 -0
- package/dist/model/parser/Base.d.ts +28 -0
- package/dist/model/parser/Base.js +87 -0
- package/dist/model/parser/DeploymentModelParser.d.ts +33 -0
- package/dist/model/parser/DeploymentModelParser.js +162 -0
- package/dist/model/parser/DeploymentViewParser.d.ts +38 -0
- package/dist/model/parser/DeploymentViewParser.js +98 -0
- package/dist/model/parser/FqnRefParser.d.ts +29 -0
- package/dist/model/parser/FqnRefParser.js +108 -0
- package/dist/model/parser/GlobalsParser.d.ts +66 -0
- package/dist/model/parser/GlobalsParser.js +80 -0
- package/dist/model/parser/ModelParser.d.ts +27 -0
- package/dist/model/parser/ModelParser.js +122 -0
- package/dist/model/parser/PredicatesParser.d.ts +34 -0
- package/dist/model/parser/PredicatesParser.js +272 -0
- package/dist/model/parser/SpecificationParser.d.ts +27 -0
- package/dist/model/parser/SpecificationParser.js +120 -0
- package/dist/model/parser/ViewsParser.d.ts +64 -0
- package/dist/model/parser/ViewsParser.js +377 -0
- package/dist/model-change/ModelChanges.d.ts +15 -0
- package/dist/model-change/ModelChanges.js +89 -0
- package/dist/model-change/changeElementStyle.d.ts +16 -0
- package/dist/model-change/changeElementStyle.js +136 -0
- package/dist/model-change/changeViewLayout.d.ts +12 -0
- package/dist/model-change/changeViewLayout.js +32 -0
- package/dist/model-change/saveManualLayout.d.ts +11 -0
- package/dist/model-change/saveManualLayout.js +27 -0
- package/dist/module.d.ts +70 -0
- package/dist/module.js +162 -0
- package/dist/protocol.d.ts +38 -23
- package/dist/protocol.js +15 -0
- package/dist/references/index.d.ts +3 -0
- package/dist/references/index.js +3 -0
- package/dist/references/name-provider.d.ts +9 -0
- package/dist/references/name-provider.js +33 -0
- package/dist/references/scope-computation.d.ts +20 -0
- package/dist/references/scope-computation.js +281 -0
- package/dist/references/scope-provider.d.ts +16 -0
- package/dist/references/scope-provider.js +165 -0
- package/dist/shared/NodeKindProvider.d.ts +15 -0
- package/dist/shared/NodeKindProvider.js +108 -0
- package/dist/shared/WorkspaceManager.d.ts +18 -0
- package/dist/shared/WorkspaceManager.js +36 -0
- package/dist/shared/WorkspaceSymbolProvider.d.ts +3 -0
- package/dist/shared/WorkspaceSymbolProvider.js +3 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/index.js +3 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.js +1 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.js +7 -0
- package/dist/test/testServices.d.ts +22 -0
- package/dist/test/testServices.js +119 -0
- package/dist/utils/elementRef.d.ts +11 -0
- package/dist/utils/elementRef.js +15 -0
- package/dist/utils/fqnRef.d.ts +8 -0
- package/dist/utils/fqnRef.js +46 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/printDocs.d.ts +2 -0
- package/dist/utils/printDocs.js +1 -0
- package/dist/utils/stringHash.d.ts +1 -0
- package/dist/utils/stringHash.js +5 -0
- package/dist/validation/_shared.d.ts +3 -0
- package/dist/validation/_shared.js +22 -0
- package/dist/validation/deployment-checks.d.ts +6 -0
- package/dist/validation/deployment-checks.js +114 -0
- package/dist/validation/dynamic-view-rule.d.ts +4 -0
- package/dist/validation/dynamic-view-rule.js +17 -0
- package/dist/validation/dynamic-view-step.d.ts +4 -0
- package/dist/validation/dynamic-view-step.js +29 -0
- package/dist/validation/element.d.ts +4 -0
- package/dist/validation/element.js +49 -0
- package/dist/validation/index.d.ts +15 -0
- package/dist/validation/index.js +152 -0
- package/dist/validation/property-checks.d.ts +6 -0
- package/dist/validation/property-checks.js +39 -0
- package/dist/validation/relation.d.ts +5 -0
- package/dist/validation/relation.js +56 -0
- package/dist/validation/specification.d.ts +11 -0
- package/dist/validation/specification.js +136 -0
- package/dist/validation/view-predicates/element-with.d.ts +4 -0
- package/dist/validation/view-predicates/element-with.js +31 -0
- package/dist/validation/view-predicates/expanded-element.d.ts +4 -0
- package/dist/validation/view-predicates/expanded-element.js +12 -0
- package/dist/validation/view-predicates/expression-v2.d.ts +5 -0
- package/dist/validation/view-predicates/expression-v2.js +83 -0
- package/dist/validation/view-predicates/incoming.d.ts +4 -0
- package/dist/validation/view-predicates/incoming.js +16 -0
- package/dist/validation/view-predicates/index.d.ts +6 -0
- package/dist/validation/view-predicates/index.js +6 -0
- package/dist/validation/view-predicates/outgoing.d.ts +4 -0
- package/dist/validation/view-predicates/outgoing.js +16 -0
- package/dist/validation/view-predicates/relation-with.d.ts +4 -0
- package/dist/validation/view-predicates/relation-with.js +13 -0
- package/dist/validation/view.d.ts +4 -0
- package/dist/validation/view.js +23 -0
- package/dist/view-utils/assignNavigateTo.d.ts +2 -0
- package/dist/view-utils/assignNavigateTo.js +25 -0
- package/dist/view-utils/index.d.ts +2 -0
- package/dist/view-utils/index.js +2 -0
- package/dist/view-utils/manual-layout.d.ts +7 -0
- package/dist/view-utils/manual-layout.js +99 -0
- package/dist/view-utils/resolve-relative-paths.d.ts +2 -0
- package/dist/view-utils/resolve-relative-paths.js +78 -0
- package/dist/views/configurable-layouter.d.ts +7 -0
- package/dist/views/configurable-layouter.js +55 -0
- package/dist/views/index.d.ts +1 -0
- package/dist/views/index.js +1 -0
- package/dist/views/likec4-views.d.ts +26 -0
- package/dist/views/likec4-views.js +113 -0
- package/package.json +40 -54
- package/src/LikeC4FileSystem.ts +22 -21
- package/src/Rpc.ts +13 -7
- package/src/ast.ts +44 -133
- package/src/browser.ts +11 -11
- package/src/documentation/documentation-provider.ts +52 -0
- package/src/documentation/index.ts +1 -0
- package/src/generated/ast.ts +177 -177
- package/src/generated/grammar.ts +1 -1
- package/src/index.ts +13 -9
- package/src/like-c4.langium +37 -34
- package/src/logger.ts +34 -55
- package/src/lsp/CompletionProvider.ts +4 -4
- package/src/lsp/DocumentSymbolProvider.ts +110 -28
- package/src/lsp/HoverProvider.ts +5 -3
- package/src/lsp/SemanticTokenProvider.ts +2 -2
- package/src/model/deployments-index.ts +18 -14
- package/src/model/fqn-computation.ts +8 -8
- package/src/model/model-builder.ts +62 -60
- package/src/model/model-parser.ts +62 -1574
- package/src/model/parser/Base.ts +107 -0
- package/src/model/parser/DeploymentModelParser.ts +192 -0
- package/src/model/parser/DeploymentViewParser.ts +116 -0
- package/src/model/parser/FqnRefParser.ts +118 -0
- package/src/model/parser/GlobalsParser.ts +96 -0
- package/src/model/parser/ModelParser.ts +141 -0
- package/src/model/parser/PredicatesParser.ts +291 -0
- package/src/model/parser/SpecificationParser.ts +133 -0
- package/src/model/parser/ViewsParser.ts +428 -0
- package/src/module.ts +71 -25
- package/src/protocol.ts +29 -4
- package/src/references/scope-computation.ts +35 -35
- package/src/references/scope-provider.ts +13 -7
- package/src/utils/{deploymentRef.ts → fqnRef.ts} +27 -2
- package/src/validation/_shared.ts +0 -1
- package/src/validation/deployment-checks.ts +49 -62
- package/src/validation/dynamic-view-rule.ts +5 -4
- package/src/validation/dynamic-view-step.ts +23 -26
- package/src/validation/index.ts +100 -9
- package/src/validation/property-checks.ts +11 -10
- package/src/validation/specification.ts +38 -38
- package/src/validation/view-predicates/element-with.ts +6 -5
- package/src/validation/view-predicates/expanded-element.ts +6 -5
- package/src/validation/view-predicates/expression-v2.ts +101 -0
- package/src/validation/view-predicates/incoming.ts +6 -5
- package/src/validation/view-predicates/index.ts +1 -1
- package/src/validation/view-predicates/outgoing.ts +6 -5
- package/src/validation/view-predicates/relation-with.ts +6 -5
- package/src/validation/view.ts +5 -5
- package/src/view-utils/assignNavigateTo.ts +1 -1
- package/src/view-utils/manual-layout.ts +25 -0
- package/src/views/configurable-layouter.ts +65 -0
- package/src/views/index.ts +1 -0
- package/src/views/likec4-views.ts +139 -0
- package/dist/browser.cjs +0 -25
- package/dist/browser.d.cts +0 -23
- package/dist/browser.d.mts +0 -23
- package/dist/browser.mjs +0 -20
- package/dist/index.cjs +0 -53
- package/dist/index.d.cts +0 -34
- package/dist/index.d.mts +0 -34
- package/dist/index.mjs +0 -46
- package/dist/likec4lib.cjs +0 -1546
- package/dist/likec4lib.d.cts +0 -6
- package/dist/likec4lib.d.mts +0 -6
- package/dist/protocol.cjs +0 -25
- package/dist/protocol.d.cts +0 -48
- package/dist/protocol.d.mts +0 -48
- package/dist/protocol.mjs +0 -17
- package/dist/shared/language-server.CO_nmHiL.cjs +0 -7689
- package/dist/shared/language-server.Da6ey08o.d.cts +0 -1619
- package/dist/shared/language-server.De7S3e5Z.d.ts +0 -1619
- package/dist/shared/language-server.Dj4iDjtB.d.mts +0 -1619
- package/dist/shared/language-server.oO_9JoAG.mjs +0 -7666
- package/src/validation/view-predicates/deployments.ts +0 -56
|
@@ -2,27 +2,27 @@ import { nonexhaustive } from '@likec4/core'
|
|
|
2
2
|
import {
|
|
3
3
|
type AstNode,
|
|
4
4
|
type AstNodeDescription,
|
|
5
|
+
type PrecomputedScopes,
|
|
5
6
|
DefaultScopeComputation,
|
|
6
7
|
MultiMap,
|
|
7
|
-
type PrecomputedScopes
|
|
8
8
|
} from 'langium'
|
|
9
|
-
import { entries, filter, flatMap,
|
|
9
|
+
import { entries, filter, flatMap, forEachObj, groupBy, isNullish, isTruthy, pipe } from 'remeda'
|
|
10
10
|
import type { CancellationToken } from 'vscode-languageserver'
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { type LikeC4LangiumDocument, ast } from '../ast'
|
|
12
|
+
import { logWarnError } from '../logger'
|
|
13
13
|
import type { LikeC4Services } from '../module'
|
|
14
14
|
|
|
15
15
|
type ElementsContainer = ast.Model | ast.ElementBody | ast.ExtendElementBody
|
|
16
16
|
type DeploymentsContainer = ast.ModelDeployments | ast.DeploymentNodeBody
|
|
17
17
|
|
|
18
18
|
function uniqueDescriptions(
|
|
19
|
-
descs: AstNodeDescription[]
|
|
19
|
+
descs: AstNodeDescription[],
|
|
20
20
|
): AstNodeDescription[] {
|
|
21
21
|
return pipe(
|
|
22
22
|
descs,
|
|
23
23
|
groupBy(desc => `${desc.type}.${desc.name}`),
|
|
24
24
|
entries(),
|
|
25
|
-
flatMap(([_, descs]) => descs.length === 1 ? descs : [])
|
|
25
|
+
flatMap(([_, descs]) => descs.length === 1 ? descs : []),
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -33,7 +33,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
33
33
|
|
|
34
34
|
override async computeExports(
|
|
35
35
|
document: LikeC4LangiumDocument,
|
|
36
|
-
_cancelToken?: CancellationToken
|
|
36
|
+
_cancelToken?: CancellationToken,
|
|
37
37
|
): Promise<AstNodeDescription[]> {
|
|
38
38
|
const docExports: AstNodeDescription[] = []
|
|
39
39
|
try {
|
|
@@ -56,7 +56,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
56
56
|
|
|
57
57
|
this.exportDeployments(deployments, docExports, document)
|
|
58
58
|
} catch (e) {
|
|
59
|
-
|
|
59
|
+
logWarnError(e)
|
|
60
60
|
}
|
|
61
61
|
return docExports
|
|
62
62
|
}
|
|
@@ -64,7 +64,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
64
64
|
private exportViews(
|
|
65
65
|
modelViews: ast.ModelViews[] | undefined,
|
|
66
66
|
docExports: AstNodeDescription[],
|
|
67
|
-
document: LikeC4LangiumDocument
|
|
67
|
+
document: LikeC4LangiumDocument,
|
|
68
68
|
) {
|
|
69
69
|
const views = modelViews?.flatMap(m => m.views)
|
|
70
70
|
if (isNullish(views) || views.length === 0) {
|
|
@@ -76,7 +76,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
76
76
|
docExports.push(this.descriptions.createDescription(viewAst, viewAst.name, document))
|
|
77
77
|
}
|
|
78
78
|
} catch (e) {
|
|
79
|
-
|
|
79
|
+
logWarnError(e)
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -84,7 +84,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
84
84
|
private exportGlobals(
|
|
85
85
|
globals: ast.Globals[] | undefined,
|
|
86
86
|
docExports: AstNodeDescription[],
|
|
87
|
-
document: LikeC4LangiumDocument
|
|
87
|
+
document: LikeC4LangiumDocument,
|
|
88
88
|
) {
|
|
89
89
|
if (isNullish(globals) || globals.length === 0) {
|
|
90
90
|
return
|
|
@@ -96,7 +96,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
96
96
|
docExports.push(this.descriptions.createDescription(id, id.name, document))
|
|
97
97
|
}
|
|
98
98
|
} catch (e) {
|
|
99
|
-
|
|
99
|
+
logWarnError(e)
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
for (const globalStyleAst of globals.flatMap(g => g.styles)) {
|
|
@@ -106,7 +106,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
106
106
|
docExports.push(this.descriptions.createDescription(id, id.name, document))
|
|
107
107
|
}
|
|
108
108
|
} catch (e) {
|
|
109
|
-
|
|
109
|
+
logWarnError(e)
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}
|
|
@@ -114,7 +114,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
114
114
|
private exportModel(
|
|
115
115
|
models: ast.Model[] | undefined,
|
|
116
116
|
docExports: AstNodeDescription[],
|
|
117
|
-
document: LikeC4LangiumDocument
|
|
117
|
+
document: LikeC4LangiumDocument,
|
|
118
118
|
) {
|
|
119
119
|
if (isNullish(models) || models.length === 0) {
|
|
120
120
|
return
|
|
@@ -125,7 +125,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
125
125
|
docExports.push(this.descriptions.createDescription(elAst, elAst.name, document))
|
|
126
126
|
}
|
|
127
127
|
} catch (e) {
|
|
128
|
-
|
|
128
|
+
logWarnError(e)
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -133,7 +133,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
133
133
|
private exportLibrary(
|
|
134
134
|
likec4lib: ast.LikeC4Lib[] | undefined,
|
|
135
135
|
docExports: AstNodeDescription[],
|
|
136
|
-
document: LikeC4LangiumDocument
|
|
136
|
+
document: LikeC4LangiumDocument,
|
|
137
137
|
) {
|
|
138
138
|
if (isNullish(likec4lib)) {
|
|
139
139
|
return
|
|
@@ -143,14 +143,14 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
143
143
|
docExports.push(this.descriptions.createDescription(iconAst, iconAst.name, document))
|
|
144
144
|
}
|
|
145
145
|
} catch (e) {
|
|
146
|
-
|
|
146
|
+
logWarnError(e)
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
private exportSpecification(
|
|
151
151
|
specifications: ast.SpecificationRule[] | undefined,
|
|
152
152
|
docExports: AstNodeDescription[],
|
|
153
|
-
document: LikeC4LangiumDocument
|
|
153
|
+
document: LikeC4LangiumDocument,
|
|
154
154
|
) {
|
|
155
155
|
if (isNullish(specifications) || specifications.length === 0) {
|
|
156
156
|
return
|
|
@@ -161,7 +161,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
161
161
|
...s.relationships,
|
|
162
162
|
...s.deploymentNodes,
|
|
163
163
|
...s.tags,
|
|
164
|
-
...s.colors
|
|
164
|
+
...s.colors,
|
|
165
165
|
])
|
|
166
166
|
) {
|
|
167
167
|
try {
|
|
@@ -170,7 +170,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
170
170
|
case ast.isSpecificationElementKind(spec): {
|
|
171
171
|
if (isTruthy(spec.kind.name)) {
|
|
172
172
|
docExports.push(
|
|
173
|
-
this.descriptions.createDescription(spec.kind, spec.kind.name, document)
|
|
173
|
+
this.descriptions.createDescription(spec.kind, spec.kind.name, document),
|
|
174
174
|
)
|
|
175
175
|
}
|
|
176
176
|
continue
|
|
@@ -178,7 +178,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
178
178
|
case ast.isSpecificationTag(spec): {
|
|
179
179
|
if (isTruthy(spec.tag.name)) {
|
|
180
180
|
docExports.push(
|
|
181
|
-
this.descriptions.createDescription(spec.tag, '#' + spec.tag.name, document)
|
|
181
|
+
this.descriptions.createDescription(spec.tag, '#' + spec.tag.name, document),
|
|
182
182
|
)
|
|
183
183
|
}
|
|
184
184
|
continue
|
|
@@ -187,7 +187,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
187
187
|
if (isTruthy(spec.kind.name)) {
|
|
188
188
|
docExports.push(
|
|
189
189
|
this.descriptions.createDescription(spec.kind, spec.kind.name, document),
|
|
190
|
-
this.descriptions.createDescription(spec.kind, '.' + spec.kind.name, document)
|
|
190
|
+
this.descriptions.createDescription(spec.kind, '.' + spec.kind.name, document),
|
|
191
191
|
)
|
|
192
192
|
}
|
|
193
193
|
continue
|
|
@@ -195,7 +195,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
195
195
|
case ast.isSpecificationColor(spec): {
|
|
196
196
|
if (isTruthy(spec.name.name)) {
|
|
197
197
|
docExports.push(
|
|
198
|
-
this.descriptions.createDescription(spec.name, spec.name.name, document)
|
|
198
|
+
this.descriptions.createDescription(spec.name, spec.name.name, document),
|
|
199
199
|
)
|
|
200
200
|
}
|
|
201
201
|
continue
|
|
@@ -205,7 +205,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
205
205
|
nonexhaustive(spec)
|
|
206
206
|
}
|
|
207
207
|
} catch (e) {
|
|
208
|
-
|
|
208
|
+
logWarnError(e)
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -213,7 +213,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
213
213
|
private exportDeployments(
|
|
214
214
|
modelDeployments: ast.ModelDeployments[] | undefined,
|
|
215
215
|
docExports: AstNodeDescription[],
|
|
216
|
-
document: LikeC4LangiumDocument
|
|
216
|
+
document: LikeC4LangiumDocument,
|
|
217
217
|
) {
|
|
218
218
|
const nodes = modelDeployments?.flatMap(m => m.elements)
|
|
219
219
|
if (isNullish(nodes) || nodes.length === 0) {
|
|
@@ -232,7 +232,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
232
232
|
|
|
233
233
|
override computeLocalScopes(
|
|
234
234
|
document: LikeC4LangiumDocument,
|
|
235
|
-
_cancelToken?: CancellationToken
|
|
235
|
+
_cancelToken?: CancellationToken,
|
|
236
236
|
): Promise<PrecomputedScopes> {
|
|
237
237
|
return new Promise(resolve => {
|
|
238
238
|
const root = document.parseResult.value
|
|
@@ -242,16 +242,16 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
242
242
|
for (const model of root.models) {
|
|
243
243
|
try {
|
|
244
244
|
descendants.push(
|
|
245
|
-
...this.processContainer(model, scopes, document)
|
|
245
|
+
...this.processContainer(model, scopes, document),
|
|
246
246
|
)
|
|
247
247
|
} catch (e) {
|
|
248
|
-
|
|
248
|
+
logWarnError(e)
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
for (const deployment of root.deployments) {
|
|
252
252
|
try {
|
|
253
253
|
descendants.push(
|
|
254
|
-
...this.processDeployments(deployment, scopes, document)
|
|
254
|
+
...this.processDeployments(deployment, scopes, document),
|
|
255
255
|
)
|
|
256
256
|
} catch (e) {
|
|
257
257
|
logWarnError(e)
|
|
@@ -269,7 +269,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
269
269
|
protected processContainer(
|
|
270
270
|
container: ElementsContainer,
|
|
271
271
|
scopes: PrecomputedScopes,
|
|
272
|
-
document: LikeC4LangiumDocument
|
|
272
|
+
document: LikeC4LangiumDocument,
|
|
273
273
|
): AstNodeDescription[] {
|
|
274
274
|
const localScope = new MultiMap<string, AstNodeDescription>()
|
|
275
275
|
const descedants = [] as AstNodeDescription[]
|
|
@@ -292,7 +292,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
292
292
|
if (subcontainer && subcontainer.elements.length > 0) {
|
|
293
293
|
try {
|
|
294
294
|
descedants.push(
|
|
295
|
-
...this.processContainer(subcontainer, scopes, document)
|
|
295
|
+
...this.processContainer(subcontainer, scopes, document),
|
|
296
296
|
)
|
|
297
297
|
} catch (e) {
|
|
298
298
|
logWarnError(e)
|
|
@@ -309,7 +309,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
309
309
|
if (descs.length === 1) {
|
|
310
310
|
localScope.add(name, descs[0])
|
|
311
311
|
}
|
|
312
|
-
})
|
|
312
|
+
}),
|
|
313
313
|
)
|
|
314
314
|
}
|
|
315
315
|
const local = [...localScope.values()]
|
|
@@ -320,7 +320,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
320
320
|
protected processDeployments(
|
|
321
321
|
container: DeploymentsContainer,
|
|
322
322
|
scopes: PrecomputedScopes,
|
|
323
|
-
document: LikeC4LangiumDocument
|
|
323
|
+
document: LikeC4LangiumDocument,
|
|
324
324
|
): AstNodeDescription[] {
|
|
325
325
|
const localnames = new Set<string>()
|
|
326
326
|
const descedants = [] as AstNodeDescription[]
|
|
@@ -340,7 +340,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
340
340
|
if (ast.isDeploymentNode(el) && el.body) {
|
|
341
341
|
try {
|
|
342
342
|
descedants.push(
|
|
343
|
-
...this.processDeployments(el.body, scopes, document)
|
|
343
|
+
...this.processDeployments(el.body, scopes, document),
|
|
344
344
|
)
|
|
345
345
|
} catch (e) {
|
|
346
346
|
logWarnError(e)
|
|
@@ -356,7 +356,7 @@ export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
|
356
356
|
if (descs.length === 1) {
|
|
357
357
|
scopes.add(container, descs[0])
|
|
358
358
|
}
|
|
359
|
-
})
|
|
359
|
+
}),
|
|
360
360
|
)
|
|
361
361
|
}
|
|
362
362
|
return [...scopes.get(container).values()]
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
StreamImpl,
|
|
17
17
|
StreamScope
|
|
18
18
|
} from 'langium'
|
|
19
|
-
import { ast
|
|
19
|
+
import { ast } from '../ast'
|
|
20
20
|
import { logger } from '../logger'
|
|
21
21
|
import type { DeploymentsIndex, FqnIndex } from '../model'
|
|
22
22
|
import type { LikeC4Services } from '../module'
|
|
@@ -91,8 +91,8 @@ export class LikeC4ScopeProvider extends DefaultScopeProvider {
|
|
|
91
91
|
const referenceType = this.reflection.getReferenceType(context)
|
|
92
92
|
try {
|
|
93
93
|
const container = context.container
|
|
94
|
-
if (ast.
|
|
95
|
-
return this.
|
|
94
|
+
if (ast.isFqnRef(container)) {
|
|
95
|
+
return this.getScopeForFqnRef(container, context)
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
if (referenceType !== ast.Element) {
|
|
@@ -134,14 +134,20 @@ export class LikeC4ScopeProvider extends DefaultScopeProvider {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
protected
|
|
137
|
+
protected getScopeForFqnRef(container: ast.FqnRef, context: ReferenceInfo) {
|
|
138
138
|
const parent = container.parent
|
|
139
139
|
if (!parent) {
|
|
140
|
-
return
|
|
140
|
+
return this.createScope(
|
|
141
141
|
// First preference for deployment nodes
|
|
142
142
|
this.computeScope(context, ast.DeploymentNode).getAllElements(),
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
this.createScope(
|
|
144
|
+
// Second preference for deployed instances
|
|
145
|
+
this.computeScope(context, ast.DeployedInstance).getAllElements(),
|
|
146
|
+
// Third preference for elements if we are in deployment view
|
|
147
|
+
AstUtils.hasContainerOfType(container, ast.isDeploymentView)
|
|
148
|
+
? this.computeScope(context, ast.Element)
|
|
149
|
+
: EMPTY_SCOPE
|
|
150
|
+
)
|
|
145
151
|
)
|
|
146
152
|
}
|
|
147
153
|
const parentRef = parent.value.ref
|
|
@@ -2,7 +2,7 @@ import { AstUtils } from 'langium'
|
|
|
2
2
|
import { isNullish } from 'remeda'
|
|
3
3
|
import { ast } from '../ast'
|
|
4
4
|
|
|
5
|
-
export function instanceRef(deploymentRef: ast.
|
|
5
|
+
export function instanceRef(deploymentRef: ast.FqnRef): ast.DeployedInstance | null {
|
|
6
6
|
let referenceable
|
|
7
7
|
while ((referenceable = deploymentRef.value?.ref)) {
|
|
8
8
|
if (ast.isDeploymentNode(referenceable)) {
|
|
@@ -19,7 +19,7 @@ export function instanceRef(deploymentRef: ast.DeploymentRef): ast.DeployedInsta
|
|
|
19
19
|
return null
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function deploymentNodeRef(deploymentRef: ast.
|
|
22
|
+
export function deploymentNodeRef(deploymentRef: ast.FqnRef): ast.DeploymentNode | null {
|
|
23
23
|
let referenceable = deploymentRef.value.ref ?? null
|
|
24
24
|
if (!referenceable || ast.isDeploymentNode(referenceable)) {
|
|
25
25
|
return referenceable
|
|
@@ -29,3 +29,28 @@ export function deploymentNodeRef(deploymentRef: ast.DeploymentRef): ast.Deploym
|
|
|
29
29
|
// we find artifact first and then its container
|
|
30
30
|
return artifact ? AstUtils.getContainerOfType(artifact, ast.isDeploymentNode) ?? null : null
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
export function isReferenceToLogicalModel(node: ast.FqnRef) {
|
|
34
|
+
// iterate up the root parent
|
|
35
|
+
while (node.parent) {
|
|
36
|
+
node = node.parent
|
|
37
|
+
}
|
|
38
|
+
return ast.isElement(node.value.ref)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if node references deployment model
|
|
43
|
+
*/
|
|
44
|
+
export function isReferenceToDeploymentModel(node: ast.FqnRef) {
|
|
45
|
+
let referenceable
|
|
46
|
+
while ((referenceable = node.value?.ref)) {
|
|
47
|
+
if (ast.isDeploymentElement(referenceable)) {
|
|
48
|
+
return true
|
|
49
|
+
}
|
|
50
|
+
if (isNullish(node.parent)) {
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
node = node.parent
|
|
54
|
+
}
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { nonNullable } from '@likec4/core'
|
|
2
|
-
import {
|
|
1
|
+
import { FqnRef, isSameHierarchy, nonNullable } from '@likec4/core'
|
|
2
|
+
import { type ValidationCheck, AstUtils } from 'langium'
|
|
3
3
|
import { ast } from '../ast'
|
|
4
4
|
import type { LikeC4Services } from '../module'
|
|
5
5
|
import type { LikeC4NameProvider } from '../references'
|
|
@@ -14,7 +14,7 @@ export const deploymentNodeChecks = (services: LikeC4Services): ValidationCheck<
|
|
|
14
14
|
const nodeName = Names.getName(el)
|
|
15
15
|
if (!nodeName) {
|
|
16
16
|
accept('error', 'DeploymentNode must be named', {
|
|
17
|
-
node: el
|
|
17
|
+
node: el,
|
|
18
18
|
})
|
|
19
19
|
return
|
|
20
20
|
}
|
|
@@ -23,10 +23,10 @@ export const deploymentNodeChecks = (services: LikeC4Services): ValidationCheck<
|
|
|
23
23
|
if (RESERVED_WORDS.includes(nodeName)) {
|
|
24
24
|
accept('error', `Reserved word: ${nodeName}`, {
|
|
25
25
|
node: el,
|
|
26
|
-
range
|
|
26
|
+
range,
|
|
27
27
|
})
|
|
28
28
|
}
|
|
29
|
-
const fqnName = DeploymentsIndex.
|
|
29
|
+
const fqnName = DeploymentsIndex.getFqn(el)
|
|
30
30
|
|
|
31
31
|
const withSameName = DeploymentsIndex.byFqn(fqnName).limit(2).toArray()
|
|
32
32
|
if (withSameName.length > 1) {
|
|
@@ -35,8 +35,8 @@ export const deploymentNodeChecks = (services: LikeC4Services): ValidationCheck<
|
|
|
35
35
|
`Duplicate node name "${fqnName}"`,
|
|
36
36
|
{
|
|
37
37
|
node: el,
|
|
38
|
-
range
|
|
39
|
-
}
|
|
38
|
+
range,
|
|
39
|
+
},
|
|
40
40
|
)
|
|
41
41
|
}
|
|
42
42
|
})
|
|
@@ -50,7 +50,7 @@ export const deployedInstanceChecks = (services: LikeC4Services): ValidationChec
|
|
|
50
50
|
const artifactName = Names.getName(el)
|
|
51
51
|
if (!artifactName) {
|
|
52
52
|
accept('error', 'Deployed instance must be named, unique inside node', {
|
|
53
|
-
node: el
|
|
53
|
+
node: el,
|
|
54
54
|
})
|
|
55
55
|
return
|
|
56
56
|
}
|
|
@@ -59,10 +59,11 @@ export const deployedInstanceChecks = (services: LikeC4Services): ValidationChec
|
|
|
59
59
|
if (RESERVED_WORDS.includes(artifactName)) {
|
|
60
60
|
accept('error', `Reserved word: ${artifactName}`, {
|
|
61
61
|
node: el,
|
|
62
|
-
range
|
|
62
|
+
range,
|
|
63
63
|
})
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
|
|
66
|
+
const fqnName = DeploymentsIndex.getFqn(el)
|
|
66
67
|
|
|
67
68
|
const withSameName = DeploymentsIndex.byFqn(fqnName).limit(2).toArray()
|
|
68
69
|
if (withSameName.length > 1) {
|
|
@@ -71,74 +72,60 @@ export const deployedInstanceChecks = (services: LikeC4Services): ValidationChec
|
|
|
71
72
|
`Duplicate instance name "${fqnName}"`,
|
|
72
73
|
{
|
|
73
74
|
node: el,
|
|
74
|
-
range
|
|
75
|
-
}
|
|
75
|
+
range,
|
|
76
|
+
},
|
|
76
77
|
)
|
|
77
78
|
}
|
|
78
79
|
})
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
export const deploymentRelationChecks = (services: LikeC4Services): ValidationCheck<ast.DeploymentRelation> => {
|
|
82
|
-
|
|
83
|
-
// const Names = services.references.NameProvider as LikeC4NameProvider
|
|
84
|
-
// const Locator = services.workspace.AstNodeLocator
|
|
85
|
-
// const fqnIndex = services.likec4.FqnIndex
|
|
83
|
+
const ModelParser = services.likec4.ModelParser
|
|
86
84
|
return tryOrLog((el, accept) => {
|
|
87
85
|
const source = el.source?.value?.ref
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
if (!source) {
|
|
87
|
+
let sourceCstText = el.source?.$cstNode?.text ?? ''
|
|
88
|
+
accept('error', `DeploymentRelation source '${sourceCstText}' not resolved`, {
|
|
89
|
+
node: el,
|
|
90
|
+
property: 'source',
|
|
91
|
+
})
|
|
91
92
|
return
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const range = el.target.$cstNode?.range ?? el.source.$cstNode?.range
|
|
98
|
-
accept('error', 'Relations between deployment nodes and instance internals are not supported', {
|
|
94
|
+
const target = el.target?.value?.ref
|
|
95
|
+
if (!target) {
|
|
96
|
+
let targetCstText = el.target?.$cstNode?.text ?? ''
|
|
97
|
+
accept('error', `DeploymentRelation target '${targetCstText}' not resolved`, {
|
|
99
98
|
node: el,
|
|
100
|
-
|
|
99
|
+
property: 'target',
|
|
101
100
|
})
|
|
101
|
+
return
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
// : source
|
|
107
|
-
// const targetEl = ast.isDeployedInstance(target)
|
|
108
|
-
// ? elementRef(target.element)
|
|
109
|
-
// : target
|
|
110
|
-
|
|
111
|
-
// if (!sourceEl || !targetEl) {
|
|
112
|
-
// return
|
|
113
|
-
// }
|
|
104
|
+
const doc = getDocument(el)
|
|
105
|
+
const parser = ModelParser.forDocument(doc)
|
|
114
106
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// const targetFqn = ast.isElement(targetEl) ? fqnIndex.getFqn(targetEl) : DeploymentsIndex.getFqnName(targetEl) as Fqn
|
|
124
|
-
// if (!targetFqn) {
|
|
125
|
-
// accept('error', 'Target not resolved', {
|
|
126
|
-
// node: el,
|
|
127
|
-
// property: 'target'
|
|
128
|
-
// })
|
|
129
|
-
// }
|
|
107
|
+
const sourceFqnRef = parser.parseFqnRef(el.source)
|
|
108
|
+
if (FqnRef.isModelRef(sourceFqnRef)) {
|
|
109
|
+
accept('error', 'DeploymentRelation must refer deployment element', {
|
|
110
|
+
node: el,
|
|
111
|
+
property: 'source',
|
|
112
|
+
})
|
|
113
|
+
return
|
|
114
|
+
}
|
|
130
115
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
116
|
+
const targetFqnRef = parser.parseFqnRef(el.target)
|
|
117
|
+
if (FqnRef.isModelRef(targetFqnRef)) {
|
|
118
|
+
accept('error', 'DeploymentRelation must refer deployment element', {
|
|
119
|
+
node: el,
|
|
120
|
+
property: 'target',
|
|
121
|
+
})
|
|
122
|
+
return
|
|
123
|
+
}
|
|
137
124
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
125
|
+
if (isSameHierarchy(sourceFqnRef.deployment, targetFqnRef.deployment)) {
|
|
126
|
+
accept('error', 'Invalid parent-child relationship', {
|
|
127
|
+
node: el,
|
|
128
|
+
})
|
|
129
|
+
}
|
|
143
130
|
})
|
|
144
131
|
}
|
|
@@ -2,21 +2,22 @@ import { nonexhaustive } from '@likec4/core'
|
|
|
2
2
|
import type { ValidationCheck } from 'langium'
|
|
3
3
|
import { ast, elementExpressionFromPredicate } from '../ast'
|
|
4
4
|
import type { LikeC4Services } from '../module'
|
|
5
|
+
import { tryOrLog } from './_shared'
|
|
5
6
|
|
|
6
7
|
export const dynamicViewRulePredicate = (
|
|
7
|
-
_services: LikeC4Services
|
|
8
|
+
_services: LikeC4Services,
|
|
8
9
|
): ValidationCheck<ast.DynamicViewPredicateIterator> => {
|
|
9
|
-
return (predicate, accept) => {
|
|
10
|
+
return tryOrLog((predicate, accept) => {
|
|
10
11
|
const expr = elementExpressionFromPredicate(predicate.value)
|
|
11
12
|
switch (true) {
|
|
12
13
|
case ast.isElementKindExpression(expr):
|
|
13
14
|
case ast.isElementTagExpression(expr):
|
|
14
15
|
case ast.isWildcardExpression(expr): {
|
|
15
16
|
accept('warning', `Predicate is ignored, as not supported in dynamic views`, {
|
|
16
|
-
node: predicate
|
|
17
|
+
node: predicate,
|
|
17
18
|
})
|
|
18
19
|
return
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
}
|
|
22
|
+
})
|
|
22
23
|
}
|
|
@@ -4,36 +4,33 @@ import { ast } from '../ast'
|
|
|
4
4
|
import { logError } from '../logger'
|
|
5
5
|
import type { LikeC4Services } from '../module'
|
|
6
6
|
import { elementRef } from '../utils/elementRef'
|
|
7
|
+
import { tryOrLog } from './_shared'
|
|
7
8
|
|
|
8
9
|
export const dynamicViewStep = (services: LikeC4Services): ValidationCheck<ast.DynamicViewStep> => {
|
|
9
10
|
const fqnIndex = services.likec4.FqnIndex
|
|
10
|
-
return (el, accept) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
11
|
+
return tryOrLog((el, accept) => {
|
|
12
|
+
const sourceEl: ast.Element | undefined = elementRef(el.source)
|
|
13
|
+
const source = sourceEl && fqnIndex.getFqn(sourceEl)
|
|
14
|
+
if (!source) {
|
|
15
|
+
accept('error', 'Source not found (not parsed/indexed yet)', {
|
|
16
|
+
node: el,
|
|
17
|
+
property: 'source',
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const targetEl: ast.Element | undefined = elementRef(el.target)
|
|
22
|
+
const target = targetEl && fqnIndex.getFqn(targetEl)
|
|
23
|
+
if (!target) {
|
|
24
|
+
accept('error', 'Target not found (not parsed/indexed yet)', {
|
|
25
|
+
node: el,
|
|
26
|
+
property: 'target',
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
} catch (e) {
|
|
36
|
-
logError(e)
|
|
30
|
+
if (source && target && (isAncestor(source, target) || isAncestor(target, source))) {
|
|
31
|
+
accept('error', 'Invalid parent-child relationship', {
|
|
32
|
+
node: el,
|
|
33
|
+
})
|
|
37
34
|
}
|
|
38
|
-
}
|
|
35
|
+
})
|
|
39
36
|
}
|