@likec4/language-server 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contrib/likec4.monarch.ts +4 -4
- package/contrib/likec4.tmLanguage.json +1 -1
- package/package.json +8 -10
- package/src/Rpc.ts +108 -0
- package/src/ast.ts +443 -0
- package/src/browser/index.ts +30 -0
- package/src/elementRef.ts +26 -0
- package/src/generated/ast.ts +1632 -0
- package/src/generated/grammar.ts +10 -0
- package/src/generated/module.ts +32 -0
- package/src/index.ts +4 -0
- package/src/like-c4.langium +395 -0
- package/src/logger.ts +54 -0
- package/src/lsp/CodeLensProvider.ts +51 -0
- package/src/lsp/DocumentHighlightProvider.ts +12 -0
- package/src/lsp/DocumentLinkProvider.test.ts +66 -0
- package/src/lsp/DocumentLinkProvider.ts +53 -0
- package/src/lsp/DocumentSymbolProvider.ts +201 -0
- package/src/lsp/HoverProvider.ts +58 -0
- package/{dist/lsp/SemanticTokenProvider.js → src/lsp/SemanticTokenProvider.ts} +58 -43
- package/src/lsp/index.ts +6 -0
- package/src/model/fqn-computation.ts +47 -0
- package/src/model/fqn-index.ts +161 -0
- package/src/model/index.ts +5 -0
- package/src/model/model-builder.ts +447 -0
- package/src/model/model-locator.ts +130 -0
- package/src/model/model-parser.ts +580 -0
- package/src/model-change/ModelChanges.ts +120 -0
- package/src/model-change/changeElementStyle.ts +176 -0
- package/src/model-change/changeViewLayout.ts +41 -0
- package/src/module.ts +197 -0
- package/src/node/index.ts +20 -0
- package/src/protocol.ts +87 -0
- package/src/references/index.ts +2 -0
- package/src/references/scope-computation.ts +142 -0
- package/src/references/scope-provider.ts +166 -0
- package/src/shared/NodeKindProvider.ts +67 -0
- package/src/shared/WorkspaceManager.ts +39 -0
- package/src/shared/WorkspaceSymbolProvider.ts +3 -0
- package/src/shared/index.ts +3 -0
- package/src/test/index.ts +1 -0
- package/src/test/testServices.ts +119 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/printDocs.ts +3 -0
- package/src/utils/stringHash.ts +6 -0
- package/src/validation/dynamic-view-rule.ts +35 -0
- package/src/validation/dynamic-view-step.ts +39 -0
- package/src/validation/element.ts +52 -0
- package/{dist/validation/index.js → src/validation/index.ts} +25 -17
- package/src/validation/property-checks.ts +17 -0
- package/src/validation/relation.ts +57 -0
- package/src/validation/specification.ts +118 -0
- package/src/validation/view-predicates/custom-element-expr.ts +21 -0
- package/src/validation/view-predicates/expanded-element.ts +34 -0
- package/src/validation/view-predicates/incoming.ts +19 -0
- package/src/validation/view-predicates/index.ts +4 -0
- package/src/validation/view-predicates/outgoing.ts +19 -0
- package/src/validation/view.ts +26 -0
- package/src/view-utils/assignNavigateTo.ts +30 -0
- package/src/view-utils/index.ts +3 -0
- package/src/view-utils/resolve-extended-views.ts +57 -0
- package/src/view-utils/resolve-relative-paths.ts +84 -0
- package/dist/Rpc.d.ts +0 -10
- package/dist/Rpc.js +0 -98
- package/dist/ast.d.ts +0 -133
- package/dist/ast.js +0 -267
- package/dist/browser/index.d.ts +0 -9
- package/dist/browser/index.js +0 -16
- package/dist/elementRef.d.ts +0 -12
- package/dist/elementRef.js +0 -15
- package/dist/generated/ast.d.ts +0 -559
- package/dist/generated/ast.js +0 -868
- package/dist/generated/grammar.d.ts +0 -7
- package/dist/generated/grammar.js +0 -3
- package/dist/generated/module.d.ts +0 -14
- package/dist/generated/module.js +0 -22
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -2
- package/dist/logger.d.ts +0 -12
- package/dist/logger.js +0 -51
- package/dist/lsp/CodeLensProvider.d.ts +0 -10
- package/dist/lsp/CodeLensProvider.js +0 -37
- package/dist/lsp/DocumentHighlightProvider.d.ts +0 -10
- package/dist/lsp/DocumentHighlightProvider.js +0 -10
- package/dist/lsp/DocumentLinkProvider.d.ts +0 -11
- package/dist/lsp/DocumentLinkProvider.js +0 -41
- package/dist/lsp/DocumentLinkProvider.test.d.ts +0 -2
- package/dist/lsp/DocumentLinkProvider.test.js +0 -54
- package/dist/lsp/DocumentSymbolProvider.d.ts +0 -22
- package/dist/lsp/DocumentSymbolProvider.js +0 -184
- package/dist/lsp/HoverProvider.d.ts +0 -10
- package/dist/lsp/HoverProvider.js +0 -36
- package/dist/lsp/SemanticTokenProvider.d.ts +0 -8
- package/dist/lsp/index.d.ts +0 -7
- package/dist/lsp/index.js +0 -6
- package/dist/model/fqn-computation.d.ts +0 -4
- package/dist/model/fqn-computation.js +0 -43
- package/dist/model/fqn-index.d.ts +0 -26
- package/dist/model/fqn-index.js +0 -114
- package/dist/model/index.d.ts +0 -6
- package/dist/model/index.js +0 -5
- package/dist/model/model-builder.d.ts +0 -20
- package/dist/model/model-builder.js +0 -352
- package/dist/model/model-locator.d.ts +0 -22
- package/dist/model/model-locator.js +0 -119
- package/dist/model/model-parser.d.ts +0 -27
- package/dist/model/model-parser.js +0 -410
- package/dist/model-change/ModelChanges.d.ts +0 -15
- package/dist/model-change/ModelChanges.js +0 -100
- package/dist/model-change/changeElementStyle.d.ts +0 -15
- package/dist/model-change/changeElementStyle.js +0 -141
- package/dist/model-change/changeViewLayout.d.ts +0 -13
- package/dist/model-change/changeViewLayout.js +0 -30
- package/dist/module.d.ts +0 -59
- package/dist/module.js +0 -121
- package/dist/node/index.d.ts +0 -6
- package/dist/node/index.js +0 -13
- package/dist/protocol.d.ts +0 -58
- package/dist/protocol.js +0 -14
- package/dist/references/index.d.ts +0 -3
- package/dist/references/index.js +0 -2
- package/dist/references/scope-computation.d.ts +0 -11
- package/dist/references/scope-computation.js +0 -108
- package/dist/references/scope-provider.d.ts +0 -18
- package/dist/references/scope-provider.js +0 -136
- package/dist/shared/NodeKindProvider.d.ts +0 -16
- package/dist/shared/NodeKindProvider.js +0 -58
- package/dist/shared/WorkspaceManager.d.ts +0 -17
- package/dist/shared/WorkspaceManager.js +0 -29
- package/dist/shared/WorkspaceSymbolProvider.d.ts +0 -4
- package/dist/shared/WorkspaceSymbolProvider.js +0 -3
- package/dist/shared/index.d.ts +0 -4
- package/dist/shared/index.js +0 -3
- package/dist/test/index.d.ts +0 -2
- package/dist/test/index.js +0 -1
- package/dist/test/testServices.d.ts +0 -23
- package/dist/test/testServices.js +0 -102
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -1
- package/dist/utils/printDocs.d.ts +0 -3
- package/dist/utils/printDocs.js +0 -1
- package/dist/utils/stringHash.d.ts +0 -2
- package/dist/utils/stringHash.js +0 -5
- package/dist/validation/element.d.ts +0 -6
- package/dist/validation/element.js +0 -38
- package/dist/validation/index.d.ts +0 -3
- package/dist/validation/property-checks.d.ts +0 -5
- package/dist/validation/property-checks.js +0 -11
- package/dist/validation/relation.d.ts +0 -5
- package/dist/validation/relation.js +0 -50
- package/dist/validation/specification.d.ts +0 -10
- package/dist/validation/specification.js +0 -97
- package/dist/validation/view-predicates/custom-element-expr.d.ts +0 -5
- package/dist/validation/view-predicates/custom-element-expr.js +0 -16
- package/dist/validation/view-predicates/expanded-element.d.ts +0 -5
- package/dist/validation/view-predicates/expanded-element.js +0 -28
- package/dist/validation/view-predicates/incoming.d.ts +0 -5
- package/dist/validation/view-predicates/incoming.js +0 -14
- package/dist/validation/view-predicates/index.d.ts +0 -5
- package/dist/validation/view-predicates/index.js +0 -4
- package/dist/validation/view-predicates/outgoing.d.ts +0 -5
- package/dist/validation/view-predicates/outgoing.js +0 -14
- package/dist/validation/view.d.ts +0 -5
- package/dist/validation/view.js +0 -18
- package/dist/view-utils/assignNavigateTo.d.ts +0 -3
- package/dist/view-utils/assignNavigateTo.js +0 -23
- package/dist/view-utils/index.d.ts +0 -4
- package/dist/view-utils/index.js +0 -3
- package/dist/view-utils/resolve-extended-views.d.ts +0 -7
- package/dist/view-utils/resolve-extended-views.js +0 -41
- package/dist/view-utils/resolve-relative-paths.d.ts +0 -3
- package/dist/view-utils/resolve-relative-paths.js +0 -76
- /package/{dist → src}/reset.d.ts +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type ElementView } from '@likec4/core';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve rules of extended views
|
|
4
|
-
* (Removes invalid views)
|
|
5
|
-
*/
|
|
6
|
-
export declare function resolveRulesExtendedViews<V extends Record<any, ElementView>>(unresolvedViews: V): V;
|
|
7
|
-
//# sourceMappingURL=resolve-extended-views.d.ts.map
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import graphlib from "@dagrejs/graphlib";
|
|
2
|
-
import { isExtendsElementView } from "@likec4/core";
|
|
3
|
-
const { Graph, alg } = graphlib;
|
|
4
|
-
export function resolveRulesExtendedViews(unresolvedViews) {
|
|
5
|
-
const g = new Graph({
|
|
6
|
-
directed: true,
|
|
7
|
-
multigraph: false,
|
|
8
|
-
compound: false
|
|
9
|
-
});
|
|
10
|
-
for (const view of Object.values(unresolvedViews)) {
|
|
11
|
-
g.setNode(view.id);
|
|
12
|
-
if (isExtendsElementView(view)) {
|
|
13
|
-
g.setEdge(view.id, view.extends);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const cycles = alg.findCycles(g);
|
|
17
|
-
if (cycles.length > 0) {
|
|
18
|
-
cycles.flat().forEach((id) => g.removeNode(id));
|
|
19
|
-
}
|
|
20
|
-
const ordered = alg.postorder(g, g.sources());
|
|
21
|
-
return ordered.reduce((acc, id) => {
|
|
22
|
-
const view = unresolvedViews[id];
|
|
23
|
-
if (!view) {
|
|
24
|
-
return acc;
|
|
25
|
-
}
|
|
26
|
-
if (isExtendsElementView(view)) {
|
|
27
|
-
const extendsFrom = acc[view.extends];
|
|
28
|
-
if (!extendsFrom) {
|
|
29
|
-
return acc;
|
|
30
|
-
}
|
|
31
|
-
return Object.assign(acc, {
|
|
32
|
-
[view.id]: {
|
|
33
|
-
...extendsFrom,
|
|
34
|
-
...view,
|
|
35
|
-
rules: [...extendsFrom.rules, ...view.rules]
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return Object.assign(acc, { [view.id]: view });
|
|
40
|
-
}, {});
|
|
41
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { invariant } from "@likec4/core";
|
|
2
|
-
import { uniq, zip } from "rambdax";
|
|
3
|
-
import { hasAtLeast } from "remeda";
|
|
4
|
-
function commonAncestorPath(views, sep = "/") {
|
|
5
|
-
if (views.length <= 1)
|
|
6
|
-
return "";
|
|
7
|
-
const uniqURIs = uniq(views.flatMap(({ docUri }) => docUri ? [docUri] : []));
|
|
8
|
-
if (uniqURIs.length === 0)
|
|
9
|
-
return "";
|
|
10
|
-
if (uniqURIs.length === 1) {
|
|
11
|
-
invariant(hasAtLeast(uniqURIs, 1));
|
|
12
|
-
return new URL(uniqURIs[0]).pathname;
|
|
13
|
-
}
|
|
14
|
-
invariant(hasAtLeast(uniqURIs, 2), "Expected at least 2 unique URIs");
|
|
15
|
-
const [baseUri, ...tail] = uniqURIs;
|
|
16
|
-
const parts = new URL(baseUri).pathname.split(sep);
|
|
17
|
-
let endOfPrefix = parts.length;
|
|
18
|
-
for (const uri of tail) {
|
|
19
|
-
if (uri === baseUri) {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
const compare = new URL(uri).pathname.split(sep);
|
|
23
|
-
for (let i = 0; i < endOfPrefix; i++) {
|
|
24
|
-
if (compare[i] !== parts[i]) {
|
|
25
|
-
endOfPrefix = i;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (endOfPrefix === 0)
|
|
29
|
-
return "";
|
|
30
|
-
}
|
|
31
|
-
const prefix = parts.slice(0, endOfPrefix).join(sep);
|
|
32
|
-
return prefix.endsWith(sep) ? prefix : prefix + sep;
|
|
33
|
-
}
|
|
34
|
-
export function resolveRelativePaths(views) {
|
|
35
|
-
const commonPrefix = commonAncestorPath(views);
|
|
36
|
-
return views.map((view) => {
|
|
37
|
-
if (!view.docUri) {
|
|
38
|
-
return {
|
|
39
|
-
...view,
|
|
40
|
-
parts: []
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
const path = new URL(view.docUri).pathname;
|
|
44
|
-
const parts = path.replace(commonPrefix, "").split("/");
|
|
45
|
-
parts.pop();
|
|
46
|
-
return {
|
|
47
|
-
...view,
|
|
48
|
-
parts
|
|
49
|
-
};
|
|
50
|
-
}).sort((a, b) => {
|
|
51
|
-
if (a.parts.length === b.parts.length) {
|
|
52
|
-
if (a.parts.length === 0) {
|
|
53
|
-
return 0;
|
|
54
|
-
}
|
|
55
|
-
if (a.parts.length === 1 && hasAtLeast(a.parts, 1) && hasAtLeast(b.parts, 1)) {
|
|
56
|
-
return a.parts[0].localeCompare(b.parts[0]);
|
|
57
|
-
}
|
|
58
|
-
for (const [_a, _b] of zip(a.parts, b.parts)) {
|
|
59
|
-
const compare = _a.localeCompare(_b);
|
|
60
|
-
if (compare !== 0) {
|
|
61
|
-
return compare;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return 0;
|
|
65
|
-
}
|
|
66
|
-
return a.parts.length - b.parts.length;
|
|
67
|
-
}).map(({ parts, ...view }) => {
|
|
68
|
-
if (view.docUri) {
|
|
69
|
-
return {
|
|
70
|
-
...view,
|
|
71
|
-
relativePath: parts.join("/")
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
return view;
|
|
75
|
-
});
|
|
76
|
-
}
|
/package/{dist → src}/reset.d.ts
RENAMED
|
File without changes
|