@likec4/language-server 1.4.0 → 1.6.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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/contrib/likec4.tmLanguage.json +1 -1
  3. package/package.json +26 -14
  4. package/src/Rpc.ts +25 -2
  5. package/src/ast.ts +19 -15
  6. package/src/generated/ast.ts +390 -203
  7. package/src/generated/grammar.ts +1 -1
  8. package/src/generated-lib/icons.ts +952 -0
  9. package/src/like-c4.langium +120 -64
  10. package/src/likec4lib.ts +7 -0
  11. package/src/lsp/DocumentSymbolProvider.ts +28 -1
  12. package/src/lsp/SemanticTokenProvider.ts +41 -22
  13. package/src/model/fqn-computation.ts +29 -7
  14. package/src/model/fqn-index.ts +18 -31
  15. package/src/model/model-builder.ts +13 -9
  16. package/src/model/model-locator.ts +7 -7
  17. package/src/model/model-parser.ts +166 -69
  18. package/src/model-change/changeElementStyle.ts +6 -6
  19. package/src/model-graph/compute-view/__test__/fixture.ts +52 -24
  20. package/src/model-graph/compute-view/compute.ts +51 -20
  21. package/src/model-graph/compute-view/predicates.ts +6 -1
  22. package/src/model-graph/dynamic-view/__test__/fixture.ts +2 -2
  23. package/src/model-graph/dynamic-view/compute.ts +2 -2
  24. package/src/model-graph/utils/{applyElementCustomProperties.ts → applyCustomElementProperties.ts} +5 -3
  25. package/src/model-graph/utils/applyCustomRelationProperties.ts +50 -0
  26. package/src/model-graph/utils/applyViewRuleStyles.ts +11 -34
  27. package/src/model-graph/utils/elementExpressionToPredicate.ts +32 -0
  28. package/src/references/scope-computation.ts +113 -60
  29. package/src/references/scope-provider.ts +3 -23
  30. package/src/shared/NodeKindProvider.ts +1 -0
  31. package/src/shared/WorkspaceManager.ts +15 -6
  32. package/src/validation/dynamic-view-rule.ts +19 -26
  33. package/src/validation/element.ts +8 -4
  34. package/src/validation/index.ts +9 -6
  35. package/src/validation/property-checks.ts +23 -1
  36. package/src/validation/view-predicates/custom-element-expr.ts +21 -8
  37. package/src/validation/view-predicates/custom-relation-expr.ts +16 -0
  38. package/src/validation/view-predicates/expanded-element.ts +13 -24
  39. package/src/validation/view-predicates/incoming.ts +5 -5
  40. package/src/validation/view-predicates/index.ts +1 -0
  41. package/src/validation/view-predicates/outgoing.ts +5 -5
  42. package/src/view-utils/assignNavigateTo.ts +2 -2
  43. package/src/view-utils/manual-layout.ts +4 -2
  44. package/src/view-utils/resolve-extended-views.ts +2 -2
  45. package/src/view-utils/resolve-relative-paths.ts +3 -3
@@ -29,8 +29,10 @@ export namespace CompactViewManualLayout {
29
29
  export function pack(layout: ViewManualLayout): CompactViewManualLayout {
30
30
  return [
31
31
  1,
32
- entries.strict(layout.nodes).map(([id, { x, y, width, height }]) => [id, x, y, width, height]),
33
- entries.strict(layout.edges).map(([id, { controlPoints }]) => [id, controlPoints.flatMap(({ x, y }) => [x, y])])
32
+ entries(layout.nodes).map(([id, { x, y, width, height }]) => [id as Fqn, x, y, width, height]),
33
+ entries(layout.edges).map((
34
+ [id, { controlPoints }]
35
+ ) => [id as EdgeId, controlPoints.flatMap(({ x, y }) => [x, y])])
34
36
  ]
35
37
  }
36
38
 
@@ -1,5 +1,5 @@
1
1
  import graphlib from '@dagrejs/graphlib'
2
- import { isExtendsElementView, type View } from '@likec4/core'
2
+ import { isExtendsElementView, type LikeC4View } from '@likec4/core'
3
3
 
4
4
  // '@dagrejs/graphlib' is a CommonJS module
5
5
  // Here is a workaround to import it
@@ -10,7 +10,7 @@ const { Graph, alg } = graphlib
10
10
  * (Removes invalid views)
11
11
  */
12
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- export function resolveRulesExtendedViews<V extends Record<any, View>>(
13
+ export function resolveRulesExtendedViews<V extends Record<any, LikeC4View>>(
14
14
  unresolvedViews: V
15
15
  ): V {
16
16
  const g = new Graph({
@@ -1,8 +1,8 @@
1
- import type { View } from '@likec4/core'
1
+ import type { LikeC4View } from '@likec4/core'
2
2
  import { invariant } from '@likec4/core'
3
3
  import { hasAtLeast, unique, zip } from 'remeda'
4
4
 
5
- function commonAncestorPath(views: View[], sep = '/') {
5
+ function commonAncestorPath(views: LikeC4View[], sep = '/') {
6
6
  if (views.length <= 1) return ''
7
7
  const uniqURIs = unique(views.flatMap(({ docUri }) => (docUri ? [docUri] : [])))
8
8
  if (uniqURIs.length === 0) return ''
@@ -30,7 +30,7 @@ function commonAncestorPath(views: View[], sep = '/') {
30
30
  return prefix.endsWith(sep) ? prefix : prefix + sep
31
31
  }
32
32
 
33
- export function resolveRelativePaths(views: View[]): View[] {
33
+ export function resolveRelativePaths(views: LikeC4View[]): LikeC4View[] {
34
34
  const commonPrefix = commonAncestorPath(views)
35
35
  return (
36
36
  views