@likec4/language-server 1.43.0 → 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 +5 -1
- 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 +3542 -3896
- 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.js +2155 -0
- package/dist/generated/{grammar.mjs → grammar.js} +6 -2
- 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.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.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 +309 -304
- package/dist/model/model-parser.js +119 -0
- package/dist/model/parser/Base.d.ts +2 -2
- package/dist/model/parser/Base.js +367 -0
- package/dist/model/parser/DeploymentModelParser.d.ts +2 -2
- package/dist/model/parser/DeploymentModelParser.js +176 -0
- package/dist/model/parser/DeploymentViewParser.d.ts +3 -3
- package/dist/model/parser/DeploymentViewParser.js +86 -0
- package/dist/model/parser/FqnRefParser.d.ts +2 -2
- package/dist/model/parser/FqnRefParser.js +382 -0
- package/dist/model/parser/GlobalsParser.d.ts +6 -6
- package/dist/model/parser/GlobalsParser.js +84 -0
- package/dist/model/parser/ImportsParser.d.ts +11 -12
- package/dist/model/parser/ImportsParser.js +24 -0
- package/dist/model/parser/ModelParser.d.ts +2 -2
- package/dist/model/parser/ModelParser.js +165 -0
- package/dist/model/parser/PredicatesParser.d.ts +2 -2
- package/dist/model/parser/PredicatesParser.js +45 -0
- package/dist/model/parser/SpecificationParser.d.ts +2 -2
- package/dist/model/parser/SpecificationParser.js +109 -0
- package/dist/model/parser/ValueConverter.js +12 -0
- package/dist/model/parser/ViewsParser.d.ts +3 -3
- 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 +25 -24
- 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 -2150
- 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 -276
- 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 -76
- 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 -376
- 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,7 +0,0 @@
|
|
|
1
|
-
import type * as c4 from '@likec4/core/types';
|
|
2
|
-
import type { ParsedAstSpecification } from '../../ast';
|
|
3
|
-
/**
|
|
4
|
-
* Colors are taken from the styles presets of the LikeC4
|
|
5
|
-
*/
|
|
6
|
-
export declare const radixColors: string[];
|
|
7
|
-
export declare function assignTagColors(tags: ParsedAstSpecification['tags']): Record<c4.Tag, c4.TagSpecification>;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { compareNatural, nonNullable } from "@likec4/core/utils";
|
|
2
|
-
import { concat, entries, isTruthy, map, pipe, prop, pullObject, sort } from "remeda";
|
|
3
|
-
export const radixColors = [
|
|
4
|
-
"tomato",
|
|
5
|
-
"grass",
|
|
6
|
-
"blue",
|
|
7
|
-
"ruby",
|
|
8
|
-
"orange",
|
|
9
|
-
"indigo",
|
|
10
|
-
"pink",
|
|
11
|
-
"teal",
|
|
12
|
-
"purple",
|
|
13
|
-
"amber",
|
|
14
|
-
"crimson",
|
|
15
|
-
"red",
|
|
16
|
-
"lime",
|
|
17
|
-
"yellow",
|
|
18
|
-
"violet"
|
|
19
|
-
];
|
|
20
|
-
export function assignTagColors(tags) {
|
|
21
|
-
const tagsWithColors = [];
|
|
22
|
-
const tagsWithoutColors = [];
|
|
23
|
-
for (const [tag, spec] of entries(tags)) {
|
|
24
|
-
if (isTruthy(spec.color)) {
|
|
25
|
-
tagsWithColors.push({
|
|
26
|
-
tag,
|
|
27
|
-
spec: {
|
|
28
|
-
color: spec.color
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
} else {
|
|
32
|
-
tagsWithoutColors.push(tag);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return pipe(
|
|
36
|
-
tagsWithoutColors,
|
|
37
|
-
sort(compareNatural),
|
|
38
|
-
map((tag, idx) => {
|
|
39
|
-
const color = nonNullable(radixColors[idx % radixColors.length]);
|
|
40
|
-
return {
|
|
41
|
-
tag,
|
|
42
|
-
spec: {
|
|
43
|
-
color
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}),
|
|
47
|
-
concat(tagsWithColors),
|
|
48
|
-
sort((a, b) => compareNatural(a.tag, b.tag)),
|
|
49
|
-
pullObject(prop("tag"), prop("spec"))
|
|
50
|
-
);
|
|
51
|
-
}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isDeploymentNode,
|
|
3
|
-
isGlobalFqn
|
|
4
|
-
} from "@likec4/core";
|
|
5
|
-
import { resolveRulesExtendedViews } from "@likec4/core/compute-view";
|
|
6
|
-
import { computeColorValues } from "@likec4/core/styles";
|
|
7
|
-
import { _stage, _type, exact, FqnRef, isExtendsElementView } from "@likec4/core/types";
|
|
8
|
-
import {
|
|
9
|
-
compareNatural,
|
|
10
|
-
parentFqn,
|
|
11
|
-
sortByFqnHierarchically
|
|
12
|
-
} from "@likec4/core/utils";
|
|
13
|
-
import { UriUtils } from "langium";
|
|
14
|
-
import {
|
|
15
|
-
filter,
|
|
16
|
-
flatMap,
|
|
17
|
-
forEach,
|
|
18
|
-
indexBy,
|
|
19
|
-
isDefined,
|
|
20
|
-
isNullish,
|
|
21
|
-
isTruthy,
|
|
22
|
-
keys,
|
|
23
|
-
map,
|
|
24
|
-
mapValues,
|
|
25
|
-
omitBy,
|
|
26
|
-
pipe,
|
|
27
|
-
prop,
|
|
28
|
-
reduce
|
|
29
|
-
} from "remeda";
|
|
30
|
-
import { logger } from "../../logger.mjs";
|
|
31
|
-
import { MergedExtends } from "./MergedExtends.mjs";
|
|
32
|
-
import { MergedSpecification } from "./MergedSpecification.mjs";
|
|
33
|
-
export function buildModelData(project, docs) {
|
|
34
|
-
const c4Specification = new MergedSpecification(docs);
|
|
35
|
-
const customColors = mapValues(
|
|
36
|
-
c4Specification.specs.colors,
|
|
37
|
-
(c) => computeColorValues(c.color)
|
|
38
|
-
);
|
|
39
|
-
const metadataKeys = /* @__PURE__ */ new Set();
|
|
40
|
-
const elementExtends = new MergedExtends();
|
|
41
|
-
const deploymentExtends = new MergedExtends();
|
|
42
|
-
const scanMetadataKeys = (obj) => {
|
|
43
|
-
if (obj?.metadata) {
|
|
44
|
-
keys(obj.metadata).forEach((key) => metadataKeys.add(key));
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const elements = pipe(
|
|
48
|
-
docs,
|
|
49
|
-
flatMap((d) => {
|
|
50
|
-
elementExtends.merge(d.c4ExtendElements);
|
|
51
|
-
return map(d.c4Elements, c4Specification.toModelElement);
|
|
52
|
-
}),
|
|
53
|
-
filter(isTruthy),
|
|
54
|
-
// sort from root elements to nested, so that parent is always present
|
|
55
|
-
// Import to preserve the order from the source
|
|
56
|
-
sortByFqnHierarchically,
|
|
57
|
-
reduce(
|
|
58
|
-
(acc, el) => {
|
|
59
|
-
const parent = parentFqn(el.id);
|
|
60
|
-
if (parent && isNullish(acc[parent])) {
|
|
61
|
-
logger.debug`No parent found for ${el.id}`;
|
|
62
|
-
return acc;
|
|
63
|
-
}
|
|
64
|
-
acc[el.id] = elementExtends.applyExtended(el);
|
|
65
|
-
scanMetadataKeys(acc[el.id]);
|
|
66
|
-
return acc;
|
|
67
|
-
},
|
|
68
|
-
{}
|
|
69
|
-
)
|
|
70
|
-
);
|
|
71
|
-
const relations = pipe(
|
|
72
|
-
docs,
|
|
73
|
-
flatMap((d) => map(d.c4Relations, c4Specification.toModelRelation)),
|
|
74
|
-
filter((rel) => {
|
|
75
|
-
if (!rel) return false;
|
|
76
|
-
const source = FqnRef.flatten(rel.source), target = FqnRef.flatten(rel.target);
|
|
77
|
-
if (isNullish(elements[source]) && !isGlobalFqn(source) || isNullish(elements[target]) && !isGlobalFqn(target)) {
|
|
78
|
-
logger.debug`Invalid relation ${rel.id}
|
|
79
|
-
source: ${source} resolved: ${!!elements[source]}
|
|
80
|
-
target: ${target} resolved: ${!!elements[target]}\n`;
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
}),
|
|
85
|
-
forEach(scanMetadataKeys),
|
|
86
|
-
indexBy(prop("id"))
|
|
87
|
-
);
|
|
88
|
-
const deploymentElements = pipe(
|
|
89
|
-
docs,
|
|
90
|
-
flatMap((d) => {
|
|
91
|
-
deploymentExtends.merge(d.c4ExtendDeployments);
|
|
92
|
-
return map(d.c4Deployments, c4Specification.toDeploymentElement);
|
|
93
|
-
}),
|
|
94
|
-
filter(isTruthy),
|
|
95
|
-
// sort from root elements to nested, so that parent is always present
|
|
96
|
-
// Import to preserve the order from the source
|
|
97
|
-
sortByFqnHierarchically,
|
|
98
|
-
reduce(
|
|
99
|
-
(acc, el) => {
|
|
100
|
-
const parent = parentFqn(el.id);
|
|
101
|
-
if (parent && isNullish(acc[parent])) {
|
|
102
|
-
logger.debug`No parent found for deployment element ${el.id}`;
|
|
103
|
-
return acc;
|
|
104
|
-
}
|
|
105
|
-
acc[el.id] = isDeploymentNode(el) ? deploymentExtends.applyExtended(el) : el;
|
|
106
|
-
scanMetadataKeys(acc[el.id]);
|
|
107
|
-
return acc;
|
|
108
|
-
},
|
|
109
|
-
{}
|
|
110
|
-
)
|
|
111
|
-
);
|
|
112
|
-
const deploymentRelations = pipe(
|
|
113
|
-
docs,
|
|
114
|
-
flatMap((d) => map(d.c4DeploymentRelations, c4Specification.toDeploymentRelation)),
|
|
115
|
-
filter((rel) => {
|
|
116
|
-
if (!rel) return false;
|
|
117
|
-
if (isNullish(deploymentElements[rel.source.deployment]) || isNullish(deploymentElements[rel.target.deployment])) {
|
|
118
|
-
logger.debug`Invalid deployment relation ${rel.id}
|
|
119
|
-
source: ${rel.source.deployment} resolved: ${!!deploymentElements[rel.source.deployment]}
|
|
120
|
-
target: ${rel.target.deployment} resolved: ${!!deploymentElements[rel.target.deployment]}\n`;
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
return true;
|
|
124
|
-
}),
|
|
125
|
-
reduce(
|
|
126
|
-
(acc, el) => {
|
|
127
|
-
if (isDefined(acc[el.id])) {
|
|
128
|
-
logger.debug`Duplicate deployment relation ${el.id}`;
|
|
129
|
-
return acc;
|
|
130
|
-
}
|
|
131
|
-
scanMetadataKeys(el);
|
|
132
|
-
acc[el.id] = el;
|
|
133
|
-
return acc;
|
|
134
|
-
},
|
|
135
|
-
{}
|
|
136
|
-
)
|
|
137
|
-
);
|
|
138
|
-
function toC4View(doc) {
|
|
139
|
-
const docUri = doc.uri.toString();
|
|
140
|
-
return (parsedAstView) => {
|
|
141
|
-
let {
|
|
142
|
-
id,
|
|
143
|
-
title,
|
|
144
|
-
description,
|
|
145
|
-
// ignore this property
|
|
146
|
-
astPath: _ignore,
|
|
147
|
-
// model should include discriminant __
|
|
148
|
-
...model
|
|
149
|
-
} = parsedAstView;
|
|
150
|
-
if (parsedAstView[_type] === "element" && isNullish(title) && "viewOf" in parsedAstView) {
|
|
151
|
-
title = elements[parsedAstView.viewOf]?.title ?? null;
|
|
152
|
-
}
|
|
153
|
-
if (isNullish(title) && id === "index") {
|
|
154
|
-
title = "Landscape view";
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
...omitBy(model, (v) => v === void 0),
|
|
158
|
-
[_stage]: "parsed",
|
|
159
|
-
sourcePath: UriUtils.relative(project.folderUri, docUri),
|
|
160
|
-
docUri,
|
|
161
|
-
description,
|
|
162
|
-
title,
|
|
163
|
-
id
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
const parsedViews = docs.flatMap((d) => map(d.c4Views, toC4View(d)));
|
|
168
|
-
if (!parsedViews.some((v) => v.id === "index")) {
|
|
169
|
-
parsedViews.unshift({
|
|
170
|
-
[_stage]: "parsed",
|
|
171
|
-
[_type]: "element",
|
|
172
|
-
id: "index",
|
|
173
|
-
title: "Landscape view",
|
|
174
|
-
description: null,
|
|
175
|
-
rules: [
|
|
176
|
-
{
|
|
177
|
-
include: [
|
|
178
|
-
{
|
|
179
|
-
wildcard: true
|
|
180
|
-
}
|
|
181
|
-
]
|
|
182
|
-
}
|
|
183
|
-
]
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
let views = pipe(
|
|
187
|
-
parsedViews,
|
|
188
|
-
indexBy(prop("id"))
|
|
189
|
-
);
|
|
190
|
-
if (parsedViews.some(isExtendsElementView)) {
|
|
191
|
-
views = resolveRulesExtendedViews(views);
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
data: {
|
|
195
|
-
[_stage]: "parsed",
|
|
196
|
-
projectId: project.id,
|
|
197
|
-
project: exact({
|
|
198
|
-
id: project.id,
|
|
199
|
-
title: project.config.title ?? project.config.name,
|
|
200
|
-
styles: project.config.styles
|
|
201
|
-
}),
|
|
202
|
-
specification: {
|
|
203
|
-
tags: c4Specification.tags,
|
|
204
|
-
elements: c4Specification.specs.elements,
|
|
205
|
-
relationships: mapValues(c4Specification.specs.relationships, ({ notation, technology, ...style }) => ({
|
|
206
|
-
...notation && { notation },
|
|
207
|
-
...technology && { technology },
|
|
208
|
-
style
|
|
209
|
-
})),
|
|
210
|
-
deployments: c4Specification.specs.deployments,
|
|
211
|
-
...metadataKeys.size > 0 && { metadataKeys: [...metadataKeys].sort(compareNatural) },
|
|
212
|
-
customColors
|
|
213
|
-
},
|
|
214
|
-
elements,
|
|
215
|
-
relations,
|
|
216
|
-
globals: c4Specification.globals,
|
|
217
|
-
views,
|
|
218
|
-
deployments: {
|
|
219
|
-
elements: deploymentElements,
|
|
220
|
-
relations: deploymentRelations
|
|
221
|
-
},
|
|
222
|
-
imports: {}
|
|
223
|
-
},
|
|
224
|
-
imports: c4Specification.imports
|
|
225
|
-
};
|
|
226
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { ancestorsFqn, Fqn } from "@likec4/core";
|
|
2
|
-
import { MultiMap } from "@likec4/core/utils";
|
|
3
|
-
import { isDefined, isTruthy } from "remeda";
|
|
4
|
-
import {
|
|
5
|
-
ast,
|
|
6
|
-
ElementOps
|
|
7
|
-
} from "../ast.mjs";
|
|
8
|
-
import { logWarnError } from "../logger.mjs";
|
|
9
|
-
import { readStrictFqn } from "../utils/elementRef.mjs";
|
|
10
|
-
import { DocumentFqnIndex, FqnIndex } from "./fqn-index.mjs";
|
|
11
|
-
export class DeploymentsIndex extends FqnIndex {
|
|
12
|
-
constructor(services) {
|
|
13
|
-
super(services, "deployments-index");
|
|
14
|
-
this.services = services;
|
|
15
|
-
this.Names = services.references.NameProvider;
|
|
16
|
-
}
|
|
17
|
-
Names;
|
|
18
|
-
createDocumentIndex(document) {
|
|
19
|
-
const rootNodes = document.parseResult.value.deployments.flatMap((m) => m.elements);
|
|
20
|
-
if (rootNodes.length === 0) {
|
|
21
|
-
return DocumentFqnIndex.EMPTY;
|
|
22
|
-
}
|
|
23
|
-
const projectId = document.likec4ProjectId ??= this.projects.belongsTo(document);
|
|
24
|
-
const root = new Array();
|
|
25
|
-
const children = new MultiMap();
|
|
26
|
-
const descendants = new MultiMap();
|
|
27
|
-
const byfqn = new MultiMap();
|
|
28
|
-
const Names = this.Names;
|
|
29
|
-
const Descriptions = this.services.workspace.AstNodeDescriptionProvider;
|
|
30
|
-
const createAndSaveDescription = (node, name, fqn) => {
|
|
31
|
-
const desc = {
|
|
32
|
-
...Descriptions.createDescription(node, name, document),
|
|
33
|
-
id: fqn,
|
|
34
|
-
likec4ProjectId: projectId
|
|
35
|
-
};
|
|
36
|
-
ElementOps.writeId(node, fqn);
|
|
37
|
-
byfqn.set(fqn, desc);
|
|
38
|
-
return desc;
|
|
39
|
-
};
|
|
40
|
-
const traverseNode = (node, parentFqn) => {
|
|
41
|
-
let thisFqn;
|
|
42
|
-
if (ast.isExtendDeployment(node)) {
|
|
43
|
-
thisFqn = readStrictFqn(node.deploymentNode);
|
|
44
|
-
} else {
|
|
45
|
-
const name = Names.getName(node);
|
|
46
|
-
if (!isTruthy(name)) {
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
thisFqn = Fqn(name, parentFqn);
|
|
50
|
-
const desc = createAndSaveDescription(node, name, thisFqn);
|
|
51
|
-
if (!parentFqn) {
|
|
52
|
-
root.push(desc);
|
|
53
|
-
} else {
|
|
54
|
-
children.set(parentFqn, desc);
|
|
55
|
-
}
|
|
56
|
-
if (ast.isDeployedInstance(node)) {
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
let _nested = [];
|
|
61
|
-
if (isDefined(node.body)) {
|
|
62
|
-
for (const child of node.body.elements) {
|
|
63
|
-
if (!ast.isDeploymentRelation(child)) {
|
|
64
|
-
try {
|
|
65
|
-
_nested.push(...traverseNode(child, thisFqn));
|
|
66
|
-
} catch (e) {
|
|
67
|
-
logWarnError(e);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
_nested = [
|
|
73
|
-
...children.get(thisFqn) ?? [],
|
|
74
|
-
..._nested
|
|
75
|
-
];
|
|
76
|
-
for (const child of _nested) {
|
|
77
|
-
descendants.set(thisFqn, child);
|
|
78
|
-
}
|
|
79
|
-
if (ast.isExtendDeployment(node)) {
|
|
80
|
-
for (const ancestor of ancestorsFqn(thisFqn)) {
|
|
81
|
-
for (const child of _nested) {
|
|
82
|
-
descendants.set(ancestor, child);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return descendants.get(thisFqn) ?? [];
|
|
87
|
-
};
|
|
88
|
-
for (const node of rootNodes) {
|
|
89
|
-
try {
|
|
90
|
-
if (ast.isDeploymentRelation(node)) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
traverseNode(node, null);
|
|
94
|
-
} catch (e) {
|
|
95
|
-
logWarnError(e);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return new DocumentFqnIndex(root, children, descendants, byfqn, projectId);
|
|
99
|
-
}
|
|
100
|
-
}
|
package/dist/model/fqn-index.mjs
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { invariant, nonNullable } from "@likec4/core";
|
|
2
|
-
import { Fqn } from "@likec4/core/types";
|
|
3
|
-
import { ancestorsFqn, compareNatural, DefaultWeakMap, MultiMap, sortNaturalByFqn } from "@likec4/core/utils";
|
|
4
|
-
import {
|
|
5
|
-
AstUtils,
|
|
6
|
-
DocumentState,
|
|
7
|
-
stream,
|
|
8
|
-
WorkspaceCache
|
|
9
|
-
} from "langium";
|
|
10
|
-
import { isDefined, isEmpty, isTruthy } from "remeda";
|
|
11
|
-
import {
|
|
12
|
-
ast,
|
|
13
|
-
ElementOps,
|
|
14
|
-
isLikeC4LangiumDocument
|
|
15
|
-
} from "../ast.mjs";
|
|
16
|
-
import { logWarnError } from "../logger.mjs";
|
|
17
|
-
import { ADisposable } from "../utils/index.mjs";
|
|
18
|
-
import { readStrictFqn } from "../utils/elementRef.mjs";
|
|
19
|
-
import { ProjectsManager } from "../workspace/index.mjs";
|
|
20
|
-
export class FqnIndex extends ADisposable {
|
|
21
|
-
constructor(services, cachePrefix = "fqn-index") {
|
|
22
|
-
super();
|
|
23
|
-
this.services = services;
|
|
24
|
-
this.cachePrefix = cachePrefix;
|
|
25
|
-
this.langiumDocuments = services.shared.workspace.LangiumDocuments;
|
|
26
|
-
this.projects = services.shared.workspace.ProjectsManager;
|
|
27
|
-
this.documentCache = new DefaultWeakMap((doc) => this.createDocumentIndex(doc));
|
|
28
|
-
this.workspaceCache = new WorkspaceCache(services.shared, DocumentState.IndexedContent);
|
|
29
|
-
this.onDispose(
|
|
30
|
-
services.shared.workspace.DocumentBuilder.onDocumentPhase(
|
|
31
|
-
DocumentState.IndexedContent,
|
|
32
|
-
(doc) => {
|
|
33
|
-
if (isLikeC4LangiumDocument(doc)) {
|
|
34
|
-
this.documentCache.set(doc, this.createDocumentIndex(doc));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
projects;
|
|
41
|
-
langiumDocuments;
|
|
42
|
-
documentCache;
|
|
43
|
-
workspaceCache;
|
|
44
|
-
documents(projectId) {
|
|
45
|
-
return this.langiumDocuments.projectDocuments(projectId).filter(
|
|
46
|
-
(d) => isLikeC4LangiumDocument(d) && d.state >= DocumentState.IndexedContent
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
get(document) {
|
|
50
|
-
if (document.state < DocumentState.IndexedContent) {
|
|
51
|
-
logWarnError(`Document ${document.uri.path} is not indexed`);
|
|
52
|
-
}
|
|
53
|
-
return this.documentCache.get(document);
|
|
54
|
-
}
|
|
55
|
-
resolve(reference) {
|
|
56
|
-
if (reference.$type === "Imported") {
|
|
57
|
-
return this.getFqn(reference.imported.ref);
|
|
58
|
-
}
|
|
59
|
-
if (reference.$type === "Element") {
|
|
60
|
-
return this.getFqn(reference);
|
|
61
|
-
}
|
|
62
|
-
return this.services.likec4.DeploymentsIndex.getFqn(reference);
|
|
63
|
-
}
|
|
64
|
-
getFqn(el) {
|
|
65
|
-
invariant(ast.isElement(el) || ast.isDeploymentElement(el));
|
|
66
|
-
let id = ElementOps.readId(el);
|
|
67
|
-
if (isTruthy(id)) {
|
|
68
|
-
return id;
|
|
69
|
-
}
|
|
70
|
-
const doc = AstUtils.getDocument(el);
|
|
71
|
-
invariant(isLikeC4LangiumDocument(doc));
|
|
72
|
-
logWarnError(`Document ${doc.uri.path} is not indexed, but getFqn was called`);
|
|
73
|
-
this.get(doc);
|
|
74
|
-
return nonNullable(ElementOps.readId(el), "Element fqn must be set, invalid state");
|
|
75
|
-
}
|
|
76
|
-
byFqn(projectId, fqn) {
|
|
77
|
-
return stream(this.workspaceCache.get(`${this.cachePrefix}:${projectId}:fqn:${fqn}`, () => {
|
|
78
|
-
return this.documents(projectId).toArray().flatMap((doc) => {
|
|
79
|
-
return this.get(doc).byFqn(fqn);
|
|
80
|
-
});
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
rootElements(projectId) {
|
|
84
|
-
return stream(
|
|
85
|
-
this.workspaceCache.get(`${this.cachePrefix}:${projectId}:rootElements`, () => {
|
|
86
|
-
const allchildren = this.documents(projectId).reduce((map, doc) => {
|
|
87
|
-
this.get(doc).rootElements().forEach((desc) => {
|
|
88
|
-
map.set(desc.name, desc);
|
|
89
|
-
});
|
|
90
|
-
return map;
|
|
91
|
-
}, new MultiMap());
|
|
92
|
-
return uniqueByName(allchildren);
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
directChildrenOf(projectId, parent) {
|
|
97
|
-
return stream(
|
|
98
|
-
this.workspaceCache.get(`${this.cachePrefix}:${projectId}:directChildrenOf:${parent}`, () => {
|
|
99
|
-
const allchildren = this.documents(projectId).reduce((map, doc) => {
|
|
100
|
-
this.get(doc).children(parent).forEach((desc) => {
|
|
101
|
-
map.set(desc.name, desc);
|
|
102
|
-
});
|
|
103
|
-
return map;
|
|
104
|
-
}, new MultiMap());
|
|
105
|
-
return uniqueByName(allchildren);
|
|
106
|
-
})
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Returns descedant elements with unique names in the scope
|
|
111
|
-
*/
|
|
112
|
-
uniqueDescedants(projectId, parent) {
|
|
113
|
-
return stream(
|
|
114
|
-
this.workspaceCache.get(`${this.cachePrefix}:${projectId}:uniqueDescedants:${parent}`, () => {
|
|
115
|
-
const { children, descendants } = this.documents(projectId).reduce((map, doc) => {
|
|
116
|
-
const docIndex = this.get(doc);
|
|
117
|
-
docIndex.children(parent).forEach((desc) => {
|
|
118
|
-
map.children.set(desc.name, desc);
|
|
119
|
-
});
|
|
120
|
-
docIndex.descendants(parent).forEach((desc) => {
|
|
121
|
-
map.descendants.set(desc.name, desc);
|
|
122
|
-
});
|
|
123
|
-
return map;
|
|
124
|
-
}, {
|
|
125
|
-
children: new MultiMap(),
|
|
126
|
-
descendants: new MultiMap()
|
|
127
|
-
});
|
|
128
|
-
const uniqueChildren = uniqueByName(children);
|
|
129
|
-
const uniqueDescendants = [...descendants.associations()].flatMap(([_name, descs]) => descs.length === 1 && !children.has(_name) ? descs : []);
|
|
130
|
-
return [
|
|
131
|
-
...uniqueChildren,
|
|
132
|
-
...sortNaturalByFqn(uniqueDescendants)
|
|
133
|
-
];
|
|
134
|
-
})
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
createDocumentIndex(document) {
|
|
138
|
-
const rootElements = document.parseResult.value.models.flatMap((m) => m.elements);
|
|
139
|
-
if (rootElements.length === 0) {
|
|
140
|
-
return DocumentFqnIndex.EMPTY;
|
|
141
|
-
}
|
|
142
|
-
const projectId = document.likec4ProjectId ??= this.projects.belongsTo(document);
|
|
143
|
-
const root = new Array();
|
|
144
|
-
const children = new MultiMap();
|
|
145
|
-
const descendants = new MultiMap();
|
|
146
|
-
const byfqn = new MultiMap();
|
|
147
|
-
const Descriptions = this.services.workspace.AstNodeDescriptionProvider;
|
|
148
|
-
const createAndSaveDescription = (node, name, fqn) => {
|
|
149
|
-
const desc = {
|
|
150
|
-
...Descriptions.createDescription(node, name, document),
|
|
151
|
-
id: fqn,
|
|
152
|
-
likec4ProjectId: projectId
|
|
153
|
-
};
|
|
154
|
-
ElementOps.writeId(node, fqn);
|
|
155
|
-
byfqn.set(fqn, desc);
|
|
156
|
-
return desc;
|
|
157
|
-
};
|
|
158
|
-
const traverseNode = (el, parentFqn) => {
|
|
159
|
-
let thisFqn;
|
|
160
|
-
if (ast.isElement(el)) {
|
|
161
|
-
thisFqn = Fqn(el.name, parentFqn);
|
|
162
|
-
const desc = createAndSaveDescription(el, el.name, thisFqn);
|
|
163
|
-
if (!parentFqn) {
|
|
164
|
-
root.push(desc);
|
|
165
|
-
} else {
|
|
166
|
-
children.set(parentFqn, desc);
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
thisFqn = readStrictFqn(el.element);
|
|
170
|
-
}
|
|
171
|
-
let _nested = [];
|
|
172
|
-
if (isDefined(el.body) && !isEmpty(el.body.elements)) {
|
|
173
|
-
for (const child of el.body.elements) {
|
|
174
|
-
if (!ast.isRelation(child)) {
|
|
175
|
-
try {
|
|
176
|
-
_nested.push(...traverseNode(child, thisFqn));
|
|
177
|
-
} catch (e) {
|
|
178
|
-
logWarnError(e);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
const directChildren = children.get(thisFqn) ?? [];
|
|
184
|
-
_nested = [
|
|
185
|
-
...directChildren,
|
|
186
|
-
..._nested
|
|
187
|
-
];
|
|
188
|
-
for (const child of _nested) {
|
|
189
|
-
descendants.set(thisFqn, child);
|
|
190
|
-
}
|
|
191
|
-
if (ast.isExtendElement(el)) {
|
|
192
|
-
for (const ancestor of ancestorsFqn(thisFqn)) {
|
|
193
|
-
for (const child of _nested) {
|
|
194
|
-
descendants.set(ancestor, child);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return descendants.get(thisFqn) ?? [];
|
|
199
|
-
};
|
|
200
|
-
for (const node of rootElements) {
|
|
201
|
-
try {
|
|
202
|
-
if (ast.isRelation(node)) {
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
traverseNode(node, null);
|
|
206
|
-
} catch (e) {
|
|
207
|
-
logWarnError(e);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return new DocumentFqnIndex(root, children, descendants, byfqn, projectId);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function uniqueByName(multimap) {
|
|
214
|
-
return [...multimap.associations()].flatMap(([_name, descs]) => descs.length === 1 ? descs : []).sort((a, b) => compareNatural(a.name, b.name));
|
|
215
|
-
}
|
|
216
|
-
export class DocumentFqnIndex {
|
|
217
|
-
constructor(_rootElements, _children, _descendants, _byfqn, projectId) {
|
|
218
|
-
this._rootElements = _rootElements;
|
|
219
|
-
this._children = _children;
|
|
220
|
-
this._descendants = _descendants;
|
|
221
|
-
this._byfqn = _byfqn;
|
|
222
|
-
this.projectId = projectId;
|
|
223
|
-
}
|
|
224
|
-
static EMPTY = new DocumentFqnIndex(
|
|
225
|
-
[],
|
|
226
|
-
new MultiMap(),
|
|
227
|
-
new MultiMap(),
|
|
228
|
-
new MultiMap(),
|
|
229
|
-
ProjectsManager.DefaultProjectId
|
|
230
|
-
);
|
|
231
|
-
rootElements() {
|
|
232
|
-
return this._rootElements;
|
|
233
|
-
}
|
|
234
|
-
byFqn(fqn) {
|
|
235
|
-
return this._byfqn.get(fqn) ?? [];
|
|
236
|
-
}
|
|
237
|
-
children(parent) {
|
|
238
|
-
return this._children.get(parent) ?? [];
|
|
239
|
-
}
|
|
240
|
-
descendants(nodeName) {
|
|
241
|
-
return this._descendants.get(nodeName) ?? [];
|
|
242
|
-
}
|
|
243
|
-
}
|
package/dist/model/index.mjs
DELETED