@likec4/language-server 1.42.1 → 1.44.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/browser/package.json +1 -1
- package/browser-worker/package.json +1 -1
- package/dist/LikeC4LanguageServices.d.ts +12 -19
- package/dist/LikeC4LanguageServices.js +182 -0
- package/dist/Rpc.js +245 -0
- package/dist/ast.d.ts +10 -6
- package/dist/ast.js +253 -0
- package/dist/browser-worker.js +4 -0
- package/dist/browser.js +35 -0
- package/dist/bundled.js +42 -0
- package/dist/bundled.mjs +3830 -4172
- package/dist/documentation/documentation-provider.js +51 -0
- package/dist/documentation/index.js +1 -0
- package/dist/empty.js +2 -0
- package/dist/filesystem/ChokidarWatcher.js +97 -0
- package/dist/filesystem/FileSystemWatcher.js +14 -0
- package/dist/filesystem/LikeC4FileSystem.d.ts +1 -2
- package/dist/filesystem/LikeC4FileSystem.js +126 -0
- package/dist/filesystem/index.d.ts +26 -0
- package/dist/filesystem/index.js +29 -0
- package/dist/formatting/LikeC4Formatter.js +637 -0
- package/dist/formatting/utils.js +18 -0
- package/dist/generated/ast.d.ts +19 -3
- package/dist/generated/ast.js +2155 -0
- package/dist/generated/grammar.js +7 -0
- package/dist/generated/module.d.ts +6 -1
- package/dist/generated/module.js +27 -0
- package/dist/generated-lib/{icons.mjs → icons.js} +11 -7
- package/dist/index.d.ts +7 -0
- package/dist/index.js +53 -0
- package/dist/{likec4lib.mjs → likec4lib.js} +3 -3
- package/dist/logger.js +81 -0
- package/dist/lsp/CodeActionProvider.d.ts +14 -0
- package/dist/lsp/CodeActionProvider.js +33 -0
- package/dist/lsp/CodeLensProvider.js +44 -0
- package/dist/lsp/CompletionProvider.d.ts +3 -1
- package/dist/lsp/CompletionProvider.js +200 -0
- package/dist/lsp/DocumentHighlightProvider.js +10 -0
- package/dist/lsp/DocumentLinkProvider.js +58 -0
- package/dist/lsp/DocumentSymbolProvider.js +306 -0
- package/dist/lsp/HoverProvider.js +106 -0
- package/dist/lsp/RenameProvider.js +6 -0
- package/dist/lsp/SemanticTokenProvider.d.ts +5 -0
- package/dist/lsp/SemanticTokenProvider.js +257 -0
- package/dist/lsp/index.d.ts +1 -0
- package/dist/lsp/index.js +9 -0
- package/dist/mcp/MCPServerFactory.js +73 -0
- package/dist/mcp/NoopLikeC4MCPServer.js +17 -0
- package/dist/mcp/interfaces.js +5 -0
- package/dist/mcp/server/StdioLikeC4MCPServer.js +47 -0
- package/dist/mcp/server/StreamableLikeC4MCPServer.js +145 -0
- package/dist/mcp/server/WithMCPServer.js +56 -0
- package/dist/mcp/tools/_common.d.ts +8 -7
- package/dist/mcp/tools/_common.js +49 -0
- package/dist/mcp/tools/find-relationships.d.ts +7 -8
- package/dist/mcp/tools/find-relationships.js +150 -0
- package/dist/mcp/tools/list-projects.d.ts +3 -3
- package/dist/mcp/tools/list-projects.js +62 -0
- package/dist/mcp/tools/open-view.d.ts +6 -7
- package/dist/mcp/tools/open-view.js +52 -0
- package/dist/mcp/tools/read-deployment.d.ts +6 -7
- package/dist/mcp/tools/read-deployment.js +132 -0
- package/dist/mcp/tools/read-element.d.ts +6 -7
- package/dist/mcp/tools/read-element.js +194 -0
- package/dist/mcp/tools/read-project-summary.d.ts +5 -6
- package/dist/mcp/tools/read-project-summary.js +176 -0
- package/dist/mcp/tools/read-view.d.ts +6 -7
- package/dist/mcp/tools/read-view.js +203 -0
- package/dist/mcp/tools/search-element.d.ts +3 -3
- package/dist/mcp/tools/search-element.js +177 -0
- package/dist/mcp/utils.d.ts +2 -2
- package/dist/mcp/utils.js +48 -0
- package/dist/model/builder/MergedExtends.d.ts +2 -1
- package/dist/model/builder/MergedExtends.js +74 -0
- package/dist/model/builder/MergedSpecification.js +175 -0
- package/dist/model/builder/buildModel.js +176 -0
- package/dist/model/deployments-index.js +102 -0
- package/dist/model/fqn-index.js +250 -0
- package/dist/model/index.js +6 -0
- package/dist/model/model-builder.d.ts +13 -11
- package/dist/model/model-builder.js +234 -0
- package/dist/model/model-locator.d.ts +6 -5
- package/dist/model/model-locator.js +240 -0
- package/dist/model/model-parser-where.js +81 -0
- package/dist/model/model-parser.d.ts +318 -313
- package/dist/model/model-parser.js +119 -0
- package/dist/model/parser/Base.d.ts +3 -3
- package/dist/model/parser/Base.js +367 -0
- package/dist/model/parser/DeploymentModelParser.d.ts +3 -3
- package/dist/model/parser/DeploymentModelParser.js +176 -0
- package/dist/model/parser/DeploymentViewParser.d.ts +4 -4
- package/dist/model/parser/DeploymentViewParser.js +86 -0
- package/dist/model/parser/FqnRefParser.d.ts +3 -3
- package/dist/model/parser/FqnRefParser.js +382 -0
- package/dist/model/parser/GlobalsParser.d.ts +7 -7
- package/dist/model/parser/GlobalsParser.js +84 -0
- package/dist/model/parser/ImportsParser.d.ts +12 -13
- package/dist/model/parser/ImportsParser.js +24 -0
- package/dist/model/parser/ModelParser.d.ts +3 -3
- package/dist/model/parser/ModelParser.js +165 -0
- package/dist/model/parser/PredicatesParser.d.ts +3 -3
- package/dist/model/parser/PredicatesParser.js +45 -0
- package/dist/model/parser/SpecificationParser.d.ts +3 -3
- package/dist/model/parser/SpecificationParser.js +109 -0
- package/dist/model/parser/ValueConverter.js +12 -0
- package/dist/model/parser/ViewsParser.d.ts +4 -4
- package/dist/model/parser/ViewsParser.js +477 -0
- package/dist/model-change/ModelChanges.d.ts +6 -3
- package/dist/model-change/ModelChanges.js +102 -0
- package/dist/model-change/changeElementStyle.js +134 -0
- package/dist/model-change/changeViewLayout.d.ts +2 -2
- package/dist/model-change/changeViewLayout.js +28 -0
- package/dist/model-change/removeManualLayoutV1.d.ts +7 -0
- package/dist/model-change/removeManualLayoutV1.js +27 -0
- package/dist/module.d.ts +10 -5
- package/dist/module.js +143 -0
- package/dist/protocol.d.ts +1 -17
- package/dist/protocol.js +114 -0
- package/dist/references/index.js +3 -0
- package/dist/references/name-provider.js +37 -0
- package/dist/references/scope-computation.js +288 -0
- package/dist/references/scope-provider.d.ts +3 -3
- package/dist/references/scope-provider.js +242 -0
- package/dist/shared/NodeKindProvider.js +57 -0
- package/dist/shared/{WorkspaceSymbolProvider.mjs → WorkspaceSymbolProvider.js} +1 -1
- package/dist/shared/index.js +2 -0
- package/dist/test/index.js +1 -0
- package/dist/test/testServices.d.ts +16 -16
- package/dist/test/testServices.js +210 -0
- package/dist/utils/disposable.js +26 -0
- package/dist/utils/elementRef.d.ts +1 -1
- package/dist/utils/elementRef.js +27 -0
- package/dist/utils/fqnRef.js +63 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/printDocs.js +1 -0
- package/dist/utils/projectId.js +16 -0
- package/dist/utils/stringHash.js +5 -0
- package/dist/validation/DocumentValidator.js +17 -0
- package/dist/validation/_shared.js +26 -0
- package/dist/validation/deployment-checks.js +140 -0
- package/dist/validation/dynamic-view.js +67 -0
- package/dist/validation/element-ref.js +12 -0
- package/dist/validation/element.js +49 -0
- package/dist/validation/imports.js +46 -0
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +157 -0
- package/dist/validation/property-checks.js +108 -0
- package/dist/validation/relation.js +55 -0
- package/dist/validation/specification.js +190 -0
- package/dist/validation/view-predicates/fqn-expr-with.js +43 -0
- package/dist/validation/view-predicates/fqn-ref-expr.js +51 -0
- package/dist/validation/view-predicates/incoming.js +16 -0
- package/dist/validation/view-predicates/index.js +6 -0
- package/dist/validation/view-predicates/outgoing.js +20 -0
- package/dist/validation/view-predicates/relation-expr.js +46 -0
- package/dist/validation/view-predicates/relation-with.js +16 -0
- package/dist/validation/view.d.ts +1 -1
- package/dist/validation/view.js +42 -0
- package/dist/view-utils/assignNavigateTo.js +27 -0
- package/dist/view-utils/index.d.ts +1 -0
- package/dist/view-utils/index.js +2 -0
- package/dist/view-utils/manual-layout.d.ts +6 -0
- package/dist/view-utils/manual-layout.js +151 -0
- package/dist/views/ConfigurableLayouter.js +51 -0
- package/dist/views/LikeC4ManualLayouts.d.ts +28 -0
- package/dist/views/LikeC4ManualLayouts.js +132 -0
- package/dist/views/{likec4-views.d.ts → LikeC4Views.d.ts} +9 -8
- package/dist/views/LikeC4Views.js +200 -0
- package/dist/views/index.d.ts +4 -1
- package/dist/views/index.js +11 -0
- package/dist/workspace/AstNodeDescriptionProvider.js +15 -0
- package/dist/workspace/IndexManager.js +21 -0
- package/dist/workspace/LangiumDocuments.d.ts +1 -1
- package/dist/workspace/LangiumDocuments.js +58 -0
- package/dist/workspace/ProjectsManager.d.ts +8 -3
- package/dist/workspace/ProjectsManager.js +373 -0
- package/dist/workspace/WorkspaceManager.d.ts +3 -2
- package/dist/workspace/WorkspaceManager.js +93 -0
- package/dist/workspace/index.js +5 -0
- package/likec4lib/package.json +1 -1
- package/package.json +32 -31
- package/protocol/package.json +1 -1
- package/dist/LikeC4LanguageServices.mjs +0 -197
- package/dist/Rpc.mjs +0 -296
- package/dist/ast.mjs +0 -221
- package/dist/browser-worker.mjs +0 -2
- package/dist/browser.mjs +0 -32
- package/dist/documentation/documentation-provider.mjs +0 -48
- package/dist/documentation/index.mjs +0 -1
- package/dist/empty.mjs +0 -1
- package/dist/filesystem/ChokidarWatcher.mjs +0 -68
- package/dist/filesystem/FileSystemWatcher.mjs +0 -11
- package/dist/filesystem/LikeC4FileSystem.mjs +0 -64
- package/dist/filesystem/index.mjs +0 -19
- package/dist/formatting/LikeC4Formatter.mjs +0 -511
- package/dist/formatting/utils.mjs +0 -15
- package/dist/generated/ast.mjs +0 -2118
- package/dist/generated/grammar.mjs +0 -3
- package/dist/generated/module.mjs +0 -23
- package/dist/index.mjs +0 -50
- package/dist/logger.mjs +0 -82
- package/dist/lsp/CodeLensProvider.mjs +0 -42
- package/dist/lsp/CompletionProvider.mjs +0 -208
- package/dist/lsp/DocumentHighlightProvider.mjs +0 -10
- package/dist/lsp/DocumentLinkProvider.mjs +0 -53
- package/dist/lsp/DocumentSymbolProvider.mjs +0 -287
- package/dist/lsp/HoverProvider.mjs +0 -104
- package/dist/lsp/RenameProvider.mjs +0 -6
- package/dist/lsp/SemanticTokenProvider.mjs +0 -350
- package/dist/lsp/index.mjs +0 -7
- package/dist/mcp/MCPServerFactory.mjs +0 -70
- package/dist/mcp/NoopLikeC4MCPServer.mjs +0 -17
- package/dist/mcp/interfaces.mjs +0 -4
- package/dist/mcp/server/StdioLikeC4MCPServer.mjs +0 -46
- package/dist/mcp/server/StreamableLikeC4MCPServer.mjs +0 -153
- package/dist/mcp/server/WithMCPServer.mjs +0 -58
- package/dist/mcp/tools/_common.mjs +0 -42
- package/dist/mcp/tools/find-relationships.mjs +0 -151
- package/dist/mcp/tools/list-projects.mjs +0 -62
- package/dist/mcp/tools/open-view.mjs +0 -52
- package/dist/mcp/tools/read-deployment.mjs +0 -130
- package/dist/mcp/tools/read-element.mjs +0 -198
- package/dist/mcp/tools/read-project-summary.mjs +0 -178
- package/dist/mcp/tools/read-view.mjs +0 -205
- package/dist/mcp/tools/search-element.mjs +0 -171
- package/dist/mcp/utils.mjs +0 -47
- package/dist/model/builder/MergedExtends.mjs +0 -67
- package/dist/model/builder/MergedSpecification.mjs +0 -205
- package/dist/model/builder/assignTagColors.d.ts +0 -7
- package/dist/model/builder/assignTagColors.mjs +0 -51
- package/dist/model/builder/buildModel.mjs +0 -226
- package/dist/model/deployments-index.mjs +0 -100
- package/dist/model/fqn-index.mjs +0 -243
- package/dist/model/index.mjs +0 -6
- package/dist/model/model-builder.mjs +0 -285
- package/dist/model/model-locator.mjs +0 -239
- package/dist/model/model-parser-where.mjs +0 -81
- package/dist/model/model-parser.mjs +0 -127
- package/dist/model/parser/Base.mjs +0 -342
- package/dist/model/parser/DeploymentModelParser.mjs +0 -212
- package/dist/model/parser/DeploymentViewParser.mjs +0 -95
- package/dist/model/parser/FqnRefParser.mjs +0 -398
- package/dist/model/parser/GlobalsParser.mjs +0 -82
- package/dist/model/parser/ImportsParser.mjs +0 -28
- package/dist/model/parser/ModelParser.mjs +0 -190
- package/dist/model/parser/PredicatesParser.mjs +0 -45
- package/dist/model/parser/SpecificationParser.mjs +0 -120
- package/dist/model/parser/ValueConverter.mjs +0 -12
- package/dist/model/parser/ViewsParser.mjs +0 -490
- package/dist/model-change/ModelChanges.mjs +0 -89
- package/dist/model-change/changeElementStyle.mjs +0 -143
- package/dist/model-change/changeViewLayout.mjs +0 -32
- package/dist/model-change/saveManualLayout.d.ts +0 -11
- package/dist/model-change/saveManualLayout.mjs +0 -27
- package/dist/module.mjs +0 -180
- package/dist/protocol.mjs +0 -65
- package/dist/references/index.mjs +0 -3
- package/dist/references/name-provider.mjs +0 -39
- package/dist/references/scope-computation.mjs +0 -312
- package/dist/references/scope-provider.mjs +0 -239
- package/dist/shared/NodeKindProvider.mjs +0 -110
- package/dist/shared/index.mjs +0 -2
- package/dist/test/index.mjs +0 -1
- package/dist/test/testServices.mjs +0 -200
- package/dist/utils/disposable.mjs +0 -25
- package/dist/utils/elementRef.mjs +0 -20
- package/dist/utils/fqnRef.mjs +0 -57
- package/dist/utils/index.mjs +0 -33
- package/dist/utils/printDocs.mjs +0 -1
- package/dist/utils/projectId.mjs +0 -16
- package/dist/utils/stringHash.mjs +0 -5
- package/dist/validation/DocumentValidator.mjs +0 -16
- package/dist/validation/_shared.mjs +0 -25
- package/dist/validation/deployment-checks.mjs +0 -146
- package/dist/validation/dynamic-view.mjs +0 -67
- package/dist/validation/element-ref.mjs +0 -12
- package/dist/validation/element.mjs +0 -50
- package/dist/validation/imports.mjs +0 -25
- package/dist/validation/index.mjs +0 -180
- package/dist/validation/property-checks.mjs +0 -107
- package/dist/validation/relation.mjs +0 -53
- package/dist/validation/specification.mjs +0 -173
- package/dist/validation/view-predicates/fqn-expr-with.mjs +0 -43
- package/dist/validation/view-predicates/fqn-ref-expr.mjs +0 -53
- package/dist/validation/view-predicates/incoming.mjs +0 -16
- package/dist/validation/view-predicates/index.mjs +0 -6
- package/dist/validation/view-predicates/outgoing.mjs +0 -20
- package/dist/validation/view-predicates/relation-expr.mjs +0 -39
- package/dist/validation/view-predicates/relation-with.mjs +0 -16
- package/dist/validation/view.mjs +0 -25
- package/dist/view-utils/assignNavigateTo.mjs +0 -25
- package/dist/view-utils/index.mjs +0 -1
- package/dist/view-utils/manual-layout.mjs +0 -99
- package/dist/views/configurable-layouter.mjs +0 -51
- package/dist/views/index.mjs +0 -1
- package/dist/views/likec4-views.mjs +0 -166
- package/dist/workspace/AstNodeDescriptionProvider.mjs +0 -17
- package/dist/workspace/IndexManager.mjs +0 -17
- package/dist/workspace/LangiumDocuments.mjs +0 -53
- package/dist/workspace/ProjectsManager.mjs +0 -360
- package/dist/workspace/WorkspaceManager.mjs +0 -83
- package/dist/workspace/index.mjs +0 -5
- /package/dist/views/{configurable-layouter.d.ts → ConfigurableLayouter.d.ts} +0 -0
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { AstUtils } from "langium";
|
|
2
|
-
import { projectIdFrom } from "../utils/index.mjs";
|
|
3
|
-
import { tryOrLog } from "./_shared.mjs";
|
|
4
|
-
const { getDocument } = AstUtils;
|
|
5
|
-
export const checkImportsFromPoject = (services) => {
|
|
6
|
-
const projects = services.shared.workspace.ProjectsManager;
|
|
7
|
-
return tryOrLog((el, accept) => {
|
|
8
|
-
const doc = getDocument(el);
|
|
9
|
-
const projectId = projectIdFrom(doc);
|
|
10
|
-
if (el.project === projectId) {
|
|
11
|
-
accept("error", "Imported project cannot be the same as the current project", {
|
|
12
|
-
node: el,
|
|
13
|
-
property: "project"
|
|
14
|
-
});
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (!projects.all.includes(el.project)) {
|
|
18
|
-
accept("error", "Imported project not found", {
|
|
19
|
-
node: el,
|
|
20
|
-
property: "project"
|
|
21
|
-
});
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { onNextTick } from "@likec4/core/utils";
|
|
2
|
-
import { loggable } from "@likec4/log";
|
|
3
|
-
import { DocumentState } from "langium";
|
|
4
|
-
import { isNullish } from "remeda";
|
|
5
|
-
import { DiagnosticSeverity } from "vscode-languageserver-types";
|
|
6
|
-
import { ast } from "../ast.mjs";
|
|
7
|
-
import { logger } from "../logger.mjs";
|
|
8
|
-
import {
|
|
9
|
-
deployedInstanceChecks,
|
|
10
|
-
deploymentNodeChecks,
|
|
11
|
-
deploymentRelationChecks,
|
|
12
|
-
extendDeploymentChecks
|
|
13
|
-
} from "./deployment-checks.mjs";
|
|
14
|
-
import { dynamicViewDisplayVariant, dynamicViewStepChain, dynamicViewStepSingle } from "./dynamic-view.mjs";
|
|
15
|
-
import { checkElement } from "./element.mjs";
|
|
16
|
-
import { checkElementRef } from "./element-ref.mjs";
|
|
17
|
-
import { checkImportsFromPoject } from "./imports.mjs";
|
|
18
|
-
import {
|
|
19
|
-
colorLiteralRuleChecks,
|
|
20
|
-
iconPropertyRuleChecks,
|
|
21
|
-
notesPropertyRuleChecks,
|
|
22
|
-
opacityPropertyRuleChecks
|
|
23
|
-
} from "./property-checks.mjs";
|
|
24
|
-
import { checkRelationBody, relationChecks } from "./relation.mjs";
|
|
25
|
-
import {
|
|
26
|
-
checkDeploymentNodeKind,
|
|
27
|
-
checkElementKind,
|
|
28
|
-
checkGlobalPredicate,
|
|
29
|
-
checkGlobals,
|
|
30
|
-
checkGlobalStyleId,
|
|
31
|
-
checkModel,
|
|
32
|
-
checkRelationshipKind,
|
|
33
|
-
checkSpecificationRule,
|
|
34
|
-
checkTag
|
|
35
|
-
} from "./specification.mjs";
|
|
36
|
-
import { viewChecks } from "./view.mjs";
|
|
37
|
-
import {
|
|
38
|
-
checkFqnExprWith,
|
|
39
|
-
checkFqnRefExpr,
|
|
40
|
-
checkIncomingRelationExpr,
|
|
41
|
-
checkOutgoingRelationExpr,
|
|
42
|
-
checkRelationExpr,
|
|
43
|
-
checkRelationExprWith
|
|
44
|
-
} from "./view-predicates/index.mjs";
|
|
45
|
-
export { LikeC4DocumentValidator } from "./DocumentValidator.mjs";
|
|
46
|
-
function validatableAstNodeGuards(predicates) {
|
|
47
|
-
return (n) => predicates.some((p) => p(n));
|
|
48
|
-
}
|
|
49
|
-
const isValidatableAstNode = validatableAstNodeGuards([
|
|
50
|
-
ast.isImportsFromPoject,
|
|
51
|
-
ast.isImported,
|
|
52
|
-
ast.isGlobals,
|
|
53
|
-
ast.isGlobalPredicateGroup,
|
|
54
|
-
ast.isGlobalDynamicPredicateGroup,
|
|
55
|
-
ast.isGlobalStyle,
|
|
56
|
-
ast.isGlobalStyleGroup,
|
|
57
|
-
ast.isFqnExprWith,
|
|
58
|
-
ast.isRelationExprWith,
|
|
59
|
-
ast.isFqnExpr,
|
|
60
|
-
ast.isRelationExpr,
|
|
61
|
-
ast.isDynamicViewParallelSteps,
|
|
62
|
-
ast.isDynamicStepChain,
|
|
63
|
-
ast.isDynamicStepSingle,
|
|
64
|
-
ast.isDeploymentViewRule,
|
|
65
|
-
ast.isDeploymentViewRulePredicate,
|
|
66
|
-
ast.isExpressionV2,
|
|
67
|
-
ast.isRelationExpr,
|
|
68
|
-
ast.isFqnRefExpr,
|
|
69
|
-
ast.isViewProperty,
|
|
70
|
-
ast.isStyleProperty,
|
|
71
|
-
ast.isTags,
|
|
72
|
-
ast.isViewRule,
|
|
73
|
-
ast.isDynamicViewRule,
|
|
74
|
-
ast.isLikeC4View,
|
|
75
|
-
ast.isViewRuleStyleOrGlobalRef,
|
|
76
|
-
ast.isDeployedInstance,
|
|
77
|
-
ast.isDeploymentNode,
|
|
78
|
-
ast.isDeploymentRelation,
|
|
79
|
-
ast.isRelationshipStyleProperty,
|
|
80
|
-
ast.isDynamicViewDisplayVariantProperty,
|
|
81
|
-
ast.isMetadataProperty,
|
|
82
|
-
ast.isRelation,
|
|
83
|
-
ast.isElementProperty,
|
|
84
|
-
ast.isStringProperty,
|
|
85
|
-
ast.isNavigateToProperty,
|
|
86
|
-
ast.isElement,
|
|
87
|
-
ast.isElementRef,
|
|
88
|
-
ast.isExtendElement,
|
|
89
|
-
ast.isExtendDeployment,
|
|
90
|
-
ast.isSpecificationElementKind,
|
|
91
|
-
ast.isSpecificationRelationshipKind,
|
|
92
|
-
ast.isSpecificationDeploymentNodeKind,
|
|
93
|
-
ast.isSpecificationTag,
|
|
94
|
-
ast.isSpecificationColor,
|
|
95
|
-
ast.isSpecificationRule,
|
|
96
|
-
ast.isColorLiteral
|
|
97
|
-
]);
|
|
98
|
-
const findInvalidContainer = (node) => {
|
|
99
|
-
let nd = node;
|
|
100
|
-
while (nd && !ast.isLikeC4Grammar(nd)) {
|
|
101
|
-
if (isValidatableAstNode(nd)) {
|
|
102
|
-
return nd;
|
|
103
|
-
}
|
|
104
|
-
nd = nd.$container;
|
|
105
|
-
}
|
|
106
|
-
return void 0;
|
|
107
|
-
};
|
|
108
|
-
export function checksFromDiagnostics(doc) {
|
|
109
|
-
const errors = doc.state >= DocumentState.Validated ? doc.diagnostics?.filter((d) => d.severity === DiagnosticSeverity.Error) ?? [] : [];
|
|
110
|
-
const invalidNodes = /* @__PURE__ */ new WeakSet();
|
|
111
|
-
for (const { node } of errors) {
|
|
112
|
-
if (isNullish(node) || invalidNodes.has(node)) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
invalidNodes.add(node);
|
|
116
|
-
const container = findInvalidContainer(node);
|
|
117
|
-
if (container) {
|
|
118
|
-
invalidNodes.add(container);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const isValid = (n) => !invalidNodes.has(n);
|
|
122
|
-
return {
|
|
123
|
-
isValid,
|
|
124
|
-
invalidNodes
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
export function registerValidationChecks(services) {
|
|
128
|
-
logger.debug("registerValidationChecks");
|
|
129
|
-
const registry = services.validation.ValidationRegistry;
|
|
130
|
-
registry.register({
|
|
131
|
-
DeployedInstance: deployedInstanceChecks(services),
|
|
132
|
-
DeploymentNodeKind: checkDeploymentNodeKind(services),
|
|
133
|
-
DeploymentNode: deploymentNodeChecks(services),
|
|
134
|
-
DeploymentRelation: deploymentRelationChecks(services),
|
|
135
|
-
ExtendDeployment: extendDeploymentChecks(services),
|
|
136
|
-
FqnRefExpr: checkFqnRefExpr(services),
|
|
137
|
-
RelationExpr: checkRelationExpr(services),
|
|
138
|
-
NotesProperty: notesPropertyRuleChecks(services),
|
|
139
|
-
OpacityProperty: opacityPropertyRuleChecks(services),
|
|
140
|
-
IconProperty: iconPropertyRuleChecks(services),
|
|
141
|
-
SpecificationRule: checkSpecificationRule(services),
|
|
142
|
-
Model: checkModel(services),
|
|
143
|
-
Globals: checkGlobals(services),
|
|
144
|
-
GlobalPredicateGroup: checkGlobalPredicate(services),
|
|
145
|
-
GlobalDynamicPredicateGroup: checkGlobalPredicate(services),
|
|
146
|
-
GlobalStyleId: checkGlobalStyleId(services),
|
|
147
|
-
DynamicStepSingle: dynamicViewStepSingle(services),
|
|
148
|
-
DynamicStepChain: dynamicViewStepChain(services),
|
|
149
|
-
LikeC4View: viewChecks(services),
|
|
150
|
-
Element: checkElement(services),
|
|
151
|
-
ElementRef: checkElementRef(services),
|
|
152
|
-
ElementKind: checkElementKind(services),
|
|
153
|
-
Relation: relationChecks(services),
|
|
154
|
-
RelationBody: checkRelationBody(services),
|
|
155
|
-
Tag: checkTag(services),
|
|
156
|
-
FqnExprWith: checkFqnExprWith(services),
|
|
157
|
-
RelationExprWith: checkRelationExprWith(services),
|
|
158
|
-
RelationshipKind: checkRelationshipKind(services),
|
|
159
|
-
IncomingRelationExpr: checkIncomingRelationExpr(services),
|
|
160
|
-
OutgoingRelationExpr: checkOutgoingRelationExpr(services),
|
|
161
|
-
ImportsFromPoject: checkImportsFromPoject(services),
|
|
162
|
-
// Imported: checkImported(services),
|
|
163
|
-
ColorLiteral: colorLiteralRuleChecks(services),
|
|
164
|
-
DynamicViewDisplayVariantProperty: dynamicViewDisplayVariant(services)
|
|
165
|
-
});
|
|
166
|
-
const connection = services.shared.lsp.Connection;
|
|
167
|
-
if (connection) {
|
|
168
|
-
onNextTick(() => {
|
|
169
|
-
services.shared.workspace.DocumentBuilder.onUpdate((_, deleted) => {
|
|
170
|
-
for (const uri of deleted) {
|
|
171
|
-
logger.debug(`clear diagnostics for deleted ${uri.path}`);
|
|
172
|
-
connection.sendDiagnostics({
|
|
173
|
-
uri: uri.toString(),
|
|
174
|
-
diagnostics: []
|
|
175
|
-
}).catch((e) => logger.error(loggable(e)));
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { nonexhaustive } from "@likec4/core";
|
|
2
|
-
import { AstUtils } from "langium";
|
|
3
|
-
import { isNumber, isString } from "remeda";
|
|
4
|
-
import { ast } from "../ast.mjs";
|
|
5
|
-
import { tryOrLog } from "./_shared.mjs";
|
|
6
|
-
export const opacityPropertyRuleChecks = (_) => {
|
|
7
|
-
return tryOrLog((node, accept) => {
|
|
8
|
-
const opacity = parseFloat(node.value);
|
|
9
|
-
if (isNaN(opacity) || opacity < 0 || opacity > 100) {
|
|
10
|
-
accept("warning", `Value ignored, must be between 0% and 100%`, {
|
|
11
|
-
node,
|
|
12
|
-
property: "value"
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
export const iconPropertyRuleChecks = (_) => {
|
|
18
|
-
return (node, accept) => {
|
|
19
|
-
const container = node.$container;
|
|
20
|
-
const anotherIcon = container.props.some((p) => ast.isIconProperty(p) && p !== node);
|
|
21
|
-
if (anotherIcon) {
|
|
22
|
-
accept("error", `Icon must be defined once`, {
|
|
23
|
-
node
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (ast.isElementStyleProperty(container) && ast.isElementBody(container.$container) && container.$container.props.some((p) => ast.isIconProperty(p))) {
|
|
27
|
-
accept("warning", `Redundant as icon defined on element`, {
|
|
28
|
-
node
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
if (node.value?.startsWith("file://")) {
|
|
32
|
-
accept("error", `Icon URI must not start with file://`, {
|
|
33
|
-
node,
|
|
34
|
-
property: "value"
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export const notesPropertyRuleChecks = (_) => {
|
|
40
|
-
return (node, accept) => {
|
|
41
|
-
if (!AstUtils.hasContainerOfType(node, ast.isDynamicViewStep)) {
|
|
42
|
-
accept("error", `Notes can be defined only inside dynamic view`, {
|
|
43
|
-
node
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
export const colorLiteralRuleChecks = (_) => {
|
|
49
|
-
return (node, accept) => {
|
|
50
|
-
if (node.$type === "HexColor") {
|
|
51
|
-
if (node.hex === void 0 || isString(node.hex) && !node.hex.match(/^[a-fA-F0-9]+$/)) {
|
|
52
|
-
accept("error", `Invalid HEX`, {
|
|
53
|
-
node,
|
|
54
|
-
property: "hex"
|
|
55
|
-
});
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const length = isNumber(node.hex) ? node.hex.toString().length : node.hex.length;
|
|
59
|
-
if (length !== 6 && length !== 3 && length !== 8) {
|
|
60
|
-
accept("error", `Invalid value "${node.$cstNode?.text}", must be 3, 6 or 8 characters long`, {
|
|
61
|
-
node,
|
|
62
|
-
property: "hex"
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (node.$type === "RGBAColor") {
|
|
68
|
-
if (!isNumber(node.red) || node.red < 0 || node.red > 255) {
|
|
69
|
-
accept("error", `Invalid value, must be between 0 and 255`, {
|
|
70
|
-
node,
|
|
71
|
-
property: "red"
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
if (!isNumber(node.green) || node.green < 0 || node.green > 255) {
|
|
75
|
-
accept("error", `Invalid value, must be between 0 and 255`, {
|
|
76
|
-
node,
|
|
77
|
-
property: "green"
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
if (!isNumber(node.blue) || node.blue < 0 || node.blue > 255) {
|
|
81
|
-
accept("error", `Invalid value, must be between 0 and 255`, {
|
|
82
|
-
node,
|
|
83
|
-
property: "blue"
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
if (isNumber(node.alpha)) {
|
|
87
|
-
if (node.alpha < 0 || node.alpha > 1) {
|
|
88
|
-
accept("error", `Invalid value, must be between 0 and 1`, {
|
|
89
|
-
node,
|
|
90
|
-
property: "alpha"
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (isString(node.alpha)) {
|
|
95
|
-
const alpha = parseFloat(node.alpha);
|
|
96
|
-
if (alpha < 0 || alpha > 100) {
|
|
97
|
-
accept("error", `Invalid value, must be between 0% and 100%`, {
|
|
98
|
-
node,
|
|
99
|
-
property: "alpha"
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
nonexhaustive(node);
|
|
106
|
-
};
|
|
107
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { FqnRef, isSameHierarchy } from "@likec4/core";
|
|
2
|
-
import { AstUtils } from "langium";
|
|
3
|
-
import { safeCall } from "../utils/index.mjs";
|
|
4
|
-
import { tryOrLog } from "./_shared.mjs";
|
|
5
|
-
export const relationChecks = (services) => {
|
|
6
|
-
const modelParser = services.likec4.ModelParser;
|
|
7
|
-
return tryOrLog((el, accept) => {
|
|
8
|
-
const parser = modelParser.forDocument(AstUtils.getDocument(el));
|
|
9
|
-
const source = safeCall(() => parser._resolveRelationSource(el));
|
|
10
|
-
if (!source) {
|
|
11
|
-
accept("error", "Source not resolved", {
|
|
12
|
-
node: el,
|
|
13
|
-
property: "source"
|
|
14
|
-
});
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const target = safeCall(() => parser.parseFqnRef(el.target));
|
|
18
|
-
if (!target) {
|
|
19
|
-
accept("error", "Target not resolved", {
|
|
20
|
-
node: el,
|
|
21
|
-
property: "target"
|
|
22
|
-
});
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (FqnRef.isImportRef(source)) {
|
|
26
|
-
if (FqnRef.isImportRef(target)) {
|
|
27
|
-
accept("warning", "Relationship between imported elements may not be visible in origin projects", {
|
|
28
|
-
node: el
|
|
29
|
-
});
|
|
30
|
-
} else {
|
|
31
|
-
accept("warning", "Relationship from imported element to local element may not be visible in origin project", {
|
|
32
|
-
node: el,
|
|
33
|
-
property: "source"
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (isSameHierarchy(FqnRef.flatten(source), FqnRef.flatten(target))) {
|
|
38
|
-
accept("error", "Invalid parent-child relationship", {
|
|
39
|
-
node: el
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
export const checkRelationBody = (_services) => {
|
|
45
|
-
return tryOrLog((body, accept) => {
|
|
46
|
-
const relation = body.$container;
|
|
47
|
-
if (relation.tags?.values && body.tags?.values) {
|
|
48
|
-
accept("error", "Relation cannot have tags in both header and body", {
|
|
49
|
-
node: body.tags
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { AstUtils } from "langium";
|
|
2
|
-
import { ast } from "../ast.mjs";
|
|
3
|
-
import { projectIdFrom } from "../utils/index.mjs";
|
|
4
|
-
import { RESERVED_WORDS, tryOrLog } from "./_shared.mjs";
|
|
5
|
-
export const checkSpecificationRule = (_) => {
|
|
6
|
-
return tryOrLog((node, accept) => {
|
|
7
|
-
if (node.$containerIndex && node.$containerIndex > 0) {
|
|
8
|
-
accept("warning", `Prefer one specification per document`, {
|
|
9
|
-
node,
|
|
10
|
-
property: "name"
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
export const checkModel = (_) => {
|
|
16
|
-
return tryOrLog((node, accept) => {
|
|
17
|
-
if (node.$containerIndex && node.$containerIndex > 0) {
|
|
18
|
-
accept("warning", `Prefer one model per document`, {
|
|
19
|
-
node,
|
|
20
|
-
property: "name"
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
export const checkGlobals = (_) => {
|
|
26
|
-
return tryOrLog((node, accept) => {
|
|
27
|
-
if (node.$containerIndex && node.$containerIndex > 0) {
|
|
28
|
-
accept("warning", `Prefer one global block per document`, {
|
|
29
|
-
node,
|
|
30
|
-
property: "name"
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
export const checkElementKind = (services) => {
|
|
36
|
-
const index = services.shared.workspace.IndexManager;
|
|
37
|
-
return tryOrLog((node, accept) => {
|
|
38
|
-
if (RESERVED_WORDS.includes(node.name)) {
|
|
39
|
-
accept("error", `Reserved word: ${node.name}`, {
|
|
40
|
-
node,
|
|
41
|
-
property: "name"
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
const projectId = projectIdFrom(node);
|
|
45
|
-
const sameKind = index.projectElements(projectId, ast.ElementKind).filter((n) => n.name === node.name && n.node !== node).head();
|
|
46
|
-
if (sameKind) {
|
|
47
|
-
const isAnotherDoc = sameKind.documentUri !== AstUtils.getDocument(node).uri;
|
|
48
|
-
accept("error", `Duplicate element kind '${node.name}'`, {
|
|
49
|
-
node,
|
|
50
|
-
property: "name",
|
|
51
|
-
...isAnotherDoc && {
|
|
52
|
-
relatedInformation: [
|
|
53
|
-
{
|
|
54
|
-
location: {
|
|
55
|
-
range: sameKind.nameSegment.range,
|
|
56
|
-
uri: sameKind.documentUri.toString()
|
|
57
|
-
},
|
|
58
|
-
message: `conflicting definition`
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
export const checkDeploymentNodeKind = (services) => {
|
|
67
|
-
const index = services.shared.workspace.IndexManager;
|
|
68
|
-
return tryOrLog((node, accept) => {
|
|
69
|
-
if (RESERVED_WORDS.includes(node.name)) {
|
|
70
|
-
accept("error", `Reserved word: ${node.name}`, {
|
|
71
|
-
node,
|
|
72
|
-
property: "name"
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const projectId = projectIdFrom(node);
|
|
76
|
-
const sameKind = index.projectElements(projectId, ast.DeploymentNodeKind).filter((n) => n.name === node.name && n.node !== node).head();
|
|
77
|
-
if (sameKind) {
|
|
78
|
-
const isAnotherDoc = sameKind.documentUri !== AstUtils.getDocument(node).uri;
|
|
79
|
-
accept("error", `Duplicate deploymentNode kind '${node.name}'`, {
|
|
80
|
-
node,
|
|
81
|
-
property: "name",
|
|
82
|
-
...isAnotherDoc && {
|
|
83
|
-
relatedInformation: [
|
|
84
|
-
{
|
|
85
|
-
location: {
|
|
86
|
-
range: sameKind.nameSegment.range,
|
|
87
|
-
uri: sameKind.documentUri.toString()
|
|
88
|
-
},
|
|
89
|
-
message: `conflicting definition`
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
export const checkTag = (services) => {
|
|
98
|
-
const index = services.shared.workspace.IndexManager;
|
|
99
|
-
return tryOrLog((node, accept) => {
|
|
100
|
-
const tagname = node.name;
|
|
101
|
-
const projectId = projectIdFrom(node);
|
|
102
|
-
const sameTag = index.projectElements(projectId, ast.Tag).filter((n) => n.name === tagname && n.node !== node).head();
|
|
103
|
-
if (sameTag) {
|
|
104
|
-
const isAnotherDoc = sameTag.documentUri !== AstUtils.getDocument(node).uri;
|
|
105
|
-
accept(
|
|
106
|
-
"error",
|
|
107
|
-
`Duplicate tag '${node.name}'`,
|
|
108
|
-
{
|
|
109
|
-
node,
|
|
110
|
-
property: "name",
|
|
111
|
-
...isAnotherDoc && {
|
|
112
|
-
relatedInformation: [
|
|
113
|
-
{
|
|
114
|
-
location: {
|
|
115
|
-
range: sameTag.nameSegment.range,
|
|
116
|
-
uri: sameTag.documentUri.toString()
|
|
117
|
-
},
|
|
118
|
-
message: `conflicting definition`
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
export const checkRelationshipKind = (services) => {
|
|
128
|
-
const index = services.shared.workspace.IndexManager;
|
|
129
|
-
return tryOrLog((node, accept) => {
|
|
130
|
-
if (RESERVED_WORDS.includes(node.name)) {
|
|
131
|
-
accept("error", `Reserved word: ${node.name}`, {
|
|
132
|
-
node,
|
|
133
|
-
property: "name"
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
const projectId = projectIdFrom(node);
|
|
137
|
-
const sameKinds = index.projectElements(projectId, ast.RelationshipKind).filter((n) => n.name === node.name).limit(2).count();
|
|
138
|
-
if (sameKinds > 1) {
|
|
139
|
-
accept("error", `Duplicate RelationshipKind '${node.name}'`, {
|
|
140
|
-
node,
|
|
141
|
-
property: "name"
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
export const checkGlobalPredicate = (services) => {
|
|
147
|
-
const index = services.shared.workspace.IndexManager;
|
|
148
|
-
return tryOrLog((node, accept) => {
|
|
149
|
-
const projectId = projectIdFrom(node);
|
|
150
|
-
const predicateGroups = index.projectElements(projectId, ast.GlobalPredicateGroup);
|
|
151
|
-
const dynamicPredicateGroups = index.projectElements(projectId, ast.GlobalDynamicPredicateGroup);
|
|
152
|
-
const sameName = predicateGroups.concat(dynamicPredicateGroups).filter((s) => s.name === node.name).limit(2).count();
|
|
153
|
-
if (sameName > 1) {
|
|
154
|
-
accept("error", `Duplicate GlobalPredicateGroup or GlobalDynamicPredicateGroup name '${node.name}'`, {
|
|
155
|
-
node,
|
|
156
|
-
property: "name"
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
export const checkGlobalStyleId = (services) => {
|
|
162
|
-
const index = services.shared.workspace.IndexManager;
|
|
163
|
-
return tryOrLog((node, accept) => {
|
|
164
|
-
const projectId = projectIdFrom(node);
|
|
165
|
-
const sameName = index.projectElements(projectId, ast.GlobalStyleId).filter((s) => s.name === node.name).limit(2).count();
|
|
166
|
-
if (sameName > 1) {
|
|
167
|
-
accept("error", `Duplicate GlobalStyleId name '${node.name}'`, {
|
|
168
|
-
node,
|
|
169
|
-
property: "name"
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { FqnExpr } from "@likec4/core/types";
|
|
2
|
-
import { nonexhaustive } from "@likec4/core/utils";
|
|
3
|
-
import { AstUtils } from "langium";
|
|
4
|
-
import { getViewRulePredicateContainer } from "../../ast.mjs";
|
|
5
|
-
import { tryOrLog } from "../_shared.mjs";
|
|
6
|
-
export const checkFqnExprWith = (services) => {
|
|
7
|
-
const modelParser = services.likec4.ModelParser;
|
|
8
|
-
return tryOrLog((el, accept) => {
|
|
9
|
-
const container = getViewRulePredicateContainer(el);
|
|
10
|
-
if (container?.$type !== "DynamicViewIncludePredicate" && container?.isInclude !== true) {
|
|
11
|
-
accept("error", 'Invalid usage inside "exclude"', {
|
|
12
|
-
node: el
|
|
13
|
-
});
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const isInsideDynamicView = container.$type === "DynamicViewIncludePredicate";
|
|
17
|
-
const parser = modelParser.forDocument(AstUtils.getDocument(container));
|
|
18
|
-
let expr = FqnExpr.unwrap(parser.parseFqnExprWith(el).custom.expr);
|
|
19
|
-
switch (true) {
|
|
20
|
-
case (FqnExpr.isWildcard(expr) && isInsideDynamicView):
|
|
21
|
-
case (FqnExpr.isElementKindExpr(expr) && isInsideDynamicView):
|
|
22
|
-
case (FqnExpr.isElementTagExpr(expr) && isInsideDynamicView): {
|
|
23
|
-
accept("warning", `Predicate is ignored, as not supported in dynamic views`, {
|
|
24
|
-
node: el
|
|
25
|
-
});
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
case FqnExpr.isWildcard(expr):
|
|
29
|
-
case FqnExpr.isModelRef(expr):
|
|
30
|
-
case FqnExpr.isDeploymentRef(expr):
|
|
31
|
-
return;
|
|
32
|
-
case FqnExpr.isElementKindExpr(expr):
|
|
33
|
-
case FqnExpr.isElementTagExpr(expr):
|
|
34
|
-
accept("error", "Invalid target (expect reference to specific element)", {
|
|
35
|
-
node: el,
|
|
36
|
-
property: "subject"
|
|
37
|
-
});
|
|
38
|
-
return;
|
|
39
|
-
default:
|
|
40
|
-
nonexhaustive(expr);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { FqnExpr, FqnRef } from "@likec4/core/types";
|
|
2
|
-
import { AstUtils } from "langium";
|
|
3
|
-
import { isTruthy } from "remeda";
|
|
4
|
-
import { ast, getViewRulePredicateContainer, isFqnRefInsideDeployment } from "../../ast.mjs";
|
|
5
|
-
import { tryOrLog } from "../_shared.mjs";
|
|
6
|
-
export const checkFqnRefExpr = (services) => {
|
|
7
|
-
const modelParser = services.likec4.ModelParser;
|
|
8
|
-
return tryOrLog((node, accept) => {
|
|
9
|
-
const parser = modelParser.forDocument(AstUtils.getDocument(node));
|
|
10
|
-
const expr = parser.parseFqnRefExpr(node);
|
|
11
|
-
const viewRulePredicate = getViewRulePredicateContainer(node);
|
|
12
|
-
const isInsideDeploymentButNotStyle = isFqnRefInsideDeployment(node) && !AstUtils.hasContainerOfType(
|
|
13
|
-
node,
|
|
14
|
-
(n) => ast.isDeploymentViewRuleStyle(n) || ast.isViewRuleStyle(n)
|
|
15
|
-
);
|
|
16
|
-
if (viewRulePredicate?.$type === "DeploymentViewRulePredicate" || isInsideDeploymentButNotStyle) {
|
|
17
|
-
const isPartOfRelationExpr = AstUtils.hasContainerOfType(node, ast.isRelationExpr);
|
|
18
|
-
if (!isPartOfRelationExpr) {
|
|
19
|
-
if (FqnExpr.isModelRef(expr)) {
|
|
20
|
-
accept("error", "Deployment view predicate must reference deployment model", {
|
|
21
|
-
node
|
|
22
|
-
});
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (FqnExpr.isDeploymentRef(expr) && FqnRef.isInsideInstanceRef(expr.ref)) {
|
|
26
|
-
accept("error", "Must reference deployment nodes or instances, but not internals", {
|
|
27
|
-
node
|
|
28
|
-
});
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (isTruthy(node.selector) && !ast.isDeploymentNode(node.ref.value?.ref)) {
|
|
33
|
-
accept("warning", `Selector '${node.selector}' applies to deployment nodes only, ignored here`, {
|
|
34
|
-
node,
|
|
35
|
-
property: "selector"
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (viewRulePredicate?.$type === "DynamicViewIncludePredicate") {
|
|
41
|
-
switch (true) {
|
|
42
|
-
case FqnExpr.isElementKindExpr(expr):
|
|
43
|
-
case FqnExpr.isElementTagExpr(expr):
|
|
44
|
-
case FqnExpr.isWildcard(expr): {
|
|
45
|
-
accept("warning", `Predicate is ignored, as not supported in dynamic views`, {
|
|
46
|
-
node
|
|
47
|
-
});
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AstUtils } from "langium";
|
|
2
|
-
import { isNullish } from "remeda";
|
|
3
|
-
import { ast } from "../../ast.mjs";
|
|
4
|
-
import { tryOrLog } from "../_shared.mjs";
|
|
5
|
-
export const checkIncomingRelationExpr = (_services) => {
|
|
6
|
-
return tryOrLog((el, accept) => {
|
|
7
|
-
if (el.to.$type === "WildcardExpression" && !ast.isInOutRelationExpr(el.$container)) {
|
|
8
|
-
const view = AstUtils.getContainerOfType(el, ast.isElementView);
|
|
9
|
-
if (isNullish(view?.viewOf)) {
|
|
10
|
-
accept("warning", "Predicate is ignored as it concerns all relationships", {
|
|
11
|
-
node: el
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { checkFqnExprWith } from "./fqn-expr-with.mjs";
|
|
2
|
-
export { checkFqnRefExpr } from "./fqn-ref-expr.mjs";
|
|
3
|
-
export { checkIncomingRelationExpr } from "./incoming.mjs";
|
|
4
|
-
export { checkOutgoingRelationExpr } from "./outgoing.mjs";
|
|
5
|
-
export { checkRelationExpr } from "./relation-expr.mjs";
|
|
6
|
-
export { checkRelationExprWith } from "./relation-with.mjs";
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AstUtils } from "langium";
|
|
2
|
-
import { isNullish } from "remeda";
|
|
3
|
-
import { ast, getViewRulePredicateContainer } from "../../ast.mjs";
|
|
4
|
-
import { tryOrLog } from "../_shared.mjs";
|
|
5
|
-
export const checkOutgoingRelationExpr = (_services) => {
|
|
6
|
-
return tryOrLog((el, accept) => {
|
|
7
|
-
const viewRulePredicate = getViewRulePredicateContainer(el);
|
|
8
|
-
if (viewRulePredicate?.$type !== "ViewRulePredicate") {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if (el.$container.$type !== "DirectedRelationExpr" && el.from.$type === "WildcardExpression") {
|
|
12
|
-
const view = AstUtils.getContainerOfType(el, ast.isElementView);
|
|
13
|
-
if (view && isNullish(view.viewOf)) {
|
|
14
|
-
accept("warning", "Predicate is ignored as it concerns all relationships", {
|
|
15
|
-
node: el
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
};
|