@likec4/language-server 1.8.1 → 1.9.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/dist/browser.cjs +21 -0
- package/dist/browser.d.cts +22 -0
- package/dist/browser.d.mts +22 -0
- package/dist/browser.d.ts +22 -0
- package/dist/browser.mjs +19 -0
- package/dist/index.cjs +10 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.mjs +1 -0
- package/dist/likec4lib.cjs +961 -0
- package/dist/likec4lib.d.cts +6 -0
- package/dist/likec4lib.d.mts +6 -0
- package/dist/likec4lib.d.ts +6 -0
- package/dist/likec4lib.mjs +957 -0
- package/dist/model-graph/index.cjs +10 -0
- package/dist/model-graph/index.d.cts +79 -0
- package/dist/model-graph/index.d.mts +79 -0
- package/dist/model-graph/index.d.ts +79 -0
- package/dist/model-graph/index.mjs +1 -0
- package/dist/node.cjs +18 -0
- package/dist/node.d.cts +20 -0
- package/dist/node.d.mts +20 -0
- package/dist/node.d.ts +20 -0
- package/dist/node.mjs +16 -0
- package/dist/protocol.cjs +25 -0
- package/dist/protocol.d.cts +43 -0
- package/dist/protocol.d.mts +43 -0
- package/dist/protocol.d.ts +43 -0
- package/dist/protocol.mjs +17 -0
- package/dist/shared/language-server.86lmJ8ZN.d.cts +1194 -0
- package/dist/shared/language-server.B1TZgyoH.cjs +5371 -0
- package/dist/shared/language-server.CCB4ESN5.mjs +1606 -0
- package/dist/shared/language-server.CFTY6j4e.d.mts +1194 -0
- package/dist/shared/language-server.D0bOlrCi.cjs +1619 -0
- package/dist/shared/language-server.Q-wtPShM.mjs +5360 -0
- package/dist/shared/language-server.RjhrBZS0.d.ts +1194 -0
- package/package.json +35 -20
- package/src/ast.ts +40 -30
- package/src/browser.ts +0 -3
- package/src/elementRef.ts +1 -1
- package/src/generated/ast.ts +67 -3
- package/src/generated/grammar.ts +1 -1
- package/src/generated-lib/icons.ts +1 -1
- package/src/like-c4.langium +16 -2
- package/src/likec4lib.ts +2 -3
- package/src/logger.ts +9 -1
- package/src/lsp/RenameProvider.ts +8 -0
- package/src/lsp/SemanticTokenProvider.ts +19 -1
- package/src/lsp/index.ts +1 -0
- package/src/model/fqn-computation.ts +33 -23
- package/src/model/fqn-index.ts +5 -20
- package/src/model/model-builder.ts +147 -90
- package/src/model/model-locator.ts +1 -1
- package/src/model/model-parser-where.ts +3 -2
- package/src/model/model-parser.ts +57 -19
- package/src/model-graph/LikeC4ModelGraph.ts +42 -21
- package/src/model-graph/compute-view/__test__/fixture.ts +16 -14
- package/src/model-graph/compute-view/compute.ts +9 -6
- package/src/model-graph/compute-view/predicates.ts +3 -3
- package/src/model-graph/dynamic-view/__test__/fixture.ts +1 -0
- package/src/model-graph/dynamic-view/compute.ts +2 -1
- package/src/model-graph/utils/elementExpressionToPredicate.ts +1 -1
- package/src/model-graph/utils/sortNodes.ts +2 -6
- package/src/module.ts +23 -3
- package/src/protocol.ts +4 -5
- package/src/references/scope-computation.ts +10 -1
- package/src/references/scope-provider.ts +2 -1
- package/src/shared/NodeKindProvider.ts +73 -34
- package/src/test/setup.ts +3 -8
- package/src/utils/graphlib.ts +11 -0
- package/src/view-utils/manual-layout.ts +1 -1
- package/src/view-utils/resolve-extended-views.ts +19 -10
- package/src/view-utils/resolve-relative-paths.ts +5 -7
- package/src/view-utils/view-hash.ts +1 -1
- package/src/reset.d.ts +0 -2
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import graphlib from '@dagrejs/graphlib'
|
|
2
1
|
import { isExtendsElementView, type LikeC4View } from '@likec4/core'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { Graph, alg } = graphlib
|
|
2
|
+
import { logger } from '@likec4/log'
|
|
3
|
+
import { first, last, values } from 'remeda'
|
|
4
|
+
import { findCycles, Graph, isAcyclic, postorder } from '../utils/graphlib'
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* Resolve rules of extended views
|
|
@@ -18,21 +16,31 @@ export function resolveRulesExtendedViews<V extends Record<any, LikeC4View>>(
|
|
|
18
16
|
multigraph: false,
|
|
19
17
|
compound: false
|
|
20
18
|
})
|
|
21
|
-
for (const view of
|
|
19
|
+
for (const view of values(unresolvedViews)) {
|
|
22
20
|
g.setNode(view.id)
|
|
23
21
|
if (isExtendsElementView(view)) {
|
|
24
22
|
// view -> parent
|
|
25
23
|
g.setEdge(view.id, view.extends)
|
|
26
24
|
}
|
|
27
25
|
}
|
|
26
|
+
if (g.edgeCount() === 0) {
|
|
27
|
+
return unresolvedViews
|
|
28
|
+
}
|
|
28
29
|
|
|
29
30
|
// Remove circular dependencies
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
while (!isAcyclic(g)) {
|
|
32
|
+
const firstCycle = first(findCycles(g))
|
|
33
|
+
if (!firstCycle) {
|
|
34
|
+
break
|
|
35
|
+
}
|
|
36
|
+
const cycledNode = last(firstCycle)
|
|
37
|
+
if (!cycledNode) {
|
|
38
|
+
break
|
|
39
|
+
}
|
|
40
|
+
g.removeNode(cycledNode)
|
|
33
41
|
}
|
|
34
42
|
|
|
35
|
-
const ordered =
|
|
43
|
+
const ordered = postorder(g, g.sources())
|
|
36
44
|
|
|
37
45
|
return ordered.reduce((acc, id) => {
|
|
38
46
|
const view = unresolvedViews[id]
|
|
@@ -42,6 +50,7 @@ export function resolveRulesExtendedViews<V extends Record<any, LikeC4View>>(
|
|
|
42
50
|
if (isExtendsElementView(view)) {
|
|
43
51
|
const extendsFrom = acc[view.extends]
|
|
44
52
|
if (!extendsFrom) {
|
|
53
|
+
logger.debug(`View "${view.id}" extends from "${view.extends}" which does not exist`)
|
|
45
54
|
return acc
|
|
46
55
|
}
|
|
47
56
|
return Object.assign(acc, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LikeC4View } from '@likec4/core'
|
|
2
2
|
import { invariant } from '@likec4/core'
|
|
3
3
|
import { filter, hasAtLeast, isTruthy, map, pipe, unique, zip } from 'remeda'
|
|
4
|
+
import { parsePath } from 'ufo'
|
|
4
5
|
|
|
5
6
|
function commonAncestorPath(views: LikeC4View[], sep = '/') {
|
|
6
7
|
const uniqURIs = pipe(
|
|
@@ -11,20 +12,20 @@ function commonAncestorPath(views: LikeC4View[], sep = '/') {
|
|
|
11
12
|
)
|
|
12
13
|
if (uniqURIs.length === 0) return ''
|
|
13
14
|
if (hasAtLeast(uniqURIs, 1) && uniqURIs.length === 1) {
|
|
14
|
-
const parts =
|
|
15
|
+
const parts = parsePath(uniqURIs[0]).pathname.split(sep)
|
|
15
16
|
if (parts.length <= 1) return sep
|
|
16
17
|
parts.pop() // remove filename
|
|
17
18
|
return parts.join(sep) + sep
|
|
18
19
|
}
|
|
19
20
|
invariant(hasAtLeast(uniqURIs, 2), 'Expected at least 2 unique URIs')
|
|
20
21
|
const [baseUri, ...tail] = uniqURIs
|
|
21
|
-
const parts =
|
|
22
|
+
const parts = parsePath(baseUri).pathname.split(sep)
|
|
22
23
|
let endOfPrefix = parts.length
|
|
23
24
|
for (const uri of tail) {
|
|
24
25
|
if (uri === baseUri) {
|
|
25
26
|
continue
|
|
26
27
|
}
|
|
27
|
-
const compare =
|
|
28
|
+
const compare = parsePath(uri).pathname.split(sep)
|
|
28
29
|
for (let i = 0; i < endOfPrefix; i++) {
|
|
29
30
|
if (compare[i] !== parts[i]) {
|
|
30
31
|
endOfPrefix = i
|
|
@@ -50,7 +51,7 @@ export function resolveRelativePaths(views: LikeC4View[]): LikeC4View[] {
|
|
|
50
51
|
parts: []
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
|
-
let path =
|
|
54
|
+
let path = parsePath(view.docUri).pathname
|
|
54
55
|
if (commonPrefix.length > 0) {
|
|
55
56
|
invariant(
|
|
56
57
|
path.startsWith(commonPrefix),
|
|
@@ -71,9 +72,6 @@ export function resolveRelativePaths(views: LikeC4View[]): LikeC4View[] {
|
|
|
71
72
|
if (a.parts.length === 0) {
|
|
72
73
|
return 0
|
|
73
74
|
}
|
|
74
|
-
if (a.parts.length === 1 && hasAtLeast(a.parts, 1) && hasAtLeast(b.parts, 1)) {
|
|
75
|
-
return a.parts[0].localeCompare(b.parts[0])
|
|
76
|
-
}
|
|
77
75
|
for (const [_a, _b] of zip(a.parts, b.parts)) {
|
|
78
76
|
const compare = _a.localeCompare(_b)
|
|
79
77
|
if (compare !== 0) {
|
package/src/reset.d.ts
DELETED