@likec4/language-server 1.46.4 → 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 -4681
- 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 -62
- package/protocol/package.json +2 -2
- package/dist/LikeC4LanguageServices.d.ts +0 -109
- package/dist/LikeC4LanguageServices.js +0 -154
- package/dist/Rpc.d.ts +0 -9
- package/dist/Rpc.js +0 -270
- 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 -11
- package/dist/browser.js +0 -35
- 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 -16
- package/dist/filesystem/ChokidarWatcher.js +0 -108
- 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 -130
- 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 -38
- package/dist/index.js +0 -55
- 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 -11
- package/dist/lsp/CompletionProvider.js +0 -200
- 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 -12
- package/dist/lsp/SemanticTokenProvider.js +0 -264
- 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 -5
- 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 -145
- 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 -12
- package/dist/mcp/tools/find-relationships.js +0 -150
- package/dist/mcp/tools/list-projects.d.ts +0 -6
- package/dist/mcp/tools/list-projects.js +0 -62
- package/dist/mcp/tools/open-view.d.ts +0 -10
- package/dist/mcp/tools/open-view.js +0 -52
- package/dist/mcp/tools/read-deployment.d.ts +0 -10
- package/dist/mcp/tools/read-deployment.js +0 -150
- package/dist/mcp/tools/read-element.d.ts +0 -10
- package/dist/mcp/tools/read-element.js +0 -218
- package/dist/mcp/tools/read-project-summary.d.ts +0 -8
- package/dist/mcp/tools/read-project-summary.js +0 -176
- package/dist/mcp/tools/read-view.d.ts +0 -10
- package/dist/mcp/tools/read-view.js +0 -203
- package/dist/mcp/tools/search-element.d.ts +0 -8
- 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 -52
- package/dist/model/model-builder.js +0 -224
- 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 -372
- 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 -284
- 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 -27
- 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 -25
- package/dist/workspace/LangiumDocuments.js +0 -98
- package/dist/workspace/ProjectsManager.d.ts +0 -130
- package/dist/workspace/ProjectsManager.js +0 -605
- 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,133 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
//
|
|
3
|
-
// Copyright (c) 2023-2025 Denis Davydkov
|
|
4
|
-
// Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
5
|
-
//
|
|
6
|
-
// Portions of this file have been modified by NVIDIA CORPORATION & AFFILIATES.
|
|
7
|
-
import { DefaultWeakMap, invariant, MultiMap } from '@likec4/core/utils';
|
|
8
|
-
import { DocumentState, UriUtils } from 'langium';
|
|
9
|
-
import { pipe } from 'remeda';
|
|
10
|
-
import { DiagnosticSeverity } from 'vscode-languageserver-types';
|
|
11
|
-
import { isLikeC4LangiumDocument } from '../ast';
|
|
12
|
-
import { logger as rootLogger, logWarnError } from '../logger';
|
|
13
|
-
import { BaseParser } from './parser/Base';
|
|
14
|
-
import { DeploymentModelParser } from './parser/DeploymentModelParser';
|
|
15
|
-
import { DeploymentViewParser } from './parser/DeploymentViewParser';
|
|
16
|
-
import { ExpressionV2Parser } from './parser/FqnRefParser';
|
|
17
|
-
import { GlobalsParser } from './parser/GlobalsParser';
|
|
18
|
-
import { ImportsParser } from './parser/ImportsParser';
|
|
19
|
-
import { ModelParser } from './parser/ModelParser';
|
|
20
|
-
import { PredicatesParser } from './parser/PredicatesParser';
|
|
21
|
-
import { SpecificationParser } from './parser/SpecificationParser';
|
|
22
|
-
import { ViewsParser } from './parser/ViewsParser';
|
|
23
|
-
const DocumentParserFromMixins = pipe(BaseParser, ExpressionV2Parser, ImportsParser, ModelParser, DeploymentModelParser, DeploymentViewParser, PredicatesParser, SpecificationParser, ViewsParser, GlobalsParser);
|
|
24
|
-
export class DocumentParser extends DocumentParserFromMixins {
|
|
25
|
-
}
|
|
26
|
-
const logger = rootLogger.getChild('ModelParser');
|
|
27
|
-
export class LikeC4ModelParser {
|
|
28
|
-
services;
|
|
29
|
-
cachedParsers = new DefaultWeakMap((doc) => this.createParser(doc));
|
|
30
|
-
constructor(services) {
|
|
31
|
-
this.services = services;
|
|
32
|
-
services.shared.workspace.DocumentBuilder.onDocumentPhase(DocumentState.Linked, async (doc) => {
|
|
33
|
-
if (this.cachedParsers.has(doc)) {
|
|
34
|
-
logger.trace('Linked: clear cached parser {projectId} document {doc}', {
|
|
35
|
-
projectId: doc.likec4ProjectId,
|
|
36
|
-
doc: UriUtils.basename(doc.uri),
|
|
37
|
-
});
|
|
38
|
-
this.cachedParsers.delete(doc);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
services.shared.workspace.DocumentBuilder.onBuildPhase(DocumentState.Linked, async (docs) => {
|
|
42
|
-
for (const doc of docs) {
|
|
43
|
-
if (services.shared.workspace.ProjectsManager.isExcluded(doc)) {
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
// Force create parser for linked document (if not yet created)
|
|
48
|
-
this.parse(doc);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
logWarnError(error);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
// We need to clean up cached parser when document is validated and has errors
|
|
56
|
-
// Because after that parser takes into account validation results
|
|
57
|
-
services.shared.workspace.DocumentBuilder.onDocumentPhase(DocumentState.Validated, async (doc) => {
|
|
58
|
-
if (doc.diagnostics?.some(d => d.severity === DiagnosticSeverity.Error) && this.cachedParsers.has(doc)) {
|
|
59
|
-
logger.trace('Validated: clear cached parser {projectId} document {doc} because of errors', {
|
|
60
|
-
projectId: doc.likec4ProjectId,
|
|
61
|
-
doc: UriUtils.basename(doc.uri),
|
|
62
|
-
});
|
|
63
|
-
this.cachedParsers.delete(doc);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
documents(projectId) {
|
|
68
|
-
return this.services.shared.workspace.LangiumDocuments.projectDocuments(projectId).map(d => this.parse(d));
|
|
69
|
-
}
|
|
70
|
-
parse(doc) {
|
|
71
|
-
const parser = this.forDocument(doc);
|
|
72
|
-
return parser.doc;
|
|
73
|
-
}
|
|
74
|
-
forDocument(doc) {
|
|
75
|
-
return this.cachedParsers.get(doc);
|
|
76
|
-
}
|
|
77
|
-
createParser(doc) {
|
|
78
|
-
invariant(isLikeC4LangiumDocument(doc), `Document ${doc.uri.toString()} is not a LikeC4 document`);
|
|
79
|
-
const docbasename = UriUtils.basename(doc.uri);
|
|
80
|
-
if (doc.likec4ProjectId) {
|
|
81
|
-
logger.trace(`create parser {projectId} document {doc}`, {
|
|
82
|
-
projectId: doc.likec4ProjectId,
|
|
83
|
-
doc: docbasename,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
logger.warn(`create parser for document without project {doc}`, { doc: doc.uri.fsPath });
|
|
88
|
-
}
|
|
89
|
-
if (doc.state < DocumentState.Linked) {
|
|
90
|
-
logger.warn(`Document {doc} is not linked, state is {state}`, {
|
|
91
|
-
doc: docbasename,
|
|
92
|
-
state: doc.state,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
const props = {
|
|
96
|
-
c4Specification: {
|
|
97
|
-
tags: {},
|
|
98
|
-
elements: {},
|
|
99
|
-
relationships: {},
|
|
100
|
-
colors: {},
|
|
101
|
-
deployments: {},
|
|
102
|
-
},
|
|
103
|
-
c4Elements: [],
|
|
104
|
-
c4ExtendElements: [],
|
|
105
|
-
c4ExtendDeployments: [],
|
|
106
|
-
c4ExtendRelations: [],
|
|
107
|
-
c4Relations: [],
|
|
108
|
-
c4Deployments: [],
|
|
109
|
-
c4DeploymentRelations: [],
|
|
110
|
-
c4Globals: {
|
|
111
|
-
predicates: {},
|
|
112
|
-
dynamicPredicates: {},
|
|
113
|
-
styles: {},
|
|
114
|
-
},
|
|
115
|
-
c4Views: [],
|
|
116
|
-
c4Imports: new MultiMap(Set),
|
|
117
|
-
};
|
|
118
|
-
doc = Object.assign(doc, props);
|
|
119
|
-
const parser = new DocumentParser(this.services, doc);
|
|
120
|
-
try {
|
|
121
|
-
parser.parseSpecification();
|
|
122
|
-
parser.parseImports();
|
|
123
|
-
parser.parseModel();
|
|
124
|
-
parser.parseGlobals();
|
|
125
|
-
parser.parseDeployment();
|
|
126
|
-
parser.parseViews();
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
throw new Error(`Error parsing document ${doc.uri.fsPath}`, { cause: error });
|
|
130
|
-
}
|
|
131
|
-
return parser;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type * as c4 from '@likec4/core';
|
|
2
|
-
import { type MarkdownOrString } from '@likec4/core';
|
|
3
|
-
import type { AstNode } from 'langium';
|
|
4
|
-
import { type ParsedElementStyle, type ParsedLikeC4LangiumDocument, ast } from '../../ast';
|
|
5
|
-
import type { LikeC4Services } from '../../module';
|
|
6
|
-
import { type IsValidFn } from '../../validation';
|
|
7
|
-
import type { Project } from '../../workspace/ProjectsManager';
|
|
8
|
-
export type GConstructor<T = {}> = new (...args: any[]) => T;
|
|
9
|
-
export declare function toSingleLine(str: string): string;
|
|
10
|
-
export declare function toSingleLine(str: string | undefined | null): string | undefined;
|
|
11
|
-
export declare function toSingleLine(str: ast.MarkdownOrString): MarkdownOrString;
|
|
12
|
-
export declare function toSingleLine(str: ast.MarkdownOrString | undefined | null): MarkdownOrString | undefined;
|
|
13
|
-
export declare function toSingleLine(str: ast.MarkdownOrString | string): MarkdownOrString | string;
|
|
14
|
-
export declare function toSingleLine(str: ast.MarkdownOrString | string | undefined | null): MarkdownOrString | string | undefined;
|
|
15
|
-
export declare function removeIndent(str: string): string;
|
|
16
|
-
export declare function removeIndent(str: string | undefined): string | undefined;
|
|
17
|
-
export declare function removeIndent(str: ast.MarkdownOrString): MarkdownOrString;
|
|
18
|
-
export declare function removeIndent(str: ast.MarkdownOrString | undefined): MarkdownOrString | undefined;
|
|
19
|
-
export declare function removeIndent(str: ast.MarkdownOrString | string): MarkdownOrString | string;
|
|
20
|
-
export type Base = GConstructor<BaseParser>;
|
|
21
|
-
export declare class BaseParser {
|
|
22
|
-
readonly services: LikeC4Services;
|
|
23
|
-
readonly doc: ParsedLikeC4LangiumDocument;
|
|
24
|
-
isValid: IsValidFn;
|
|
25
|
-
constructor(services: LikeC4Services, doc: ParsedLikeC4LangiumDocument);
|
|
26
|
-
get project(): Project;
|
|
27
|
-
resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
|
|
28
|
-
getAstNodePath(node: AstNode): string;
|
|
29
|
-
getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
|
|
30
|
-
[key: string]: string | string[];
|
|
31
|
-
} | undefined;
|
|
32
|
-
parseMarkdownOrString(markdownOrString: ast.MarkdownOrString | undefined): c4.MarkdownOrString | undefined;
|
|
33
|
-
convertTags<E extends {
|
|
34
|
-
tags?: ast.Tags;
|
|
35
|
-
}>(withTags?: E): c4.NonEmptyArray<c4.Tag<string>> | null;
|
|
36
|
-
parseTags<E extends {
|
|
37
|
-
tags?: ast.Tags;
|
|
38
|
-
}>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
|
|
39
|
-
convertLinks(source?: ast.LinkProperty['$container']): c4.Link[] | undefined;
|
|
40
|
-
parseLinks(source?: ast.LinkProperty['$container']): c4.Link[] | undefined;
|
|
41
|
-
parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
|
|
42
|
-
parseImageAlias(value: string): string | undefined;
|
|
43
|
-
parseColorLiteral(astNode: ast.ColorLiteral): c4.ColorLiteral | undefined;
|
|
44
|
-
parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): ParsedElementStyle;
|
|
45
|
-
parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): ParsedElementStyle;
|
|
46
|
-
/**
|
|
47
|
-
* Parse base properties: title, description and technology
|
|
48
|
-
*
|
|
49
|
-
* @param props - body properties (inside '{...}')
|
|
50
|
-
* @param override - optional, inline properties (right on the node)
|
|
51
|
-
* have higher priority and override body properties
|
|
52
|
-
*/
|
|
53
|
-
parseBaseProps(props: {
|
|
54
|
-
title?: ast.MarkdownOrString | undefined;
|
|
55
|
-
summary?: ast.MarkdownOrString | undefined;
|
|
56
|
-
description?: ast.MarkdownOrString | undefined;
|
|
57
|
-
technology?: ast.MarkdownOrString | undefined;
|
|
58
|
-
}, override?: {
|
|
59
|
-
title?: string | undefined;
|
|
60
|
-
summary?: string | undefined;
|
|
61
|
-
description?: string | undefined;
|
|
62
|
-
technology?: string | undefined;
|
|
63
|
-
}): {
|
|
64
|
-
title?: string;
|
|
65
|
-
summary?: c4.MarkdownOrString;
|
|
66
|
-
description?: c4.MarkdownOrString;
|
|
67
|
-
technology?: string;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
@@ -1,372 +0,0 @@
|
|
|
1
|
-
import { exact, GlobalFqn, isNonEmptyArray, memoizeProp, nonexhaustive, nonNullable, } from '@likec4/core';
|
|
2
|
-
import { filter, flatMap, groupBy, isArray, isBoolean, isEmpty, isNumber, isString, isTruthy, mapValues, pipe, unique, } from 'remeda';
|
|
3
|
-
import { dedent } from 'strip-indent';
|
|
4
|
-
import { hasLeadingSlash, hasProtocol, isRelative, joinRelativeURL, joinURL } from 'ufo';
|
|
5
|
-
import { ast, parseAstOpacityProperty, parseAstPercent, parseAstSizeValue, parseMarkdownAsString, toColor, } from '../../ast';
|
|
6
|
-
import { serverLogger } from '../../logger';
|
|
7
|
-
import { projectIdFrom } from '../../utils';
|
|
8
|
-
import { readStrictFqn } from '../../utils/elementRef';
|
|
9
|
-
import { checksFromDiagnostics } from '../../validation';
|
|
10
|
-
const logger = serverLogger.getChild('BaseParser');
|
|
11
|
-
export function toSingleLine(str) {
|
|
12
|
-
if (str === null || str === undefined) {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
const without = removeIndent(str);
|
|
16
|
-
if (isString(without)) {
|
|
17
|
-
return without.split('\n').join(' ');
|
|
18
|
-
}
|
|
19
|
-
if ('md' in without) {
|
|
20
|
-
return {
|
|
21
|
-
md: without.md.split('\n').join(' '),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
txt: without.txt.split('\n').join(' '),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
// export function removeIndent(str: ast.MarkdownOrString | string): MarkdownOrString | string
|
|
29
|
-
export function removeIndent(str) {
|
|
30
|
-
if (str === null || str === undefined) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
switch (true) {
|
|
34
|
-
case isString(str):
|
|
35
|
-
return dedent(str).trim();
|
|
36
|
-
case ast.isMarkdownOrString(str) && isTruthy(str.markdown):
|
|
37
|
-
return {
|
|
38
|
-
md: dedent(str.markdown).trim(),
|
|
39
|
-
};
|
|
40
|
-
case ast.isMarkdownOrString(str) && isTruthy(str.text):
|
|
41
|
-
return {
|
|
42
|
-
txt: dedent(str.text).trim(),
|
|
43
|
-
};
|
|
44
|
-
default:
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export class BaseParser {
|
|
49
|
-
services;
|
|
50
|
-
doc;
|
|
51
|
-
isValid;
|
|
52
|
-
constructor(services, doc) {
|
|
53
|
-
this.services = services;
|
|
54
|
-
this.doc = doc;
|
|
55
|
-
// do nothing
|
|
56
|
-
this.isValid = checksFromDiagnostics(doc).isValid;
|
|
57
|
-
}
|
|
58
|
-
get project() {
|
|
59
|
-
return memoizeProp(this, 'project', () => this.services.shared.workspace.ProjectsManager.getProject(this.doc));
|
|
60
|
-
}
|
|
61
|
-
resolveFqn(node) {
|
|
62
|
-
if (ast.isImported(node)) {
|
|
63
|
-
const project = projectIdFrom(node);
|
|
64
|
-
const fqn = this.resolveFqn(nonNullable(node.imported.ref, `FqnRef is empty of imported: ${node.$cstNode?.text}`));
|
|
65
|
-
this.doc.c4Imports.set(project, fqn);
|
|
66
|
-
return GlobalFqn(project, fqn);
|
|
67
|
-
}
|
|
68
|
-
if (ast.isExtendElement(node)) {
|
|
69
|
-
return readStrictFqn(node.element);
|
|
70
|
-
}
|
|
71
|
-
if (ast.isExtendDeployment(node)) {
|
|
72
|
-
return readStrictFqn(node.deploymentNode);
|
|
73
|
-
}
|
|
74
|
-
if (ast.isDeploymentElement(node)) {
|
|
75
|
-
return this.services.likec4.DeploymentsIndex.getFqn(node);
|
|
76
|
-
}
|
|
77
|
-
return this.services.likec4.FqnIndex.getFqn(node);
|
|
78
|
-
}
|
|
79
|
-
getAstNodePath(node) {
|
|
80
|
-
return this.services.workspace.AstNodeLocator.getAstNodePath(node);
|
|
81
|
-
}
|
|
82
|
-
getMetadata(metadataAstNode) {
|
|
83
|
-
if (!metadataAstNode || !this.isValid(metadataAstNode) || isEmpty(metadataAstNode.props)) {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
// Helper function to extract string values from MetadataValue
|
|
87
|
-
const extractValues = (value) => {
|
|
88
|
-
if (ast.isMarkdownOrString(value)) {
|
|
89
|
-
const mdOrStr = removeIndent(value);
|
|
90
|
-
if (!mdOrStr)
|
|
91
|
-
return [];
|
|
92
|
-
// Handle both string and MarkdownOrString types
|
|
93
|
-
if (typeof mdOrStr === 'string') {
|
|
94
|
-
return isTruthy(mdOrStr) ? [mdOrStr] : [];
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
// MarkdownOrString object with txt or md property
|
|
98
|
-
const strValue = mdOrStr.md || mdOrStr.txt;
|
|
99
|
-
return isTruthy(strValue) ? [strValue] : [];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else if (ast.isMetadataArray(value)) {
|
|
103
|
-
return value.values
|
|
104
|
-
.map(v => removeIndent(v))
|
|
105
|
-
.map(v => {
|
|
106
|
-
if (typeof v === 'string') {
|
|
107
|
-
return v;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
// MarkdownOrString object
|
|
111
|
-
return v.md || v.txt;
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
.filter(isTruthy);
|
|
115
|
-
}
|
|
116
|
-
return [];
|
|
117
|
-
};
|
|
118
|
-
// Transform metadata attributes into key-value pairs
|
|
119
|
-
const keyValuePairs = pipe(metadataAstNode.props, flatMap(p => extractValues(p.value).map(v => [p.key, v])), filter(([_, value]) => isTruthy(value)));
|
|
120
|
-
if (isEmpty(keyValuePairs)) {
|
|
121
|
-
return undefined;
|
|
122
|
-
}
|
|
123
|
-
// Group by key to handle duplicate keys
|
|
124
|
-
const groupedData = pipe(keyValuePairs, groupBy(([key]) => key), mapValues(pairs => pairs.map(([_, value]) => value)));
|
|
125
|
-
// Convert to final format: single values as string, multiple values as string[]
|
|
126
|
-
const data = {};
|
|
127
|
-
for (const [key, values] of Object.entries(groupedData)) {
|
|
128
|
-
if (values && values.length > 0) {
|
|
129
|
-
data[key] = values.length === 1 ? values[0] : values;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return isEmpty(data) ? undefined : data;
|
|
133
|
-
}
|
|
134
|
-
parseMarkdownOrString(markdownOrString) {
|
|
135
|
-
if (ast.isMarkdownOrString(markdownOrString)) {
|
|
136
|
-
return removeIndent(markdownOrString);
|
|
137
|
-
}
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
140
|
-
convertTags(withTags) {
|
|
141
|
-
return this.parseTags(withTags);
|
|
142
|
-
}
|
|
143
|
-
parseTags(withTags) {
|
|
144
|
-
let iter = withTags?.tags;
|
|
145
|
-
if (!iter) {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
let tags = [];
|
|
149
|
-
while (iter) {
|
|
150
|
-
try {
|
|
151
|
-
if (this.isValid(iter)) {
|
|
152
|
-
const values = iter.values.map(t => t.tag.ref?.name).filter(isTruthy);
|
|
153
|
-
if (values.length > 0) {
|
|
154
|
-
tags.push(...values);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
catch {
|
|
159
|
-
// ignore
|
|
160
|
-
}
|
|
161
|
-
iter = iter.prev;
|
|
162
|
-
}
|
|
163
|
-
return isNonEmptyArray(tags) ? unique(tags) : null;
|
|
164
|
-
}
|
|
165
|
-
convertLinks(source) {
|
|
166
|
-
return this.parseLinks(source);
|
|
167
|
-
}
|
|
168
|
-
parseLinks(source) {
|
|
169
|
-
if (!source?.props || source.props.length === 0) {
|
|
170
|
-
return undefined;
|
|
171
|
-
}
|
|
172
|
-
return pipe(source.props, filter(ast.isLinkProperty), flatMap(p => {
|
|
173
|
-
if (!this.isValid(p)) {
|
|
174
|
-
return [];
|
|
175
|
-
}
|
|
176
|
-
const url = p.value;
|
|
177
|
-
if (isTruthy(url)) {
|
|
178
|
-
const title = isTruthy(p.title) ? toSingleLine(p.title) : undefined;
|
|
179
|
-
const relative = this.services.lsp.DocumentLinkProvider.relativeLink(this.doc, url);
|
|
180
|
-
return {
|
|
181
|
-
url,
|
|
182
|
-
...(title && { title }),
|
|
183
|
-
...(relative && relative !== url && { relative }),
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
return [];
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
parseIconProperty(prop) {
|
|
190
|
-
if (!prop || !this.isValid(prop)) {
|
|
191
|
-
return undefined;
|
|
192
|
-
}
|
|
193
|
-
const { libicon, value } = prop;
|
|
194
|
-
switch (true) {
|
|
195
|
-
case !!libicon: {
|
|
196
|
-
return nonNullable(libicon.ref, `Library icon ${libicon.$refText} has empty ref`).name;
|
|
197
|
-
}
|
|
198
|
-
case value && value === 'none': {
|
|
199
|
-
return value;
|
|
200
|
-
}
|
|
201
|
-
case value && hasProtocol(value): {
|
|
202
|
-
if (value.startsWith('file:')) {
|
|
203
|
-
logger.warn(`Icon property '${value}' used the 'file' protocol which is not supported`);
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
return value;
|
|
207
|
-
}
|
|
208
|
-
case value && value.startsWith('@'): {
|
|
209
|
-
return this.parseImageAlias(value);
|
|
210
|
-
}
|
|
211
|
-
case value && isRelative(value): {
|
|
212
|
-
return joinRelativeURL(this.doc.uri.toString(), '../', value);
|
|
213
|
-
}
|
|
214
|
-
case value && hasLeadingSlash(value): {
|
|
215
|
-
return joinURL(this.project.folderUri.toString(), value);
|
|
216
|
-
}
|
|
217
|
-
default: {
|
|
218
|
-
logger.warn(`Icon property '${value}' is not a valid URL, library icon, image alias or 'none'`);
|
|
219
|
-
return undefined;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
parseImageAlias(value) {
|
|
224
|
-
// Extract the alias name (e.g., '@infra' from '@infra/backend.svg')
|
|
225
|
-
const slashIndex = value.indexOf('/');
|
|
226
|
-
const aliasName = slashIndex > 0 ? value.substring(0, slashIndex) : value;
|
|
227
|
-
const remainingPath = slashIndex > 0 ? value.substring(slashIndex + 1) : '';
|
|
228
|
-
// Get imageAliases from project config, or use default '@' -> './images' mapping
|
|
229
|
-
const imageAliases = { '@': './images', ...this.project.config.imageAliases };
|
|
230
|
-
// Look up the alias path
|
|
231
|
-
const aliasPath = imageAliases[aliasName];
|
|
232
|
-
if (!aliasPath) {
|
|
233
|
-
logger.warn(`Image alias "${aliasName}" not found in project configuration`);
|
|
234
|
-
return undefined;
|
|
235
|
-
}
|
|
236
|
-
// Combine the alias path with the remaining path
|
|
237
|
-
const fullPath = remainingPath ? joinURL(aliasPath, remainingPath) : aliasPath;
|
|
238
|
-
// Make it relative to the **project root**, not the current document.
|
|
239
|
-
return joinURL(this.project.folderUri.toString(), fullPath);
|
|
240
|
-
}
|
|
241
|
-
parseColorLiteral(astNode) {
|
|
242
|
-
if (!this.isValid(astNode)) {
|
|
243
|
-
return undefined;
|
|
244
|
-
}
|
|
245
|
-
if (ast.isHexColor(astNode)) {
|
|
246
|
-
return `#${astNode.hex}`;
|
|
247
|
-
}
|
|
248
|
-
if (ast.isRGBAColor(astNode)) {
|
|
249
|
-
let alpha = isNumber(astNode.alpha) ? astNode.alpha : undefined;
|
|
250
|
-
if (isString(astNode.alpha)) {
|
|
251
|
-
alpha = parseAstPercent(astNode.alpha) / 100;
|
|
252
|
-
}
|
|
253
|
-
if (alpha !== undefined) {
|
|
254
|
-
return `rgba(${astNode.red},${astNode.green},${astNode.blue},${alpha})`;
|
|
255
|
-
}
|
|
256
|
-
return `rgb(${astNode.red},${astNode.green},${astNode.blue})`;
|
|
257
|
-
}
|
|
258
|
-
nonexhaustive(astNode);
|
|
259
|
-
}
|
|
260
|
-
parseElementStyle(elementProps) {
|
|
261
|
-
if (!elementProps) {
|
|
262
|
-
return {};
|
|
263
|
-
}
|
|
264
|
-
if (isArray(elementProps)) {
|
|
265
|
-
const style = this.parseStyleProps(elementProps.find(ast.isElementStyleProperty)?.props);
|
|
266
|
-
// Property on element has higher priority than from style
|
|
267
|
-
try {
|
|
268
|
-
const iconProp = this.parseIconProperty(elementProps.find(ast.isIconProperty));
|
|
269
|
-
if (iconProp) {
|
|
270
|
-
style.icon = iconProp;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
catch (err) {
|
|
274
|
-
logger.warn('Failed to parse icon property on element', { err });
|
|
275
|
-
}
|
|
276
|
-
return style;
|
|
277
|
-
}
|
|
278
|
-
return this.parseStyleProps(elementProps.props);
|
|
279
|
-
}
|
|
280
|
-
parseStyleProps(styleProps) {
|
|
281
|
-
const result = {};
|
|
282
|
-
if (!styleProps || styleProps.length === 0) {
|
|
283
|
-
return result;
|
|
284
|
-
}
|
|
285
|
-
for (const prop of styleProps) {
|
|
286
|
-
if (!this.isValid(prop)) {
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
switch (true) {
|
|
290
|
-
case ast.isBorderProperty(prop): {
|
|
291
|
-
if (isTruthy(prop.value)) {
|
|
292
|
-
result.border = prop.value;
|
|
293
|
-
}
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
case ast.isColorProperty(prop): {
|
|
297
|
-
const color = toColor(prop);
|
|
298
|
-
if (isTruthy(color)) {
|
|
299
|
-
result.color = color;
|
|
300
|
-
}
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
case ast.isShapeProperty(prop): {
|
|
304
|
-
if (isTruthy(prop.value)) {
|
|
305
|
-
result.shape = prop.value;
|
|
306
|
-
}
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
case ast.isIconProperty(prop): {
|
|
310
|
-
const icon = this.parseIconProperty(prop);
|
|
311
|
-
if (isTruthy(icon)) {
|
|
312
|
-
result.icon = icon;
|
|
313
|
-
}
|
|
314
|
-
break;
|
|
315
|
-
}
|
|
316
|
-
case ast.isOpacityProperty(prop): {
|
|
317
|
-
result.opacity = parseAstOpacityProperty(prop);
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
case ast.isMultipleProperty(prop): {
|
|
321
|
-
result.multiple = isBoolean(prop.value) ? prop.value : false;
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
case ast.isShapeSizeProperty(prop): {
|
|
325
|
-
if (isTruthy(prop.value)) {
|
|
326
|
-
result.size = parseAstSizeValue(prop);
|
|
327
|
-
}
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
case ast.isPaddingSizeProperty(prop): {
|
|
331
|
-
if (isTruthy(prop.value)) {
|
|
332
|
-
result.padding = parseAstSizeValue(prop);
|
|
333
|
-
}
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
case ast.isTextSizeProperty(prop): {
|
|
337
|
-
if (isTruthy(prop.value)) {
|
|
338
|
-
result.textSize = parseAstSizeValue(prop);
|
|
339
|
-
}
|
|
340
|
-
break;
|
|
341
|
-
}
|
|
342
|
-
default:
|
|
343
|
-
nonexhaustive(prop);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return exact(result);
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Parse base properties: title, description and technology
|
|
350
|
-
*
|
|
351
|
-
* @param props - body properties (inside '{...}')
|
|
352
|
-
* @param override - optional, inline properties (right on the node)
|
|
353
|
-
* have higher priority and override body properties
|
|
354
|
-
*/
|
|
355
|
-
parseBaseProps(props, override) {
|
|
356
|
-
const title = removeIndent(override?.title ?? parseMarkdownAsString(props.title));
|
|
357
|
-
const description = override?.description
|
|
358
|
-
? { txt: removeIndent(override.description) }
|
|
359
|
-
: this.parseMarkdownOrString(props.description);
|
|
360
|
-
const summary = override?.summary
|
|
361
|
-
? { txt: removeIndent(override.summary) }
|
|
362
|
-
: this.parseMarkdownOrString(props.summary);
|
|
363
|
-
const technology = toSingleLine(override?.technology) ??
|
|
364
|
-
removeIndent(parseMarkdownAsString(props.technology));
|
|
365
|
-
return exact({
|
|
366
|
-
title,
|
|
367
|
-
summary,
|
|
368
|
-
description,
|
|
369
|
-
technology,
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type * as c4 from '@likec4/core';
|
|
2
|
-
import { FqnRef } from '@likec4/core';
|
|
3
|
-
import { type ParsedAstDeployment, type ParsedAstDeploymentRelation, type ParsedAstExtend, ast } from '../../ast';
|
|
4
|
-
import type { WithExpressionV2 } from './FqnRefParser';
|
|
5
|
-
export type WithDeploymentModel = ReturnType<typeof DeploymentModelParser>;
|
|
6
|
-
export declare function DeploymentModelParser<TBase extends WithExpressionV2>(B: TBase): {
|
|
7
|
-
new (...args: any[]): {
|
|
8
|
-
parseDeployment(): void;
|
|
9
|
-
parseDeploymentNode(astNode: ast.DeploymentNode): ParsedAstDeployment.Node;
|
|
10
|
-
parseDeployedInstance(astNode: ast.DeployedInstance): ParsedAstDeployment.Instance;
|
|
11
|
-
parseExtendDeployment(astNode: ast.ExtendDeployment): ParsedAstExtend | null;
|
|
12
|
-
_resolveDeploymentRelationSource(node: ast.DeploymentRelation): FqnRef;
|
|
13
|
-
parseDeploymentRelation(astNode: ast.DeploymentRelation): ParsedAstDeploymentRelation;
|
|
14
|
-
parseFqnRef(astNode: ast.FqnRef): c4.FqnRef;
|
|
15
|
-
parseExpressionV2(astNode: ast.ExpressionV2): c4.Expression;
|
|
16
|
-
parseFqnExprOrWith(astNode: ast.FqnExprOrWith): c4.FqnExpr.Any;
|
|
17
|
-
parseFqnExprWith(astNode: ast.FqnExprWith): c4.FqnExpr.Custom;
|
|
18
|
-
parseFqnExprOrWhere(astNode: ast.FqnExprOrWhere): c4.FqnExpr.OrWhere;
|
|
19
|
-
parseFqnExprWhere(astNode: ast.FqnExprWhere): c4.FqnExpr.Where;
|
|
20
|
-
parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
|
|
21
|
-
parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
|
|
22
|
-
parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
|
|
23
|
-
parseRelationExprOrWith(astNode: ast.RelationExprOrWith): c4.RelationExpr.Any;
|
|
24
|
-
parseRelationExprWith(astNode: ast.RelationExprWith): c4.RelationExpr.Custom;
|
|
25
|
-
parseCustomRelationProperties(custom: ast.CustomRelationProperties | undefined): import("type-fest").Except<c4.RelationExpr.Custom["customRelation"], "expr">;
|
|
26
|
-
parseRelationExprOrWhere(astNode: ast.RelationExprOrWhere): c4.RelationExpr.OrWhere;
|
|
27
|
-
parseRelationExprWhere(astNode: ast.RelationExprWhere): c4.RelationExpr.Where;
|
|
28
|
-
parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr.OrWhere;
|
|
29
|
-
parseInlineKindCondition(astNode: ast.OutgoingRelationExpr): c4.WhereOperator | null;
|
|
30
|
-
wrapInWhere(expr: c4.RelationExpr, condition: c4.WhereOperator | null): c4.RelationExpr.OrWhere;
|
|
31
|
-
isValid: import("../../validation").IsValidFn;
|
|
32
|
-
readonly services: import("../..").LikeC4Services;
|
|
33
|
-
readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
|
|
34
|
-
get project(): import("../../workspace").Project;
|
|
35
|
-
resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
|
|
36
|
-
getAstNodePath(node: import("langium").AstNode): string;
|
|
37
|
-
getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
|
|
38
|
-
[key: string]: string | string[];
|
|
39
|
-
} | undefined;
|
|
40
|
-
parseMarkdownOrString(markdownOrString: ast.MarkdownOrString | undefined): c4.MarkdownOrString | undefined;
|
|
41
|
-
convertTags<E extends {
|
|
42
|
-
tags?: ast.Tags;
|
|
43
|
-
}>(withTags?: E | undefined): c4.NonEmptyArray<c4.Tag<string>> | null;
|
|
44
|
-
parseTags<E extends {
|
|
45
|
-
tags?: ast.Tags;
|
|
46
|
-
}>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
|
|
47
|
-
convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
|
|
48
|
-
parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
|
|
49
|
-
parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
|
|
50
|
-
parseImageAlias(value: string): string | undefined;
|
|
51
|
-
parseColorLiteral(astNode: ast.ColorLiteral): c4.ColorLiteral | undefined;
|
|
52
|
-
parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
|
|
53
|
-
parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
|
|
54
|
-
parseBaseProps(props: {
|
|
55
|
-
title?: ast.MarkdownOrString | undefined;
|
|
56
|
-
summary?: ast.MarkdownOrString | undefined;
|
|
57
|
-
description?: ast.MarkdownOrString | undefined;
|
|
58
|
-
technology?: ast.MarkdownOrString | undefined;
|
|
59
|
-
}, override?: {
|
|
60
|
-
title?: string | undefined;
|
|
61
|
-
summary?: string | undefined;
|
|
62
|
-
description?: string | undefined;
|
|
63
|
-
technology?: string | undefined;
|
|
64
|
-
}): {
|
|
65
|
-
title?: string;
|
|
66
|
-
summary?: c4.MarkdownOrString;
|
|
67
|
-
description?: c4.MarkdownOrString;
|
|
68
|
-
technology?: string;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
} & TBase;
|