@likec4/language-server 1.47.0 → 1.48.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/LICENSE +1 -1
- package/browser/package.json +2 -2
- package/browser-worker/package.json +2 -2
- package/bundled/package.json +4 -0
- package/dist/LikeC4LanguageServices.d.mts +4 -0
- package/dist/LikeC4LanguageServices.mjs +3 -0
- package/dist/_chunks/ConfigurableLayouter.mjs +1956 -0
- package/dist/_chunks/LikeC4LanguageServices.d.mts +1978 -0
- package/dist/_chunks/LikeC4LanguageServices.mjs +725 -0
- package/dist/_chunks/ast.d.mts +1444 -0
- package/dist/_chunks/ast.mjs +2375 -0
- package/dist/_chunks/ast2.mjs +176 -0
- package/dist/_chunks/common-exports.mjs +0 -0
- package/dist/_chunks/filesystem.mjs +58 -0
- package/dist/_chunks/grammar.mjs +8 -0
- package/dist/_chunks/icons.mjs +5211 -0
- package/dist/_chunks/libs/@hono/node-server.mjs +436 -0
- package/dist/_chunks/libs/@msgpack/msgpack.mjs +805 -0
- package/dist/_chunks/libs/eventemitter3.mjs +243 -0
- package/dist/_chunks/libs/fast-equals.mjs +446 -0
- package/dist/_chunks/libs/hono.mjs +1829 -0
- package/dist/_chunks/libs/p-queue.mjs +449 -0
- package/dist/_chunks/libs/parse-ms.mjs +36 -0
- package/dist/_chunks/libs/picomatch.mjs +1673 -0
- package/dist/_chunks/libs/pretty-ms.mjs +80 -0
- package/dist/_chunks/libs/remeda.mjs +482 -0
- package/dist/_chunks/libs/strip-indent.mjs +15 -0
- package/dist/_chunks/libs/ufo.mjs +166 -0
- package/dist/_chunks/likec4lib.mjs +9 -0
- package/dist/_chunks/mcp.mjs +33 -0
- package/dist/_chunks/module.mjs +28 -0
- package/dist/_chunks/module2.mjs +6576 -0
- package/dist/_chunks/protocol.d.mts +311 -0
- package/dist/_chunks/protocol.mjs +78 -0
- package/dist/_chunks/rolldown-runtime.mjs +42 -0
- package/dist/ast.d.mts +4 -0
- package/dist/ast.mjs +4 -0
- package/dist/browser-worker.d.mts +1 -0
- package/dist/browser-worker.mjs +6 -0
- package/dist/browser.d.mts +11 -0
- package/dist/browser.mjs +27 -0
- package/dist/bundled.d.mts +28 -0
- package/dist/bundled.mjs +51 -4853
- package/dist/common-exports.d.mts +4 -0
- package/dist/common-exports.mjs +5 -0
- package/dist/filesystem/index.d.mts +4 -0
- package/dist/filesystem/index.mjs +3 -0
- package/dist/generated/ast.d.mts +2 -0
- package/dist/generated/ast.mjs +3 -0
- package/dist/generated/grammar.d.mts +6 -0
- package/dist/generated/grammar.mjs +3 -0
- package/dist/generated/module.d.mts +14 -0
- package/dist/generated/module.mjs +3 -0
- package/dist/generated-lib/icons.d.mts +4 -0
- package/dist/generated-lib/icons.mjs +3 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +48 -0
- package/dist/likec4lib.d.mts +9 -0
- package/dist/likec4lib.mjs +4 -0
- package/dist/mcp/index.d.mts +4 -0
- package/dist/mcp/index.mjs +3 -0
- package/dist/module.d.mts +4 -0
- package/dist/module.mjs +3 -0
- package/dist/protocol.d.mts +2 -0
- package/dist/protocol.mjs +3 -0
- package/likec4lib/package.json +2 -2
- package/package.json +106 -63
- package/protocol/package.json +2 -2
- package/dist/LikeC4LanguageServices.d.ts +0 -115
- package/dist/LikeC4LanguageServices.js +0 -164
- package/dist/Rpc.d.ts +0 -9
- package/dist/Rpc.js +0 -276
- package/dist/ast.d.ts +0 -226
- package/dist/ast.js +0 -264
- package/dist/browser-worker.d.ts +0 -1
- package/dist/browser-worker.js +0 -4
- package/dist/browser.d.ts +0 -10
- package/dist/browser.js +0 -34
- package/dist/bundled.d.ts +0 -8
- package/dist/bundled.js +0 -44
- package/dist/documentation/documentation-provider.d.ts +0 -8
- package/dist/documentation/documentation-provider.js +0 -51
- package/dist/documentation/index.d.ts +0 -1
- package/dist/documentation/index.js +0 -1
- package/dist/empty.d.ts +0 -2
- package/dist/empty.js +0 -2
- package/dist/filesystem/ChokidarWatcher.d.ts +0 -19
- package/dist/filesystem/ChokidarWatcher.js +0 -133
- package/dist/filesystem/FileSystemWatcher.d.ts +0 -19
- package/dist/filesystem/FileSystemWatcher.js +0 -14
- package/dist/filesystem/LikeC4FileSystem.d.ts +0 -3
- package/dist/filesystem/LikeC4FileSystem.js +0 -140
- package/dist/filesystem/index.d.ts +0 -55
- package/dist/filesystem/index.js +0 -29
- package/dist/formatting/LikeC4Formatter.d.ts +0 -59
- package/dist/formatting/LikeC4Formatter.js +0 -637
- package/dist/formatting/utils.d.ts +0 -6
- package/dist/formatting/utils.js +0 -18
- package/dist/generated/ast.d.ts +0 -1411
- package/dist/generated/ast.js +0 -2207
- package/dist/generated/grammar.d.ts +0 -6
- package/dist/generated/grammar.js +0 -7
- package/dist/generated/module.d.ts +0 -14
- package/dist/generated/module.js +0 -27
- package/dist/generated-lib/icons.d.ts +0 -1
- package/dist/generated-lib/icons.js +0 -18
- package/dist/index.d.ts +0 -37
- package/dist/index.js +0 -54
- package/dist/likec4lib.d.ts +0 -6
- package/dist/likec4lib.js +0 -7
- package/dist/logger.d.ts +0 -17
- package/dist/logger.js +0 -81
- package/dist/lsp/CodeActionProvider.d.ts +0 -14
- package/dist/lsp/CodeActionProvider.js +0 -33
- package/dist/lsp/CodeLensProvider.d.ts +0 -9
- package/dist/lsp/CodeLensProvider.js +0 -44
- package/dist/lsp/CompletionProvider.d.ts +0 -13
- package/dist/lsp/CompletionProvider.js +0 -238
- package/dist/lsp/DocumentHighlightProvider.d.ts +0 -9
- package/dist/lsp/DocumentHighlightProvider.js +0 -10
- package/dist/lsp/DocumentLinkProvider.d.ts +0 -11
- package/dist/lsp/DocumentLinkProvider.js +0 -58
- package/dist/lsp/DocumentSymbolProvider.d.ts +0 -33
- package/dist/lsp/DocumentSymbolProvider.js +0 -317
- package/dist/lsp/HoverProvider.d.ts +0 -10
- package/dist/lsp/HoverProvider.js +0 -106
- package/dist/lsp/RenameProvider.d.ts +0 -5
- package/dist/lsp/RenameProvider.js +0 -6
- package/dist/lsp/SemanticTokenProvider.d.ts +0 -19
- package/dist/lsp/SemanticTokenProvider.js +0 -305
- package/dist/lsp/index.d.ts +0 -8
- package/dist/lsp/index.js +0 -9
- package/dist/mcp/MCPServerFactory.d.ts +0 -8
- package/dist/mcp/MCPServerFactory.js +0 -73
- package/dist/mcp/NoopLikeC4MCPServer.d.ts +0 -9
- package/dist/mcp/NoopLikeC4MCPServer.js +0 -17
- package/dist/mcp/interfaces.d.ts +0 -13
- package/dist/mcp/interfaces.js +0 -4
- package/dist/mcp/server/StdioLikeC4MCPServer.d.ts +0 -16
- package/dist/mcp/server/StdioLikeC4MCPServer.js +0 -51
- package/dist/mcp/server/StreamableLikeC4MCPServer.d.ts +0 -16
- package/dist/mcp/server/StreamableLikeC4MCPServer.js +0 -121
- package/dist/mcp/server/WithMCPServer.d.ts +0 -4
- package/dist/mcp/server/WithMCPServer.js +0 -54
- package/dist/mcp/tools/_common.d.ts +0 -88
- package/dist/mcp/tools/_common.js +0 -49
- package/dist/mcp/tools/find-relationships.d.ts +0 -202
- package/dist/mcp/tools/find-relationships.js +0 -150
- package/dist/mcp/tools/list-projects.d.ts +0 -194
- package/dist/mcp/tools/list-projects.js +0 -62
- package/dist/mcp/tools/open-view.d.ts +0 -200
- package/dist/mcp/tools/open-view.js +0 -52
- package/dist/mcp/tools/read-deployment.d.ts +0 -200
- package/dist/mcp/tools/read-deployment.js +0 -150
- package/dist/mcp/tools/read-element.d.ts +0 -200
- package/dist/mcp/tools/read-element.js +0 -218
- package/dist/mcp/tools/read-project-summary.d.ts +0 -198
- package/dist/mcp/tools/read-project-summary.js +0 -176
- package/dist/mcp/tools/read-view.d.ts +0 -200
- package/dist/mcp/tools/read-view.js +0 -203
- package/dist/mcp/tools/search-element.d.ts +0 -198
- package/dist/mcp/tools/search-element.js +0 -177
- package/dist/mcp/utils.d.ts +0 -18
- package/dist/mcp/utils.js +0 -48
- package/dist/model/builder/MergedExtends.d.ts +0 -13
- package/dist/model/builder/MergedExtends.js +0 -74
- package/dist/model/builder/MergedSpecification.d.ts +0 -32
- package/dist/model/builder/MergedSpecification.js +0 -175
- package/dist/model/builder/buildModel.d.ts +0 -16
- package/dist/model/builder/buildModel.js +0 -245
- package/dist/model/deployments-index.d.ts +0 -10
- package/dist/model/deployments-index.js +0 -102
- package/dist/model/fqn-index.d.ts +0 -61
- package/dist/model/fqn-index.js +0 -253
- package/dist/model/index.d.ts +0 -6
- package/dist/model/index.js +0 -6
- package/dist/model/model-builder.d.ts +0 -54
- package/dist/model/model-builder.js +0 -233
- package/dist/model/model-locator.d.ts +0 -39
- package/dist/model/model-locator.js +0 -240
- package/dist/model/model-parser-where.d.ts +0 -4
- package/dist/model/model-parser-where.js +0 -81
- package/dist/model/model-parser.d.ts +0 -645
- package/dist/model/model-parser.js +0 -133
- package/dist/model/parser/Base.d.ts +0 -69
- package/dist/model/parser/Base.js +0 -382
- package/dist/model/parser/DeploymentModelParser.d.ts +0 -71
- package/dist/model/parser/DeploymentModelParser.js +0 -176
- package/dist/model/parser/DeploymentViewParser.d.ts +0 -75
- package/dist/model/parser/DeploymentViewParser.js +0 -86
- package/dist/model/parser/FqnRefParser.d.ts +0 -66
- package/dist/model/parser/FqnRefParser.js +0 -382
- package/dist/model/parser/GlobalsParser.d.ts +0 -109
- package/dist/model/parser/GlobalsParser.js +0 -84
- package/dist/model/parser/ImportsParser.d.ts +0 -46
- package/dist/model/parser/ImportsParser.js +0 -24
- package/dist/model/parser/ModelParser.d.ts +0 -71
- package/dist/model/parser/ModelParser.js +0 -209
- package/dist/model/parser/PredicatesParser.d.ts +0 -75
- package/dist/model/parser/PredicatesParser.js +0 -45
- package/dist/model/parser/SpecificationParser.d.ts +0 -53
- package/dist/model/parser/SpecificationParser.js +0 -113
- package/dist/model/parser/ValueConverter.d.ts +0 -4
- package/dist/model/parser/ValueConverter.js +0 -12
- package/dist/model/parser/ViewsParser.d.ts +0 -112
- package/dist/model/parser/ViewsParser.js +0 -492
- package/dist/model-change/ModelChanges.d.ts +0 -18
- package/dist/model-change/ModelChanges.js +0 -129
- package/dist/model-change/changeElementStyle.d.ts +0 -16
- package/dist/model-change/changeElementStyle.js +0 -134
- package/dist/model-change/changeViewLayout.d.ts +0 -12
- package/dist/model-change/changeViewLayout.js +0 -28
- package/dist/model-change/removeManualLayoutV1.d.ts +0 -7
- package/dist/model-change/removeManualLayoutV1.js +0 -27
- package/dist/module.d.ts +0 -92
- package/dist/module.js +0 -143
- package/dist/protocol.d.ts +0 -289
- package/dist/protocol.js +0 -123
- package/dist/references/index.d.ts +0 -3
- package/dist/references/index.js +0 -3
- package/dist/references/name-provider.d.ts +0 -9
- package/dist/references/name-provider.js +0 -37
- package/dist/references/scope-computation.d.ts +0 -20
- package/dist/references/scope-computation.js +0 -288
- package/dist/references/scope-provider.d.ts +0 -40
- package/dist/references/scope-provider.js +0 -239
- package/dist/shared/NodeKindProvider.d.ts +0 -15
- package/dist/shared/NodeKindProvider.js +0 -57
- package/dist/shared/WorkspaceSymbolProvider.d.ts +0 -3
- package/dist/shared/WorkspaceSymbolProvider.js +0 -3
- package/dist/shared/index.d.ts +0 -2
- package/dist/shared/index.js +0 -2
- package/dist/test/index.d.ts +0 -1
- package/dist/test/index.js +0 -1
- package/dist/test/testServices.d.ts +0 -64
- package/dist/test/testServices.js +0 -210
- package/dist/utils/disposable.d.ts +0 -8
- package/dist/utils/disposable.js +0 -26
- package/dist/utils/elementRef.d.ts +0 -11
- package/dist/utils/elementRef.js +0 -33
- package/dist/utils/fqnRef.d.ts +0 -11
- package/dist/utils/fqnRef.js +0 -63
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.js +0 -35
- package/dist/utils/printDocs.d.ts +0 -2
- package/dist/utils/printDocs.js +0 -1
- package/dist/utils/projectId.d.ts +0 -4
- package/dist/utils/projectId.js +0 -16
- package/dist/utils/stringHash.d.ts +0 -1
- package/dist/utils/stringHash.js +0 -5
- package/dist/validation/DocumentValidator.d.ts +0 -11
- package/dist/validation/DocumentValidator.js +0 -17
- package/dist/validation/_shared.d.ts +0 -3
- package/dist/validation/_shared.js +0 -26
- package/dist/validation/deployment-checks.d.ts +0 -7
- package/dist/validation/deployment-checks.js +0 -140
- package/dist/validation/dynamic-view.d.ts +0 -6
- package/dist/validation/dynamic-view.js +0 -67
- package/dist/validation/element-ref.d.ts +0 -4
- package/dist/validation/element-ref.js +0 -12
- package/dist/validation/element.d.ts +0 -4
- package/dist/validation/element.js +0 -49
- package/dist/validation/imports.d.ts +0 -4
- package/dist/validation/imports.js +0 -46
- package/dist/validation/index.d.ts +0 -15
- package/dist/validation/index.js +0 -167
- package/dist/validation/property-checks.d.ts +0 -7
- package/dist/validation/property-checks.js +0 -108
- package/dist/validation/relation.d.ts +0 -6
- package/dist/validation/relation.js +0 -141
- package/dist/validation/specification.d.ts +0 -12
- package/dist/validation/specification.js +0 -190
- package/dist/validation/view-checks.d.ts +0 -4
- package/dist/validation/view-checks.js +0 -46
- package/dist/validation/view-predicates/fqn-expr-with.d.ts +0 -4
- package/dist/validation/view-predicates/fqn-expr-with.js +0 -43
- package/dist/validation/view-predicates/fqn-ref-expr.d.ts +0 -4
- package/dist/validation/view-predicates/fqn-ref-expr.js +0 -51
- package/dist/validation/view-predicates/incoming.d.ts +0 -4
- package/dist/validation/view-predicates/incoming.js +0 -16
- package/dist/validation/view-predicates/index.d.ts +0 -6
- package/dist/validation/view-predicates/index.js +0 -6
- package/dist/validation/view-predicates/outgoing.d.ts +0 -4
- package/dist/validation/view-predicates/outgoing.js +0 -20
- package/dist/validation/view-predicates/relation-expr.d.ts +0 -4
- package/dist/validation/view-predicates/relation-expr.js +0 -46
- package/dist/validation/view-predicates/relation-with.d.ts +0 -4
- package/dist/validation/view-predicates/relation-with.js +0 -16
- package/dist/validation/view.d.ts +0 -4
- package/dist/validation/view.js +0 -42
- package/dist/view-utils/assignNavigateTo.d.ts +0 -2
- package/dist/view-utils/assignNavigateTo.js +0 -27
- package/dist/view-utils/index.d.ts +0 -2
- package/dist/view-utils/index.js +0 -2
- package/dist/view-utils/manual-layout.d.ts +0 -13
- package/dist/view-utils/manual-layout.js +0 -149
- package/dist/views/ConfigurableLayouter.d.ts +0 -7
- package/dist/views/ConfigurableLayouter.js +0 -51
- package/dist/views/LikeC4ManualLayouts.d.ts +0 -42
- package/dist/views/LikeC4ManualLayouts.js +0 -209
- package/dist/views/LikeC4Views.d.ts +0 -89
- package/dist/views/LikeC4Views.js +0 -216
- package/dist/views/index.d.ts +0 -4
- package/dist/views/index.js +0 -11
- package/dist/workspace/AstNodeDescriptionProvider.d.ts +0 -7
- package/dist/workspace/AstNodeDescriptionProvider.js +0 -18
- package/dist/workspace/IndexManager.d.ts +0 -10
- package/dist/workspace/IndexManager.js +0 -26
- package/dist/workspace/LangiumDocuments.d.ts +0 -29
- package/dist/workspace/LangiumDocuments.js +0 -104
- package/dist/workspace/ProjectsManager.d.ts +0 -134
- package/dist/workspace/ProjectsManager.js +0 -610
- package/dist/workspace/WorkspaceManager.d.ts +0 -31
- package/dist/workspace/WorkspaceManager.js +0 -132
- package/dist/workspace/index.d.ts +0 -5
- package/dist/workspace/index.js +0 -5
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import * as c4 from '@likec4/core';
|
|
2
|
-
import type { Except, Writable } from 'type-fest';
|
|
3
|
-
import { type ParsedAstDynamicView, type ParsedAstElementView, ast } from '../../ast';
|
|
4
|
-
import type { WithDeploymentView } from './DeploymentViewParser';
|
|
5
|
-
import type { WithPredicates } from './PredicatesParser';
|
|
6
|
-
export type WithViewsParser = ReturnType<typeof ViewsParser>;
|
|
7
|
-
type ViewRuleStyleOrGlobalRef = c4.ElementViewRuleStyle | c4.ViewRuleGlobalStyle;
|
|
8
|
-
export declare function ViewsParser<TBase extends WithPredicates & WithDeploymentView>(B: TBase): {
|
|
9
|
-
new (...args: any[]): {
|
|
10
|
-
parseViews(): void;
|
|
11
|
-
parseElementView(astNode: ast.ElementView, additionalStyles: ViewRuleStyleOrGlobalRef[]): ParsedAstElementView;
|
|
12
|
-
parseElementViewRule(astRule: ast.ViewRule): c4.ElementViewRule;
|
|
13
|
-
parseViewRulePredicate(astNode: ast.ViewRulePredicate): c4.ElementViewPredicate;
|
|
14
|
-
parseViewRuleGlobalPredicateRef(astRule: ast.ViewRuleGlobalPredicateRef | ast.DynamicViewGlobalPredicateRef): c4.ViewRuleGlobalPredicateRef;
|
|
15
|
-
parseViewRuleStyleOrGlobalRef(astRule: ast.ViewRuleStyleOrGlobalRef): ViewRuleStyleOrGlobalRef;
|
|
16
|
-
parseViewRuleGroup(astNode: ast.ViewRuleGroup): c4.ElementViewRuleGroup;
|
|
17
|
-
parseViewRuleRank(astRule: ast.ViewRuleRank): c4.ElementViewRuleRank;
|
|
18
|
-
parseViewRuleStyle(astRule: ast.ViewRuleStyle | ast.GlobalStyle): c4.ElementViewRuleStyle;
|
|
19
|
-
parseViewRuleGlobalStyle(astRule: ast.ViewRuleGlobalStyle): c4.ViewRuleGlobalStyle;
|
|
20
|
-
parseDynamicElementView(astNode: ast.DynamicView, additionalStyles: ViewRuleStyleOrGlobalRef[]): ParsedAstDynamicView;
|
|
21
|
-
parseDynamicViewRule(astRule: ast.DynamicViewRule): c4.DynamicViewRule;
|
|
22
|
-
parseDynamicViewIncludePredicate(astRule: ast.DynamicViewIncludePredicate): c4.DynamicViewIncludeRule;
|
|
23
|
-
parseDynamicParallelSteps(node: ast.DynamicViewParallelSteps): c4.DynamicStepsParallel;
|
|
24
|
-
/**
|
|
25
|
-
* @returns non-empty array in case of step chain A -> B -> C
|
|
26
|
-
*/
|
|
27
|
-
parseDynamicStep(node: ast.DynamicViewStep): c4.DynamicStep | c4.DynamicStepsSeries;
|
|
28
|
-
recursiveParseDynamicStepChain(node: ast.DynamicStepChain, callstack?: Array<[source: c4.Fqn, target: c4.Fqn]>): c4.DynamicStep[];
|
|
29
|
-
parseDynamicStepSingle(node: ast.DynamicStepSingle): c4.DynamicStep;
|
|
30
|
-
parseAbstractDynamicStep(astnode: ast.AbstractDynamicStep): Writable<Except<c4.DynamicStep, "source", {
|
|
31
|
-
requireExactProps: true;
|
|
32
|
-
}>>;
|
|
33
|
-
parsePredicate(astNode: ast.ExpressionV2): c4.ModelExpression;
|
|
34
|
-
parseElementPredicate(astNode: ast.FqnExprOrWith): c4.ModelFqnExpr.Any;
|
|
35
|
-
parseElementPredicateOrWhere(astNode: ast.FqnExprOrWhere): c4.ModelFqnExpr.OrWhere;
|
|
36
|
-
parseElementExpression(astNode: ast.FqnExpr): c4.ModelFqnExpr;
|
|
37
|
-
parseElementPredicateWhere(astNode: ast.FqnExprWhere): c4.ModelFqnExpr.Where;
|
|
38
|
-
parseElementPredicateWith(astNode: ast.FqnExprWith): c4.ModelFqnExpr.Custom;
|
|
39
|
-
parseRelationPredicate(astNode: ast.RelationExprOrWith): c4.ModelRelationExpr.Any;
|
|
40
|
-
parseRelationPredicateOrWhere(astNode: ast.RelationExprOrWhere): c4.ModelRelationExpr.OrWhere;
|
|
41
|
-
parseRelationPredicateWhere(astNode: ast.RelationExprWhere): c4.ModelRelationExpr.Where;
|
|
42
|
-
parseRelationPredicateWith(astNode: ast.RelationExprWith): c4.ModelRelationExpr.Custom;
|
|
43
|
-
parseRelationExpression(astNode: ast.RelationExpr): c4.ModelRelationExpr;
|
|
44
|
-
parseFqnRef(astNode: ast.FqnRef): c4.FqnRef;
|
|
45
|
-
parseExpressionV2(astNode: ast.ExpressionV2): c4.Expression;
|
|
46
|
-
parseFqnExprOrWith(astNode: ast.FqnExprOrWith): c4.FqnExpr.Any;
|
|
47
|
-
parseFqnExprWith(astNode: ast.FqnExprWith): c4.FqnExpr.Custom;
|
|
48
|
-
parseFqnExprOrWhere(astNode: ast.FqnExprOrWhere): c4.FqnExpr.OrWhere;
|
|
49
|
-
parseFqnExprWhere(astNode: ast.FqnExprWhere): c4.FqnExpr.Where;
|
|
50
|
-
parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
|
|
51
|
-
parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
|
|
52
|
-
parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
|
|
53
|
-
parseRelationExprOrWith(astNode: ast.RelationExprOrWith): c4.RelationExpr.Any;
|
|
54
|
-
parseRelationExprWith(astNode: ast.RelationExprWith): c4.RelationExpr.Custom;
|
|
55
|
-
parseCustomRelationProperties(custom: ast.CustomRelationProperties | undefined): Except<c4.RelationExpr.Custom["customRelation"], "expr">;
|
|
56
|
-
parseRelationExprOrWhere(astNode: ast.RelationExprOrWhere): c4.RelationExpr.OrWhere;
|
|
57
|
-
parseRelationExprWhere(astNode: ast.RelationExprWhere): c4.RelationExpr.Where;
|
|
58
|
-
parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr.OrWhere;
|
|
59
|
-
parseInlineKindCondition(astNode: ast.OutgoingRelationExpr): c4.WhereOperator | null;
|
|
60
|
-
wrapInWhere(expr: c4.RelationExpr, condition: c4.WhereOperator | null): c4.RelationExpr.OrWhere;
|
|
61
|
-
isValid: import("../../validation").IsValidFn;
|
|
62
|
-
readonly services: import("../..").LikeC4Services;
|
|
63
|
-
readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
|
|
64
|
-
get project(): import("../../workspace").Project;
|
|
65
|
-
resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
|
|
66
|
-
getAstNodePath(node: import("langium").AstNode): string;
|
|
67
|
-
getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
|
|
68
|
-
[key: string]: string | string[];
|
|
69
|
-
} | undefined;
|
|
70
|
-
parseMarkdownOrString(markdownOrString: ast.MarkdownOrString | undefined): c4.MarkdownOrString | undefined;
|
|
71
|
-
convertTags<E extends {
|
|
72
|
-
tags?: ast.Tags;
|
|
73
|
-
}>(withTags?: E | undefined): c4.NonEmptyArray<c4.Tag<string>> | null;
|
|
74
|
-
parseTags<E extends {
|
|
75
|
-
tags?: ast.Tags;
|
|
76
|
-
}>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
|
|
77
|
-
convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
|
|
78
|
-
parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
|
|
79
|
-
parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
|
|
80
|
-
parseImageAlias(value: string): string | undefined;
|
|
81
|
-
parseColorLiteral(astNode: ast.ColorLiteral): c4.ColorLiteral | undefined;
|
|
82
|
-
parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
|
|
83
|
-
parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
|
|
84
|
-
parseBaseProps(props: {
|
|
85
|
-
title?: ast.MarkdownOrString | undefined;
|
|
86
|
-
summary?: ast.MarkdownOrString | undefined;
|
|
87
|
-
description?: ast.MarkdownOrString | undefined;
|
|
88
|
-
technology?: ast.MarkdownOrString | undefined;
|
|
89
|
-
}, override?: {
|
|
90
|
-
title?: string | undefined;
|
|
91
|
-
summary?: string | undefined;
|
|
92
|
-
description?: string | undefined;
|
|
93
|
-
technology?: string | undefined;
|
|
94
|
-
}): {
|
|
95
|
-
title?: string;
|
|
96
|
-
summary?: c4.MarkdownOrString;
|
|
97
|
-
description?: c4.MarkdownOrString;
|
|
98
|
-
technology?: string;
|
|
99
|
-
};
|
|
100
|
-
parseDeploymentView(astNode: ast.DeploymentView): import("../../ast").ParsedAstDeploymentView;
|
|
101
|
-
parseDeploymentViewRule(astRule: ast.DeploymentViewRule): c4.DeploymentViewRule;
|
|
102
|
-
parseDeploymentViewRulePredicate(astRule: ast.DeploymentViewRulePredicate): c4.DeploymentViewPredicate;
|
|
103
|
-
parseDeploymentViewRuleStyle(astRule: ast.DeploymentViewRuleStyle): c4.DeploymentViewRuleStyle;
|
|
104
|
-
parseDeployment(): void;
|
|
105
|
-
parseDeploymentNode(astNode: ast.DeploymentNode): import("../../ast").ParsedAstDeployment.Node;
|
|
106
|
-
parseDeployedInstance(astNode: ast.DeployedInstance): import("../../ast").ParsedAstDeployment.Instance;
|
|
107
|
-
parseExtendDeployment(astNode: ast.ExtendDeployment): import("../../ast").ParsedAstExtend | null;
|
|
108
|
-
_resolveDeploymentRelationSource(node: ast.DeploymentRelation): c4.FqnRef;
|
|
109
|
-
parseDeploymentRelation(astNode: ast.DeploymentRelation): import("../../ast").ParsedAstDeploymentRelation;
|
|
110
|
-
};
|
|
111
|
-
} & TBase;
|
|
112
|
-
export {};
|
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
import * as c4 from '@likec4/core';
|
|
2
|
-
import { invariant, isNonEmptyArray, nonexhaustive } from '@likec4/core';
|
|
3
|
-
import { loggable } from '@likec4/log';
|
|
4
|
-
import { filter, find, isDefined, isEmpty, isNonNullish, isNumber, isTruthy, last, mapToObj, pipe } from 'remeda';
|
|
5
|
-
import { ast, parseMarkdownAsString, toAutoLayout, toColor, ViewOps, } from '../../ast';
|
|
6
|
-
import { logger as mainLogger } from '../../logger';
|
|
7
|
-
import { safeCall, stringHash } from '../../utils';
|
|
8
|
-
import { elementRef } from '../../utils/elementRef';
|
|
9
|
-
import { parseViewManualLayout } from '../../view-utils/manual-layout';
|
|
10
|
-
import { removeIndent, toSingleLine } from './Base';
|
|
11
|
-
const logger = mainLogger.getChild('ViewsParser');
|
|
12
|
-
const rankLogger = logger.getChild('rank');
|
|
13
|
-
export function ViewsParser(B) {
|
|
14
|
-
return class ViewsParser extends B {
|
|
15
|
-
parseViews() {
|
|
16
|
-
const isValid = this.isValid;
|
|
17
|
-
for (const viewBlock of this.doc.parseResult.value.views) {
|
|
18
|
-
const localStyles = viewBlock.styles.flatMap(s => {
|
|
19
|
-
try {
|
|
20
|
-
return isValid(s) ? this.parseViewRuleStyleOrGlobalRef(s) : [];
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
logger.warn(loggable(e));
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
// Common folder for all views in the block
|
|
28
|
-
const folder = viewBlock.folder && !isEmpty(viewBlock.folder.trim()) ? toSingleLine(viewBlock.folder) : null;
|
|
29
|
-
for (const view of viewBlock.views) {
|
|
30
|
-
try {
|
|
31
|
-
if (!isValid(view)) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
switch (true) {
|
|
35
|
-
case ast.isElementView(view):
|
|
36
|
-
this.doc.c4Views.push(this.parseElementView(view, localStyles));
|
|
37
|
-
break;
|
|
38
|
-
case ast.isDynamicView(view):
|
|
39
|
-
this.doc.c4Views.push(this.parseDynamicElementView(view, localStyles));
|
|
40
|
-
break;
|
|
41
|
-
case ast.isDeploymentView(view):
|
|
42
|
-
this.doc.c4Views.push(this.parseDeploymentView(view));
|
|
43
|
-
break;
|
|
44
|
-
default:
|
|
45
|
-
nonexhaustive(view);
|
|
46
|
-
}
|
|
47
|
-
if (folder) {
|
|
48
|
-
const view = this.doc.c4Views.at(-1);
|
|
49
|
-
view.title = folder + ' / ' + (view.title || view.id);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
logger.warn(loggable(e));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
parseElementView(astNode, additionalStyles) {
|
|
59
|
-
const body = astNode.body;
|
|
60
|
-
invariant(body, 'ElementView body is not defined');
|
|
61
|
-
const astPath = this.getAstNodePath(astNode);
|
|
62
|
-
let viewOf = null;
|
|
63
|
-
if ('viewOf' in astNode) {
|
|
64
|
-
const viewOfEl = elementRef(astNode.viewOf);
|
|
65
|
-
const _viewOf = viewOfEl && safeCall(() => this.resolveFqn(viewOfEl));
|
|
66
|
-
if (!_viewOf) {
|
|
67
|
-
const viewId = astNode.name ?? 'unnamed';
|
|
68
|
-
const msg = astNode.viewOf.$cstNode?.text ?? '<unknown>';
|
|
69
|
-
logger.warn(`viewOf {viewId} not resolved {msg}`, { msg, viewId });
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
viewOf = _viewOf;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
let id = astNode.name;
|
|
76
|
-
if (!id) {
|
|
77
|
-
id = 'view_' + stringHash(this.doc.uri.toString(), astPath, viewOf ?? '');
|
|
78
|
-
}
|
|
79
|
-
const { title = null, description = null } = this.parseBaseProps(pipe(body.props, filter(p => this.isValid(p)), filter(ast.isViewStringProperty), mapToObj(p => [p.key, p.value])));
|
|
80
|
-
const tags = this.convertTags(body);
|
|
81
|
-
const links = this.convertLinks(body);
|
|
82
|
-
const manualLayout = parseViewManualLayout(astNode);
|
|
83
|
-
const view = {
|
|
84
|
-
[c4._type]: 'element',
|
|
85
|
-
id: id,
|
|
86
|
-
astPath,
|
|
87
|
-
title: toSingleLine(title) ?? null,
|
|
88
|
-
description,
|
|
89
|
-
tags,
|
|
90
|
-
links: isNonEmptyArray(links) ? links : null,
|
|
91
|
-
rules: [
|
|
92
|
-
...additionalStyles,
|
|
93
|
-
...body.rules.flatMap(n => {
|
|
94
|
-
try {
|
|
95
|
-
return this.isValid(n) ? this.parseElementViewRule(n) : [];
|
|
96
|
-
}
|
|
97
|
-
catch (e) {
|
|
98
|
-
logger.warn(loggable(e));
|
|
99
|
-
return [];
|
|
100
|
-
}
|
|
101
|
-
}),
|
|
102
|
-
],
|
|
103
|
-
...(viewOf && { viewOf }),
|
|
104
|
-
...(manualLayout && { manualLayout }),
|
|
105
|
-
};
|
|
106
|
-
ViewOps.writeId(astNode, view.id);
|
|
107
|
-
if ('extends' in astNode) {
|
|
108
|
-
const extendsView = astNode.extends.view.ref;
|
|
109
|
-
invariant(extendsView?.name, 'view extends is not resolved: ' + astNode.$cstNode?.text);
|
|
110
|
-
return Object.assign(view, {
|
|
111
|
-
extends: extendsView.name,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
return view;
|
|
115
|
-
}
|
|
116
|
-
parseElementViewRule(astRule) {
|
|
117
|
-
if (ast.isViewRulePredicate(astRule)) {
|
|
118
|
-
return this.parseViewRulePredicate(astRule);
|
|
119
|
-
}
|
|
120
|
-
if (ast.isViewRuleGlobalPredicateRef(astRule)) {
|
|
121
|
-
return this.parseViewRuleGlobalPredicateRef(astRule);
|
|
122
|
-
}
|
|
123
|
-
if (ast.isViewRuleStyleOrGlobalRef(astRule)) {
|
|
124
|
-
return this.parseViewRuleStyleOrGlobalRef(astRule);
|
|
125
|
-
}
|
|
126
|
-
if (ast.isViewRuleAutoLayout(astRule)) {
|
|
127
|
-
return toAutoLayout(astRule);
|
|
128
|
-
}
|
|
129
|
-
if (ast.isViewRuleGroup(astRule)) {
|
|
130
|
-
return this.parseViewRuleGroup(astRule);
|
|
131
|
-
}
|
|
132
|
-
if (ast.isViewRuleRank(astRule)) {
|
|
133
|
-
return this.parseViewRuleRank(astRule);
|
|
134
|
-
}
|
|
135
|
-
nonexhaustive(astRule);
|
|
136
|
-
}
|
|
137
|
-
parseViewRulePredicate(astNode) {
|
|
138
|
-
const exprs = [];
|
|
139
|
-
let predicate = astNode.exprs;
|
|
140
|
-
while (predicate) {
|
|
141
|
-
const { value, prev } = predicate;
|
|
142
|
-
try {
|
|
143
|
-
if (isTruthy(value) && this.isValid(value)) {
|
|
144
|
-
const expr = this.parsePredicate(value);
|
|
145
|
-
exprs.unshift(expr);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
catch (e) {
|
|
149
|
-
logger.warn(loggable(e));
|
|
150
|
-
}
|
|
151
|
-
if (!prev) {
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
predicate = prev;
|
|
155
|
-
}
|
|
156
|
-
return astNode.isInclude ? { include: exprs } : { exclude: exprs };
|
|
157
|
-
}
|
|
158
|
-
parseViewRuleGlobalPredicateRef(astRule) {
|
|
159
|
-
return {
|
|
160
|
-
predicateId: astRule.predicate.$refText,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
parseViewRuleStyleOrGlobalRef(astRule) {
|
|
164
|
-
if (ast.isViewRuleStyle(astRule)) {
|
|
165
|
-
return this.parseViewRuleStyle(astRule);
|
|
166
|
-
}
|
|
167
|
-
if (ast.isViewRuleGlobalStyle(astRule)) {
|
|
168
|
-
return this.parseViewRuleGlobalStyle(astRule);
|
|
169
|
-
}
|
|
170
|
-
nonexhaustive(astRule);
|
|
171
|
-
}
|
|
172
|
-
parseViewRuleGroup(astNode) {
|
|
173
|
-
const groupRules = [];
|
|
174
|
-
for (const rule of astNode.groupRules) {
|
|
175
|
-
try {
|
|
176
|
-
if (!this.isValid(rule)) {
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
if (ast.isViewRulePredicate(rule)) {
|
|
180
|
-
groupRules.push(this.parseViewRulePredicate(rule));
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
if (ast.isViewRuleGroup(rule)) {
|
|
184
|
-
groupRules.push(this.parseViewRuleGroup(rule));
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
nonexhaustive(rule);
|
|
188
|
-
}
|
|
189
|
-
catch (e) {
|
|
190
|
-
logger.warn(loggable(e));
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
title: toSingleLine(astNode.title) ?? null,
|
|
195
|
-
groupRules,
|
|
196
|
-
...this.parseStyleProps(astNode.props),
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
parseViewRuleRank(astRule) {
|
|
200
|
-
const targets = this.parseFqnExpressions(astRule.targets).filter((e) => c4.ModelExpression.isFqnExpr(e));
|
|
201
|
-
const rank = astRule.value ?? 'same';
|
|
202
|
-
rankLogger.debug `Parsed rank constraint ${rank} with ${targets.length} target(s)`;
|
|
203
|
-
return {
|
|
204
|
-
rank,
|
|
205
|
-
targets,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
parseViewRuleStyle(astRule) {
|
|
209
|
-
const targets = this.parseFqnExpressions(astRule.targets).filter((e) => c4.ModelExpression.isFqnExpr(e));
|
|
210
|
-
const style = this.parseStyleProps(astRule.props.filter(ast.isStyleProperty));
|
|
211
|
-
const notation = removeIndent(parseMarkdownAsString(astRule.props.find(ast.isNotationProperty)?.value));
|
|
212
|
-
return {
|
|
213
|
-
targets,
|
|
214
|
-
style,
|
|
215
|
-
...(notation && { notation }),
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
parseViewRuleGlobalStyle(astRule) {
|
|
219
|
-
return {
|
|
220
|
-
styleId: astRule.style.$refText,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
parseDynamicElementView(astNode, additionalStyles) {
|
|
224
|
-
const body = astNode.body;
|
|
225
|
-
invariant(body, 'DynamicElementView body is not defined');
|
|
226
|
-
// only valid props
|
|
227
|
-
const isValid = this.isValid;
|
|
228
|
-
const props = body.props.filter(isValid);
|
|
229
|
-
const astPath = this.getAstNodePath(astNode);
|
|
230
|
-
let id = astNode.name;
|
|
231
|
-
if (!id) {
|
|
232
|
-
id = 'dynamic_' + stringHash(this.doc.uri.toString(), astPath);
|
|
233
|
-
}
|
|
234
|
-
const { title = null, description = null } = this.parseBaseProps(pipe(props, filter(ast.isViewStringProperty), mapToObj(p => [p.key, p.value])));
|
|
235
|
-
const tags = this.convertTags(body);
|
|
236
|
-
const links = this.convertLinks(body);
|
|
237
|
-
ViewOps.writeId(astNode, id);
|
|
238
|
-
const manualLayout = parseViewManualLayout(astNode);
|
|
239
|
-
const variant = find(props, ast.isDynamicViewDisplayVariantProperty)?.value;
|
|
240
|
-
return {
|
|
241
|
-
[c4._type]: 'dynamic',
|
|
242
|
-
id: id,
|
|
243
|
-
astPath,
|
|
244
|
-
title: toSingleLine(title) ?? null,
|
|
245
|
-
description,
|
|
246
|
-
tags,
|
|
247
|
-
links: isNonEmptyArray(links) ? links : null,
|
|
248
|
-
variant,
|
|
249
|
-
rules: [
|
|
250
|
-
...additionalStyles,
|
|
251
|
-
...body.rules.flatMap(n => {
|
|
252
|
-
try {
|
|
253
|
-
return isValid(n) ? this.parseDynamicViewRule(n) : [];
|
|
254
|
-
}
|
|
255
|
-
catch (e) {
|
|
256
|
-
logger.warn(loggable(e));
|
|
257
|
-
return [];
|
|
258
|
-
}
|
|
259
|
-
}, []),
|
|
260
|
-
],
|
|
261
|
-
steps: body.steps.reduce((acc, n) => {
|
|
262
|
-
try {
|
|
263
|
-
if (isValid(n)) {
|
|
264
|
-
if (ast.isDynamicViewParallelSteps(n)) {
|
|
265
|
-
acc.push(this.parseDynamicParallelSteps(n));
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
acc.push(this.parseDynamicStep(n));
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
catch (e) {
|
|
273
|
-
logger.warn(loggable(e));
|
|
274
|
-
}
|
|
275
|
-
return acc;
|
|
276
|
-
}, []),
|
|
277
|
-
...(manualLayout && { manualLayout }),
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
parseDynamicViewRule(astRule) {
|
|
281
|
-
if (ast.isDynamicViewIncludePredicate(astRule)) {
|
|
282
|
-
return this.parseDynamicViewIncludePredicate(astRule);
|
|
283
|
-
}
|
|
284
|
-
if (ast.isDynamicViewGlobalPredicateRef(astRule)) {
|
|
285
|
-
return this.parseViewRuleGlobalPredicateRef(astRule);
|
|
286
|
-
}
|
|
287
|
-
if (ast.isViewRuleStyleOrGlobalRef(astRule)) {
|
|
288
|
-
return this.parseViewRuleStyleOrGlobalRef(astRule);
|
|
289
|
-
}
|
|
290
|
-
if (ast.isViewRuleAutoLayout(astRule)) {
|
|
291
|
-
return toAutoLayout(astRule);
|
|
292
|
-
}
|
|
293
|
-
nonexhaustive(astRule);
|
|
294
|
-
}
|
|
295
|
-
parseDynamicViewIncludePredicate(astRule) {
|
|
296
|
-
const include = [];
|
|
297
|
-
let iter = astRule.exprs;
|
|
298
|
-
while (iter) {
|
|
299
|
-
try {
|
|
300
|
-
if (isNonNullish(iter.value) && this.isValid(iter.value)) {
|
|
301
|
-
if (ast.isFqnExprOrWith(iter.value)) {
|
|
302
|
-
const c4expr = this.parseElementPredicate(iter.value);
|
|
303
|
-
include.unshift(c4expr);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
catch (e) {
|
|
308
|
-
logger.warn(loggable(e));
|
|
309
|
-
}
|
|
310
|
-
iter = iter.prev;
|
|
311
|
-
}
|
|
312
|
-
return { include };
|
|
313
|
-
}
|
|
314
|
-
parseDynamicParallelSteps(node) {
|
|
315
|
-
const parallelId = pathInsideDynamicView(node);
|
|
316
|
-
const __parallel = node.steps.map(step => this.parseDynamicStep(step));
|
|
317
|
-
invariant(isNonEmptyArray(__parallel), 'Dynamic parallel steps must have at least one step');
|
|
318
|
-
return {
|
|
319
|
-
parallelId,
|
|
320
|
-
__parallel,
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* @returns non-empty array in case of step chain A -> B -> C
|
|
325
|
-
*/
|
|
326
|
-
parseDynamicStep(node) {
|
|
327
|
-
if (ast.isDynamicStepSingle(node)) {
|
|
328
|
-
invariant(this.isValid(node));
|
|
329
|
-
return this.parseDynamicStepSingle(node);
|
|
330
|
-
}
|
|
331
|
-
const __series = this.recursiveParseDynamicStepChain(node);
|
|
332
|
-
invariant(isNonEmptyArray(__series), 'Dynamic step chain must have at least one step');
|
|
333
|
-
return {
|
|
334
|
-
seriesId: pathInsideDynamicView(node),
|
|
335
|
-
__series,
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
recursiveParseDynamicStepChain(node, callstack) {
|
|
339
|
-
if (ast.isDynamicStepSingle(node.source)) {
|
|
340
|
-
if (!this.isValid(node.source)) {
|
|
341
|
-
return [];
|
|
342
|
-
}
|
|
343
|
-
const previous = this.parseDynamicStepSingle(node.source);
|
|
344
|
-
// Head of the chain cannot be backward
|
|
345
|
-
if (previous.isBackward) {
|
|
346
|
-
return [];
|
|
347
|
-
}
|
|
348
|
-
const thisStep = {
|
|
349
|
-
...this.parseAbstractDynamicStep(node),
|
|
350
|
-
source: previous.target,
|
|
351
|
-
};
|
|
352
|
-
// if target is the same as source of previous step, then it is a backward step
|
|
353
|
-
// A -> B -> A
|
|
354
|
-
if (thisStep.target === previous.source) {
|
|
355
|
-
thisStep.isBackward = true;
|
|
356
|
-
}
|
|
357
|
-
else if (callstack) {
|
|
358
|
-
callstack.push([previous.source, previous.target]);
|
|
359
|
-
callstack.push([thisStep.source, thisStep.target]);
|
|
360
|
-
}
|
|
361
|
-
return [previous, thisStep];
|
|
362
|
-
}
|
|
363
|
-
callstack ??= [];
|
|
364
|
-
const allprevious = this.recursiveParseDynamicStepChain(node.source, callstack);
|
|
365
|
-
if (!isNonEmptyArray(allprevious) || !this.isValid(node)) {
|
|
366
|
-
return [];
|
|
367
|
-
}
|
|
368
|
-
const previous = last(allprevious);
|
|
369
|
-
const thisStep = {
|
|
370
|
-
...this.parseAbstractDynamicStep(node),
|
|
371
|
-
source: previous.target,
|
|
372
|
-
};
|
|
373
|
-
const index = callstack.findIndex(([source, target]) => source === thisStep.target && target === thisStep.source);
|
|
374
|
-
if (index !== -1) {
|
|
375
|
-
thisStep.isBackward = true;
|
|
376
|
-
callstack.splice(index, callstack.length - index);
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
callstack.push([thisStep.source, thisStep.target]);
|
|
380
|
-
}
|
|
381
|
-
return [...allprevious, thisStep];
|
|
382
|
-
}
|
|
383
|
-
parseDynamicStepSingle(node) {
|
|
384
|
-
const sourceEl = elementRef(node.source);
|
|
385
|
-
if (!sourceEl) {
|
|
386
|
-
throw new Error('Invalid reference to source');
|
|
387
|
-
}
|
|
388
|
-
let baseStep = {
|
|
389
|
-
...this.parseAbstractDynamicStep(node),
|
|
390
|
-
source: this.resolveFqn(sourceEl),
|
|
391
|
-
};
|
|
392
|
-
if (node.isBackward) {
|
|
393
|
-
baseStep = {
|
|
394
|
-
...baseStep,
|
|
395
|
-
source: baseStep.target,
|
|
396
|
-
target: baseStep.source,
|
|
397
|
-
isBackward: true,
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
return baseStep;
|
|
401
|
-
}
|
|
402
|
-
parseAbstractDynamicStep(astnode) {
|
|
403
|
-
const targetEl = elementRef(astnode.target);
|
|
404
|
-
if (!targetEl) {
|
|
405
|
-
throw new Error('Invalid reference to target');
|
|
406
|
-
}
|
|
407
|
-
const step = {
|
|
408
|
-
target: this.resolveFqn(targetEl),
|
|
409
|
-
astPath: pathInsideDynamicView(astnode),
|
|
410
|
-
};
|
|
411
|
-
const title = removeIndent(astnode.title);
|
|
412
|
-
if (title) {
|
|
413
|
-
step.title = title;
|
|
414
|
-
}
|
|
415
|
-
const kind = astnode.kind?.ref?.name ?? astnode.dotKind?.kind.ref?.name;
|
|
416
|
-
if (kind) {
|
|
417
|
-
step.kind = kind;
|
|
418
|
-
}
|
|
419
|
-
for (const prop of astnode.custom?.props ?? []) {
|
|
420
|
-
try {
|
|
421
|
-
switch (true) {
|
|
422
|
-
case ast.isRelationNavigateToProperty(prop): {
|
|
423
|
-
const viewId = prop.value.view.ref?.name;
|
|
424
|
-
if (isTruthy(viewId)) {
|
|
425
|
-
step.navigateTo = viewId;
|
|
426
|
-
}
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
case ast.isRelationStringProperty(prop):
|
|
430
|
-
case ast.isNotationProperty(prop): {
|
|
431
|
-
if (isDefined(prop.value)) {
|
|
432
|
-
if (prop.key === 'description') {
|
|
433
|
-
const value = removeIndent(prop.value);
|
|
434
|
-
if (value) {
|
|
435
|
-
step.description = value;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
else {
|
|
439
|
-
step[prop.key] = removeIndent(parseMarkdownAsString(prop.value)) ?? '';
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
break;
|
|
443
|
-
}
|
|
444
|
-
case ast.isNotesProperty(prop): {
|
|
445
|
-
if (isDefined(prop.value)) {
|
|
446
|
-
step[prop.key] = removeIndent(prop.value);
|
|
447
|
-
}
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
case ast.isArrowProperty(prop): {
|
|
451
|
-
if (isDefined(prop.value)) {
|
|
452
|
-
step[prop.key] = prop.value;
|
|
453
|
-
}
|
|
454
|
-
break;
|
|
455
|
-
}
|
|
456
|
-
case ast.isColorProperty(prop): {
|
|
457
|
-
const value = toColor(prop);
|
|
458
|
-
if (isDefined(value)) {
|
|
459
|
-
step[prop.key] = value;
|
|
460
|
-
}
|
|
461
|
-
break;
|
|
462
|
-
}
|
|
463
|
-
case ast.isLineProperty(prop): {
|
|
464
|
-
if (isDefined(prop.value)) {
|
|
465
|
-
step[prop.key] = prop.value;
|
|
466
|
-
}
|
|
467
|
-
break;
|
|
468
|
-
}
|
|
469
|
-
default:
|
|
470
|
-
nonexhaustive(prop);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
catch (e) {
|
|
474
|
-
logger.warn(loggable(e));
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
return step;
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
function pathInsideDynamicView(_node) {
|
|
482
|
-
let node = _node;
|
|
483
|
-
let path = [];
|
|
484
|
-
while (!ast.isDynamicViewBody(node)) {
|
|
485
|
-
if (isNumber(node.$containerIndex)) {
|
|
486
|
-
path.unshift(`@${node.$containerIndex}`);
|
|
487
|
-
}
|
|
488
|
-
path.unshift(`/${node.$containerProperty ?? '__invalid__'}`);
|
|
489
|
-
node = node.$container;
|
|
490
|
-
}
|
|
491
|
-
return path.join('');
|
|
492
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type ViewChange } from '@likec4/core';
|
|
2
|
-
import { Range, TextEdit } from 'vscode-languageserver-types';
|
|
3
|
-
import type { ViewLocateResult } from '../model';
|
|
4
|
-
import type { LikeC4Services } from '../module';
|
|
5
|
-
import type { ChangeView } from '../protocol';
|
|
6
|
-
export declare class LikeC4ModelChanges {
|
|
7
|
-
private services;
|
|
8
|
-
private locator;
|
|
9
|
-
constructor(services: LikeC4Services);
|
|
10
|
-
applyChange(changeView: ChangeView.Params): Promise<ChangeView.Res>;
|
|
11
|
-
protected convertToTextEdit({ lookup, change }: {
|
|
12
|
-
lookup: ViewLocateResult;
|
|
13
|
-
change: Exclude<ViewChange, ViewChange.SaveViewSnapshot | ViewChange.ResetManualLayout>;
|
|
14
|
-
}): {
|
|
15
|
-
modifiedRange: Range;
|
|
16
|
-
edits: TextEdit[];
|
|
17
|
-
};
|
|
18
|
-
}
|