@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
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { AstUtils, GrammarUtils } from "langium";
|
|
2
|
+
import { isString } from "remeda";
|
|
3
|
+
import { ast, isParsedLikeC4LangiumDocument } from "../ast.js";
|
|
4
|
+
const { findNodeForKeyword, findNodeForProperty } = GrammarUtils;
|
|
5
|
+
const { getDocument } = AstUtils;
|
|
6
|
+
export class LikeC4ModelLocator {
|
|
7
|
+
constructor(services) {
|
|
8
|
+
this.services = services;
|
|
9
|
+
this.fqnIndex = services.likec4.FqnIndex;
|
|
10
|
+
this.deploymentsIndex = services.likec4.DeploymentsIndex;
|
|
11
|
+
this.langiumDocuments = services.shared.workspace.LangiumDocuments;
|
|
12
|
+
}
|
|
13
|
+
fqnIndex;
|
|
14
|
+
deploymentsIndex;
|
|
15
|
+
langiumDocuments;
|
|
16
|
+
documents() {
|
|
17
|
+
return this.langiumDocuments.all.filter(isParsedLikeC4LangiumDocument);
|
|
18
|
+
}
|
|
19
|
+
getParsedElement(astNodeOrFqn) {
|
|
20
|
+
if (isString(astNodeOrFqn)) {
|
|
21
|
+
const fqn2 = astNodeOrFqn;
|
|
22
|
+
const entry = this.fqnIndex.byFqn(astNodeOrFqn).head();
|
|
23
|
+
if (!entry) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const doc2 = this.langiumDocuments.getDocument(entry.documentUri);
|
|
27
|
+
if (!doc2 || !isParsedLikeC4LangiumDocument(doc2)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return doc2.c4Elements.find((e) => e.id === fqn2) ?? null;
|
|
31
|
+
}
|
|
32
|
+
const fqn = this.fqnIndex.getFqn(astNodeOrFqn);
|
|
33
|
+
if (!fqn) return null;
|
|
34
|
+
const doc = getDocument(astNodeOrFqn);
|
|
35
|
+
if (!isParsedLikeC4LangiumDocument(doc)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return doc.c4Elements.find((e) => e.id === fqn) ?? null;
|
|
39
|
+
}
|
|
40
|
+
locateElement(fqn, _prop) {
|
|
41
|
+
const entry = this.fqnIndex.byFqn(fqn).head();
|
|
42
|
+
const docsegment = entry?.nameSegment ?? entry?.selectionSegment;
|
|
43
|
+
if (!entry || !docsegment) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
uri: entry.documentUri.toString(),
|
|
48
|
+
range: docsegment.range
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
locateDeploymentElement(fqn, _prop) {
|
|
52
|
+
const entry = this.deploymentsIndex.byFqn(fqn).head();
|
|
53
|
+
const docsegment = entry?.nameSegment ?? entry?.selectionSegment;
|
|
54
|
+
if (!entry || !docsegment) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
uri: entry.documentUri.toString(),
|
|
59
|
+
range: docsegment.range
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
locateRelation(relationId) {
|
|
63
|
+
for (const doc of this.documents()) {
|
|
64
|
+
const relation = doc.c4Relations.find((r) => r.id === relationId) ?? doc.c4DeploymentRelations.find((r) => r.id === relationId);
|
|
65
|
+
if (!relation) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const node = this.services.workspace.AstNodeLocator.getAstNode(
|
|
69
|
+
doc.parseResult.value,
|
|
70
|
+
relation.astPath
|
|
71
|
+
);
|
|
72
|
+
if (!ast.isRelation(node) && !ast.isDeploymentRelation(node)) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
let targetNode = node.title ? findNodeForProperty(node.$cstNode, "title") : void 0;
|
|
76
|
+
targetNode ??= node.kind ? findNodeForProperty(node.$cstNode, "kind") : void 0;
|
|
77
|
+
targetNode ??= findNodeForProperty(node.$cstNode, "target");
|
|
78
|
+
targetNode ??= node.$cstNode;
|
|
79
|
+
if (!targetNode) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
uri: doc.uri.toString(),
|
|
84
|
+
range: targetNode.range
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
locateViewAst(viewId) {
|
|
90
|
+
for (const doc of this.documents()) {
|
|
91
|
+
const view = doc.c4Views.find((r) => r.id === viewId);
|
|
92
|
+
if (!view) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const viewAst = this.services.workspace.AstNodeLocator.getAstNode(
|
|
96
|
+
doc.parseResult.value,
|
|
97
|
+
view.astPath
|
|
98
|
+
);
|
|
99
|
+
if (ast.isLikeC4View(viewAst)) {
|
|
100
|
+
return {
|
|
101
|
+
doc,
|
|
102
|
+
view,
|
|
103
|
+
viewAst
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
locateView(viewId) {
|
|
110
|
+
const res = this.locateViewAst(viewId);
|
|
111
|
+
if (!res) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const node = res.viewAst;
|
|
115
|
+
let targetNode = node.name ? findNodeForProperty(node.$cstNode, "name") : void 0;
|
|
116
|
+
targetNode ??= findNodeForKeyword(node.$cstNode, "view");
|
|
117
|
+
targetNode ??= node.$cstNode;
|
|
118
|
+
if (!targetNode) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
uri: res.doc.uri.toString(),
|
|
123
|
+
range: targetNode.range
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { invariant, isNonEmptyArray, nonexhaustive } from "@likec4/core";
|
|
2
|
+
import { isAndOperator, isOrOperator } from "@likec4/core";
|
|
3
|
+
import { ast } from "../ast.js";
|
|
4
|
+
const parseEquals = ({ operator, not }, value) => {
|
|
5
|
+
if (operator.startsWith("!=")) {
|
|
6
|
+
return {
|
|
7
|
+
neq: value
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
if (operator.startsWith("=")) {
|
|
11
|
+
return {
|
|
12
|
+
eq: value
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return not ? { neq: value } : { eq: value };
|
|
16
|
+
};
|
|
17
|
+
export function parseWhereClause(astNode) {
|
|
18
|
+
switch (true) {
|
|
19
|
+
case ast.isWhereTagEqual(astNode): {
|
|
20
|
+
const tag = astNode.value?.ref?.name;
|
|
21
|
+
invariant(tag, "Expected tag name");
|
|
22
|
+
return {
|
|
23
|
+
tag: parseEquals(astNode, tag)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
case ast.isWhereKindEqual(astNode): {
|
|
27
|
+
const kind = astNode.value?.ref?.name;
|
|
28
|
+
invariant(kind, "Expected kind name");
|
|
29
|
+
return {
|
|
30
|
+
kind: parseEquals(astNode, kind)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
case (ast.isWhereElementNegation(astNode) || ast.isWhereRelationNegation(astNode)): {
|
|
34
|
+
return {
|
|
35
|
+
not: parseWhereClause(astNode.value)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
case ast.isWhereBinaryExpression(astNode): {
|
|
39
|
+
const left = parseWhereClause(astNode.left);
|
|
40
|
+
const right = parseWhereClause(astNode.right);
|
|
41
|
+
const operator = astNode.operator.toLowerCase();
|
|
42
|
+
switch (operator) {
|
|
43
|
+
case "and": {
|
|
44
|
+
const operands = [
|
|
45
|
+
isAndOperator(left) ? left.and : left,
|
|
46
|
+
isAndOperator(right) ? right.and : right
|
|
47
|
+
].flat();
|
|
48
|
+
invariant(isNonEmptyArray(operands), "Expected non-empty array");
|
|
49
|
+
return {
|
|
50
|
+
and: operands
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
case "or": {
|
|
54
|
+
const operands = [
|
|
55
|
+
isOrOperator(left) ? left.or : left,
|
|
56
|
+
isOrOperator(right) ? right.or : right
|
|
57
|
+
].flat();
|
|
58
|
+
invariant(isNonEmptyArray(operands), "Expected non-empty array");
|
|
59
|
+
return {
|
|
60
|
+
or: operands
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
default:
|
|
64
|
+
nonexhaustive(operator);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
default:
|
|
68
|
+
nonexhaustive(astNode);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { invariant } from '@likec4/core';
|
|
2
|
+
import type { LangiumDocument } from 'langium';
|
|
3
|
+
import type { ParsedLikeC4LangiumDocument } from '../ast';
|
|
4
|
+
import type { LikeC4Services } from '../module';
|
|
5
|
+
import { BaseParser } from './parser/Base';
|
|
6
|
+
export type ModelParsedListener = () => void;
|
|
7
|
+
declare const DocumentParserFromMixins: {
|
|
8
|
+
new (...args: any[]): {
|
|
9
|
+
parseGlobals(): void;
|
|
10
|
+
parseAndStoreGlobalPredicateGroupOrDynamic(astRule: import("../generated/ast").GlobalPredicateGroup | import("../generated/ast").GlobalDynamicPredicateGroup, id: invariant, c4Globals: import("../ast").ParsedAstGlobals): void;
|
|
11
|
+
parseGlobalPredicateGroup(astRule: import("../generated/ast").GlobalPredicateGroup): invariant[];
|
|
12
|
+
parseGlobalDynamicPredicateGroup(astRule: import("../generated/ast").GlobalDynamicPredicateGroup): invariant[];
|
|
13
|
+
parseGlobalStyleOrGroup(astRule: import("../generated/ast").GlobalStyle | import("../generated/ast").GlobalStyleGroup): invariant[];
|
|
14
|
+
parseViews(): void;
|
|
15
|
+
parseElementView(astNode: import("../generated/ast").ElementView, additionalStyles: invariant[]): import("../ast").ParsedAstElementView;
|
|
16
|
+
parseViewRule(astRule: import("../generated/ast").ViewRule): invariant;
|
|
17
|
+
parseViewRulePredicate(astNode: import("../generated/ast").ViewRulePredicate): invariant;
|
|
18
|
+
parseViewRuleGlobalPredicateRef(astRule: import("../generated/ast").ViewRuleGlobalPredicateRef | import("../generated/ast").DynamicViewGlobalPredicateRef): invariant;
|
|
19
|
+
parseViewRuleStyleOrGlobalRef(astRule: import("../generated/ast").ViewRuleStyleOrGlobalRef): invariant;
|
|
20
|
+
parseViewRuleGroup(astNode: import("../generated/ast").ViewRuleGroup): invariant;
|
|
21
|
+
parseViewRuleStyle(astRule: import("../generated/ast").ViewRuleStyle | import("../generated/ast").GlobalStyle): invariant;
|
|
22
|
+
parseRuleStyle(styleProperties: import("../generated/ast").StyleProperty[], elementExpressionsIterator: import("../generated/ast").ElementExpressionsIterator, notationProperty?: import("../generated/ast").NotationProperty): invariant;
|
|
23
|
+
parseViewRuleGlobalStyle(astRule: import("../generated/ast").ViewRuleGlobalStyle): invariant;
|
|
24
|
+
parseDynamicElementView(astNode: import("../generated/ast").DynamicView, additionalStyles: invariant[]): import("../ast").ParsedAstDynamicView;
|
|
25
|
+
parseDynamicViewRule(astRule: import("../generated/ast").DynamicViewRule): invariant;
|
|
26
|
+
parseDynamicViewIncludePredicate(astRule: import("../generated/ast").DynamicViewIncludePredicate): invariant;
|
|
27
|
+
parseDynamicParallelSteps(node: import("../generated/ast").DynamicViewParallelSteps): invariant;
|
|
28
|
+
parseDynamicStep(node: import("../generated/ast").DynamicViewStep): invariant;
|
|
29
|
+
parsePredicate(astNode: import("../generated/ast").Predicate): invariant;
|
|
30
|
+
parseElementPredicate(astNode: import("../generated/ast").ElementPredicate): invariant;
|
|
31
|
+
parseElementExpressionsIterator(astNode: import("../generated/ast").ElementExpressionsIterator): invariant[];
|
|
32
|
+
parseElementExpression(astNode: import("../generated/ast").ElementExpression): invariant;
|
|
33
|
+
parseElementPredicateWhere(astNode: import("../generated/ast").ElementPredicateWhere): invariant;
|
|
34
|
+
parseElementPredicateWith(astNode: import("../generated/ast").ElementPredicateWith): invariant;
|
|
35
|
+
parseRelationPredicate(astNode: import("../generated/ast").RelationPredicate): invariant;
|
|
36
|
+
parseRelationPredicateWhere(astNode: import("../generated/ast").RelationPredicateWhere): invariant;
|
|
37
|
+
parseRelationPredicateWith(astNode: import("../generated/ast").RelationPredicateWith, relation: invariant | invariant): invariant;
|
|
38
|
+
parseRelationExpression(astNode: import("../generated/ast").RelationExpression): invariant;
|
|
39
|
+
isValid: import("../validation").IsValidFn;
|
|
40
|
+
readonly services: LikeC4Services;
|
|
41
|
+
readonly doc: ParsedLikeC4LangiumDocument;
|
|
42
|
+
resolveFqn(node: import("../generated/ast").FqnReferenceable): invariant;
|
|
43
|
+
getAstNodePath(node: invariant): any;
|
|
44
|
+
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
45
|
+
[key: string]: string;
|
|
46
|
+
} | undefined;
|
|
47
|
+
convertTags<E extends {
|
|
48
|
+
tags?: import("../generated/ast").Tags;
|
|
49
|
+
}>(withTags?: E | undefined): any;
|
|
50
|
+
parseTags<E extends {
|
|
51
|
+
tags?: import("../generated/ast").Tags;
|
|
52
|
+
}>(withTags?: E): invariant<invariant> | null;
|
|
53
|
+
convertLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
54
|
+
parseLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
55
|
+
parseDeploymentView(astNode: import("../generated/ast").DeploymentView): import("../ast").ParsedAstDeploymentView;
|
|
56
|
+
parseDeploymentViewRule(astRule: import("../generated/ast").DeploymentViewRule): invariant;
|
|
57
|
+
parseDeploymentViewRulePredicate(astRule: import("../generated/ast").DeploymentViewRulePredicate): invariant;
|
|
58
|
+
parseDeploymentViewRuleStyle(astRule: import("../generated/ast").DeploymentViewRuleStyle): invariant;
|
|
59
|
+
parseFqnRef(astNode: import("../generated/ast").FqnRef): invariant;
|
|
60
|
+
parseFqnExpr(astNode: import("../generated/ast").FqnExpr): invariant;
|
|
61
|
+
parseFqnRefExpr(astNode: import("../generated/ast").FqnRefExpr): invariant;
|
|
62
|
+
parseFqnExpressions(astNode: import("../generated/ast").FqnExpressions): invariant[];
|
|
63
|
+
parseRelationExpr(astNode: import("../generated/ast").RelationExpr): invariant;
|
|
64
|
+
parseDeployment(): void;
|
|
65
|
+
parseDeploymentNode(astNode: import("../generated/ast").DeploymentNode): import("../ast").ParsedAstDeployment.Node;
|
|
66
|
+
parseDeployedInstance(astNode: import("../generated/ast").DeployedInstance): import("../ast").ParsedAstDeployment.Instance;
|
|
67
|
+
parseDeploymentRelation(astNode: import("../generated/ast").DeploymentRelation): import("../ast").ParsedAstDeploymentRelation;
|
|
68
|
+
};
|
|
69
|
+
} & {
|
|
70
|
+
new (...args: any[]): {
|
|
71
|
+
parseViews(): void;
|
|
72
|
+
parseElementView(astNode: import("../generated/ast").ElementView, additionalStyles: invariant[]): import("../ast").ParsedAstElementView;
|
|
73
|
+
parseViewRule(astRule: import("../generated/ast").ViewRule): invariant;
|
|
74
|
+
parseViewRulePredicate(astNode: import("../generated/ast").ViewRulePredicate): invariant;
|
|
75
|
+
parseViewRuleGlobalPredicateRef(astRule: import("../generated/ast").ViewRuleGlobalPredicateRef | import("../generated/ast").DynamicViewGlobalPredicateRef): invariant;
|
|
76
|
+
parseViewRuleStyleOrGlobalRef(astRule: import("../generated/ast").ViewRuleStyleOrGlobalRef): invariant;
|
|
77
|
+
parseViewRuleGroup(astNode: import("../generated/ast").ViewRuleGroup): invariant;
|
|
78
|
+
parseViewRuleStyle(astRule: import("../generated/ast").ViewRuleStyle | import("../generated/ast").GlobalStyle): invariant;
|
|
79
|
+
parseRuleStyle(styleProperties: import("../generated/ast").StyleProperty[], elementExpressionsIterator: import("../generated/ast").ElementExpressionsIterator, notationProperty?: import("../generated/ast").NotationProperty): invariant;
|
|
80
|
+
parseViewRuleGlobalStyle(astRule: import("../generated/ast").ViewRuleGlobalStyle): invariant;
|
|
81
|
+
parseDynamicElementView(astNode: import("../generated/ast").DynamicView, additionalStyles: invariant[]): import("../ast").ParsedAstDynamicView;
|
|
82
|
+
parseDynamicViewRule(astRule: import("../generated/ast").DynamicViewRule): invariant;
|
|
83
|
+
parseDynamicViewIncludePredicate(astRule: import("../generated/ast").DynamicViewIncludePredicate): invariant;
|
|
84
|
+
parseDynamicParallelSteps(node: import("../generated/ast").DynamicViewParallelSteps): invariant;
|
|
85
|
+
parseDynamicStep(node: import("../generated/ast").DynamicViewStep): invariant;
|
|
86
|
+
parsePredicate(astNode: import("../generated/ast").Predicate): invariant;
|
|
87
|
+
parseElementPredicate(astNode: import("../generated/ast").ElementPredicate): invariant;
|
|
88
|
+
parseElementExpressionsIterator(astNode: import("../generated/ast").ElementExpressionsIterator): invariant[];
|
|
89
|
+
parseElementExpression(astNode: import("../generated/ast").ElementExpression): invariant;
|
|
90
|
+
parseElementPredicateWhere(astNode: import("../generated/ast").ElementPredicateWhere): invariant;
|
|
91
|
+
parseElementPredicateWith(astNode: import("../generated/ast").ElementPredicateWith): invariant;
|
|
92
|
+
parseRelationPredicate(astNode: import("../generated/ast").RelationPredicate): invariant;
|
|
93
|
+
parseRelationPredicateWhere(astNode: import("../generated/ast").RelationPredicateWhere): invariant;
|
|
94
|
+
parseRelationPredicateWith(astNode: import("../generated/ast").RelationPredicateWith, relation: invariant | invariant): invariant;
|
|
95
|
+
parseRelationExpression(astNode: import("../generated/ast").RelationExpression): invariant;
|
|
96
|
+
isValid: import("../validation").IsValidFn;
|
|
97
|
+
readonly services: LikeC4Services;
|
|
98
|
+
readonly doc: ParsedLikeC4LangiumDocument;
|
|
99
|
+
resolveFqn(node: import("../generated/ast").FqnReferenceable): invariant;
|
|
100
|
+
getAstNodePath(node: invariant): any;
|
|
101
|
+
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
102
|
+
[key: string]: string;
|
|
103
|
+
} | undefined;
|
|
104
|
+
convertTags<E extends {
|
|
105
|
+
tags?: import("../generated/ast").Tags;
|
|
106
|
+
}>(withTags?: E | undefined): any;
|
|
107
|
+
parseTags<E extends {
|
|
108
|
+
tags?: import("../generated/ast").Tags;
|
|
109
|
+
}>(withTags?: E): invariant<invariant> | null;
|
|
110
|
+
convertLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
111
|
+
parseLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
112
|
+
parseDeploymentView(astNode: import("../generated/ast").DeploymentView): import("../ast").ParsedAstDeploymentView;
|
|
113
|
+
parseDeploymentViewRule(astRule: import("../generated/ast").DeploymentViewRule): invariant;
|
|
114
|
+
parseDeploymentViewRulePredicate(astRule: import("../generated/ast").DeploymentViewRulePredicate): invariant;
|
|
115
|
+
parseDeploymentViewRuleStyle(astRule: import("../generated/ast").DeploymentViewRuleStyle): invariant;
|
|
116
|
+
parseFqnRef(astNode: import("../generated/ast").FqnRef): invariant;
|
|
117
|
+
parseFqnExpr(astNode: import("../generated/ast").FqnExpr): invariant;
|
|
118
|
+
parseFqnRefExpr(astNode: import("../generated/ast").FqnRefExpr): invariant;
|
|
119
|
+
parseFqnExpressions(astNode: import("../generated/ast").FqnExpressions): invariant[];
|
|
120
|
+
parseRelationExpr(astNode: import("../generated/ast").RelationExpr): invariant;
|
|
121
|
+
parseDeployment(): void;
|
|
122
|
+
parseDeploymentNode(astNode: import("../generated/ast").DeploymentNode): import("../ast").ParsedAstDeployment.Node;
|
|
123
|
+
parseDeployedInstance(astNode: import("../generated/ast").DeployedInstance): import("../ast").ParsedAstDeployment.Instance;
|
|
124
|
+
parseDeploymentRelation(astNode: import("../generated/ast").DeploymentRelation): import("../ast").ParsedAstDeploymentRelation;
|
|
125
|
+
};
|
|
126
|
+
} & {
|
|
127
|
+
new (...args: any[]): {
|
|
128
|
+
parseSpecification(): void;
|
|
129
|
+
parseSpecificationDeploymentNodeKind({ kind, props }: import("../generated/ast").SpecificationDeploymentNodeKind): {};
|
|
130
|
+
isValid: import("../validation").IsValidFn;
|
|
131
|
+
readonly services: LikeC4Services;
|
|
132
|
+
readonly doc: ParsedLikeC4LangiumDocument;
|
|
133
|
+
resolveFqn(node: import("../generated/ast").FqnReferenceable): invariant;
|
|
134
|
+
getAstNodePath(node: invariant): any;
|
|
135
|
+
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
136
|
+
[key: string]: string;
|
|
137
|
+
} | undefined;
|
|
138
|
+
convertTags<E extends {
|
|
139
|
+
tags?: import("../generated/ast").Tags;
|
|
140
|
+
}>(withTags?: E | undefined): any;
|
|
141
|
+
parseTags<E extends {
|
|
142
|
+
tags?: import("../generated/ast").Tags;
|
|
143
|
+
}>(withTags?: E): invariant<invariant> | null;
|
|
144
|
+
convertLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
145
|
+
parseLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
146
|
+
};
|
|
147
|
+
} & {
|
|
148
|
+
new (...args: any[]): {
|
|
149
|
+
parsePredicate(astNode: import("../generated/ast").Predicate): invariant;
|
|
150
|
+
parseElementPredicate(astNode: import("../generated/ast").ElementPredicate): invariant;
|
|
151
|
+
parseElementExpressionsIterator(astNode: import("../generated/ast").ElementExpressionsIterator): invariant[];
|
|
152
|
+
parseElementExpression(astNode: import("../generated/ast").ElementExpression): invariant;
|
|
153
|
+
parseElementPredicateWhere(astNode: import("../generated/ast").ElementPredicateWhere): invariant;
|
|
154
|
+
parseElementPredicateWith(astNode: import("../generated/ast").ElementPredicateWith): invariant;
|
|
155
|
+
parseRelationPredicate(astNode: import("../generated/ast").RelationPredicate): invariant;
|
|
156
|
+
parseRelationPredicateWhere(astNode: import("../generated/ast").RelationPredicateWhere): invariant;
|
|
157
|
+
parseRelationPredicateWith(astNode: import("../generated/ast").RelationPredicateWith, relation: invariant | invariant): invariant;
|
|
158
|
+
parseRelationExpression(astNode: import("../generated/ast").RelationExpression): invariant;
|
|
159
|
+
isValid: import("../validation").IsValidFn;
|
|
160
|
+
readonly services: LikeC4Services;
|
|
161
|
+
readonly doc: ParsedLikeC4LangiumDocument;
|
|
162
|
+
resolveFqn(node: import("../generated/ast").FqnReferenceable): invariant;
|
|
163
|
+
getAstNodePath(node: invariant): any;
|
|
164
|
+
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
165
|
+
[key: string]: string;
|
|
166
|
+
} | undefined;
|
|
167
|
+
convertTags<E extends {
|
|
168
|
+
tags?: import("../generated/ast").Tags;
|
|
169
|
+
}>(withTags?: E | undefined): any;
|
|
170
|
+
parseTags<E extends {
|
|
171
|
+
tags?: import("../generated/ast").Tags;
|
|
172
|
+
}>(withTags?: E): invariant<invariant> | null;
|
|
173
|
+
convertLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
174
|
+
parseLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
175
|
+
};
|
|
176
|
+
} & {
|
|
177
|
+
new (...args: any[]): {
|
|
178
|
+
parseDeploymentView(astNode: import("../generated/ast").DeploymentView): import("../ast").ParsedAstDeploymentView;
|
|
179
|
+
parseDeploymentViewRule(astRule: import("../generated/ast").DeploymentViewRule): invariant;
|
|
180
|
+
parseDeploymentViewRulePredicate(astRule: import("../generated/ast").DeploymentViewRulePredicate): invariant;
|
|
181
|
+
parseDeploymentViewRuleStyle(astRule: import("../generated/ast").DeploymentViewRuleStyle): invariant;
|
|
182
|
+
parseFqnRef(astNode: import("../generated/ast").FqnRef): invariant;
|
|
183
|
+
parseFqnExpr(astNode: import("../generated/ast").FqnExpr): invariant;
|
|
184
|
+
parseFqnRefExpr(astNode: import("../generated/ast").FqnRefExpr): invariant;
|
|
185
|
+
parseFqnExpressions(astNode: import("../generated/ast").FqnExpressions): invariant[];
|
|
186
|
+
parseRelationExpr(astNode: import("../generated/ast").RelationExpr): invariant;
|
|
187
|
+
isValid: import("../validation").IsValidFn;
|
|
188
|
+
readonly services: LikeC4Services;
|
|
189
|
+
readonly doc: ParsedLikeC4LangiumDocument;
|
|
190
|
+
resolveFqn(node: import("../generated/ast").FqnReferenceable): invariant;
|
|
191
|
+
getAstNodePath(node: invariant): any;
|
|
192
|
+
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
193
|
+
[key: string]: string;
|
|
194
|
+
} | undefined;
|
|
195
|
+
convertTags<E extends {
|
|
196
|
+
tags?: import("../generated/ast").Tags;
|
|
197
|
+
}>(withTags?: E | undefined): any;
|
|
198
|
+
parseTags<E extends {
|
|
199
|
+
tags?: import("../generated/ast").Tags;
|
|
200
|
+
}>(withTags?: E): invariant<invariant> | null;
|
|
201
|
+
convertLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
202
|
+
parseLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
203
|
+
parseDeployment(): void;
|
|
204
|
+
parseDeploymentNode(astNode: import("../generated/ast").DeploymentNode): import("../ast").ParsedAstDeployment.Node;
|
|
205
|
+
parseDeployedInstance(astNode: import("../generated/ast").DeployedInstance): import("../ast").ParsedAstDeployment.Instance;
|
|
206
|
+
parseDeploymentRelation(astNode: import("../generated/ast").DeploymentRelation): import("../ast").ParsedAstDeploymentRelation;
|
|
207
|
+
};
|
|
208
|
+
} & {
|
|
209
|
+
new (...args: any[]): {
|
|
210
|
+
parseDeployment(): void;
|
|
211
|
+
parseDeploymentNode(astNode: import("../generated/ast").DeploymentNode): import("../ast").ParsedAstDeployment.Node;
|
|
212
|
+
parseDeployedInstance(astNode: import("../generated/ast").DeployedInstance): import("../ast").ParsedAstDeployment.Instance;
|
|
213
|
+
parseDeploymentRelation(astNode: import("../generated/ast").DeploymentRelation): import("../ast").ParsedAstDeploymentRelation;
|
|
214
|
+
parseFqnRef(astNode: import("../generated/ast").FqnRef): invariant;
|
|
215
|
+
parseFqnExpr(astNode: import("../generated/ast").FqnExpr): invariant;
|
|
216
|
+
parseFqnRefExpr(astNode: import("../generated/ast").FqnRefExpr): invariant;
|
|
217
|
+
parseFqnExpressions(astNode: import("../generated/ast").FqnExpressions): invariant[];
|
|
218
|
+
parseRelationExpr(astNode: import("../generated/ast").RelationExpr): invariant;
|
|
219
|
+
isValid: import("../validation").IsValidFn;
|
|
220
|
+
readonly services: LikeC4Services;
|
|
221
|
+
readonly doc: ParsedLikeC4LangiumDocument;
|
|
222
|
+
resolveFqn(node: import("../generated/ast").FqnReferenceable): invariant;
|
|
223
|
+
getAstNodePath(node: invariant): any;
|
|
224
|
+
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
225
|
+
[key: string]: string;
|
|
226
|
+
} | undefined;
|
|
227
|
+
convertTags<E extends {
|
|
228
|
+
tags?: import("../generated/ast").Tags;
|
|
229
|
+
}>(withTags?: E | undefined): any;
|
|
230
|
+
parseTags<E extends {
|
|
231
|
+
tags?: import("../generated/ast").Tags;
|
|
232
|
+
}>(withTags?: E): invariant<invariant> | null;
|
|
233
|
+
convertLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
234
|
+
parseLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
235
|
+
};
|
|
236
|
+
} & {
|
|
237
|
+
new (...args: any[]): {
|
|
238
|
+
parseModel(): void;
|
|
239
|
+
parseElement(astNode: import("../generated/ast").Element): import("../ast").ParsedAstElement;
|
|
240
|
+
parseRelation(astNode: import("../generated/ast").Relation): import("../ast").ParsedAstRelation;
|
|
241
|
+
isValid: import("../validation").IsValidFn;
|
|
242
|
+
readonly services: LikeC4Services;
|
|
243
|
+
readonly doc: ParsedLikeC4LangiumDocument;
|
|
244
|
+
resolveFqn(node: import("../generated/ast").FqnReferenceable): invariant;
|
|
245
|
+
getAstNodePath(node: invariant): any;
|
|
246
|
+
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
247
|
+
[key: string]: string;
|
|
248
|
+
} | undefined;
|
|
249
|
+
convertTags<E extends {
|
|
250
|
+
tags?: import("../generated/ast").Tags;
|
|
251
|
+
}>(withTags?: E | undefined): any;
|
|
252
|
+
parseTags<E extends {
|
|
253
|
+
tags?: import("../generated/ast").Tags;
|
|
254
|
+
}>(withTags?: E): invariant<invariant> | null;
|
|
255
|
+
convertLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
256
|
+
parseLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
257
|
+
};
|
|
258
|
+
} & {
|
|
259
|
+
new (...args: any[]): {
|
|
260
|
+
parseFqnRef(astNode: import("../generated/ast").FqnRef): invariant;
|
|
261
|
+
parseFqnExpr(astNode: import("../generated/ast").FqnExpr): invariant;
|
|
262
|
+
parseFqnRefExpr(astNode: import("../generated/ast").FqnRefExpr): invariant;
|
|
263
|
+
parseFqnExpressions(astNode: import("../generated/ast").FqnExpressions): invariant[];
|
|
264
|
+
parseRelationExpr(astNode: import("../generated/ast").RelationExpr): invariant;
|
|
265
|
+
isValid: import("../validation").IsValidFn;
|
|
266
|
+
readonly services: LikeC4Services;
|
|
267
|
+
readonly doc: ParsedLikeC4LangiumDocument;
|
|
268
|
+
resolveFqn(node: import("../generated/ast").FqnReferenceable): invariant;
|
|
269
|
+
getAstNodePath(node: invariant): any;
|
|
270
|
+
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
271
|
+
[key: string]: string;
|
|
272
|
+
} | undefined;
|
|
273
|
+
convertTags<E extends {
|
|
274
|
+
tags?: import("../generated/ast").Tags;
|
|
275
|
+
}>(withTags?: E | undefined): any;
|
|
276
|
+
parseTags<E extends {
|
|
277
|
+
tags?: import("../generated/ast").Tags;
|
|
278
|
+
}>(withTags?: E): invariant<invariant> | null;
|
|
279
|
+
convertLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
280
|
+
parseLinks(source?: import("../generated/ast").LinkProperty["$container"]): import("../ast").ParsedLink[] | undefined;
|
|
281
|
+
};
|
|
282
|
+
} & typeof BaseParser;
|
|
283
|
+
export declare class DocumentParser extends DocumentParserFromMixins {
|
|
284
|
+
}
|
|
285
|
+
export declare class LikeC4ModelParser {
|
|
286
|
+
private services;
|
|
287
|
+
private cachedParsers;
|
|
288
|
+
constructor(services: LikeC4Services);
|
|
289
|
+
parse(doc: LangiumDocument): ParsedLikeC4LangiumDocument;
|
|
290
|
+
forDocument(doc: LangiumDocument): DocumentParser;
|
|
291
|
+
}
|
|
292
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { invariant } from "@likec4/core";
|
|
2
|
+
import DefaultWeakMap from "mnemonist/default-weak-map";
|
|
3
|
+
import { pipe } from "remeda";
|
|
4
|
+
import { isFqnIndexedDocument } from "../ast.js";
|
|
5
|
+
import { BaseParser } from "./parser/Base.js";
|
|
6
|
+
import { DeploymentModelParser } from "./parser/DeploymentModelParser.js";
|
|
7
|
+
import { DeploymentViewParser } from "./parser/DeploymentViewParser.js";
|
|
8
|
+
import { ExpressionV2Parser } from "./parser/FqnRefParser.js";
|
|
9
|
+
import { GlobalsParser } from "./parser/GlobalsParser.js";
|
|
10
|
+
import { ModelParser } from "./parser/ModelParser.js";
|
|
11
|
+
import { PredicatesParser } from "./parser/PredicatesParser.js";
|
|
12
|
+
import { SpecificationParser } from "./parser/SpecificationParser.js";
|
|
13
|
+
import { ViewsParser } from "./parser/ViewsParser.js";
|
|
14
|
+
const DocumentParserFromMixins = pipe(
|
|
15
|
+
BaseParser,
|
|
16
|
+
ExpressionV2Parser,
|
|
17
|
+
ModelParser,
|
|
18
|
+
DeploymentModelParser,
|
|
19
|
+
DeploymentViewParser,
|
|
20
|
+
PredicatesParser,
|
|
21
|
+
SpecificationParser,
|
|
22
|
+
ViewsParser,
|
|
23
|
+
GlobalsParser
|
|
24
|
+
);
|
|
25
|
+
export class DocumentParser extends DocumentParserFromMixins {
|
|
26
|
+
}
|
|
27
|
+
export class LikeC4ModelParser {
|
|
28
|
+
constructor(services) {
|
|
29
|
+
this.services = services;
|
|
30
|
+
}
|
|
31
|
+
cachedParsers = new DefaultWeakMap(
|
|
32
|
+
(doc) => new DocumentParser(this.services, doc)
|
|
33
|
+
);
|
|
34
|
+
parse(doc) {
|
|
35
|
+
invariant(isFqnIndexedDocument(doc), `Not a FqnIndexedDocument: ${doc.uri.toString(true)}`);
|
|
36
|
+
try {
|
|
37
|
+
const props = {
|
|
38
|
+
c4Specification: {
|
|
39
|
+
tags: /* @__PURE__ */ new Set(),
|
|
40
|
+
elements: {},
|
|
41
|
+
relationships: {},
|
|
42
|
+
colors: {},
|
|
43
|
+
deployments: {}
|
|
44
|
+
},
|
|
45
|
+
c4Elements: [],
|
|
46
|
+
c4Relations: [],
|
|
47
|
+
c4Deployments: [],
|
|
48
|
+
c4DeploymentRelations: [],
|
|
49
|
+
c4Globals: {
|
|
50
|
+
predicates: {},
|
|
51
|
+
dynamicPredicates: {},
|
|
52
|
+
styles: {}
|
|
53
|
+
},
|
|
54
|
+
c4Views: []
|
|
55
|
+
};
|
|
56
|
+
doc = Object.assign(doc, props);
|
|
57
|
+
const parser = this.cachedParsers.get(doc);
|
|
58
|
+
parser.parseSpecification();
|
|
59
|
+
parser.parseModel();
|
|
60
|
+
parser.parseGlobals();
|
|
61
|
+
parser.parseDeployment();
|
|
62
|
+
parser.parseViews();
|
|
63
|
+
return parser.doc;
|
|
64
|
+
} catch (cause) {
|
|
65
|
+
throw new Error(`Error parsing document ${doc.uri.toString()}`, { cause });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
forDocument(doc) {
|
|
69
|
+
invariant(isFqnIndexedDocument(doc), `Not a FqnIndexedDocument: ${doc.uri.toString(true)}`);
|
|
70
|
+
return this.cachedParsers.get(doc);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type * as c4 from '@likec4/core';
|
|
2
|
+
import type { AstNode } from 'langium';
|
|
3
|
+
import { type ParsedLikeC4LangiumDocument, type ParsedLink, ast } from '../../ast';
|
|
4
|
+
import type { LikeC4Services } from '../../module';
|
|
5
|
+
import { type IsValidFn } from '../../validation';
|
|
6
|
+
export type GConstructor<T = {}> = new (...args: any[]) => T;
|
|
7
|
+
export declare function toSingleLine<T extends string | undefined | null>(str: T): T;
|
|
8
|
+
export declare function removeIndent<T extends string | undefined | null>(str: T): T;
|
|
9
|
+
export type Base = GConstructor<BaseParser>;
|
|
10
|
+
export declare class BaseParser {
|
|
11
|
+
readonly services: LikeC4Services;
|
|
12
|
+
readonly doc: ParsedLikeC4LangiumDocument;
|
|
13
|
+
isValid: IsValidFn;
|
|
14
|
+
constructor(services: LikeC4Services, doc: ParsedLikeC4LangiumDocument);
|
|
15
|
+
resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
|
|
16
|
+
getAstNodePath(node: AstNode): any;
|
|
17
|
+
getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
|
|
18
|
+
[key: string]: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
convertTags<E extends {
|
|
21
|
+
tags?: ast.Tags;
|
|
22
|
+
}>(withTags?: E): any;
|
|
23
|
+
parseTags<E extends {
|
|
24
|
+
tags?: ast.Tags;
|
|
25
|
+
}>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
|
|
26
|
+
convertLinks(source?: ast.LinkProperty['$container']): ParsedLink[] | undefined;
|
|
27
|
+
parseLinks(source?: ast.LinkProperty['$container']): ParsedLink[] | undefined;
|
|
28
|
+
}
|