@likec4/language-server 1.16.0 → 1.17.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 (35) hide show
  1. package/dist/browser.cjs +1 -1
  2. package/dist/browser.d.cts +2 -2
  3. package/dist/browser.d.mts +2 -2
  4. package/dist/browser.d.ts +2 -2
  5. package/dist/browser.mjs +2 -2
  6. package/dist/index.cjs +35 -5
  7. package/dist/index.d.cts +17 -4
  8. package/dist/index.d.mts +17 -4
  9. package/dist/index.d.ts +17 -4
  10. package/dist/index.mjs +34 -5
  11. package/dist/model-graph/index.cjs +1 -1
  12. package/dist/model-graph/index.mjs +1 -1
  13. package/dist/shared/{language-server.D_13fWJQ.mjs → language-server.B8qSDsWW.mjs} +36 -14
  14. package/dist/shared/{language-server.DViE1Zxi.d.mts → language-server.BGGRJRnr.d.mts} +1 -1
  15. package/dist/shared/{language-server.C5gxpVUH.mjs → language-server.BXFhlTPo.mjs} +15 -3
  16. package/dist/shared/{language-server.DIaiY0-C.d.mts → language-server.BgDKnNok.d.mts} +1 -1
  17. package/dist/shared/{language-server.7iILaJYc.d.ts → language-server.Bmpq16Gw.d.ts} +1 -1
  18. package/dist/shared/{language-server.CmBZHwSl.d.cts → language-server.C1ZfM22X.d.cts} +1 -1
  19. package/dist/shared/{language-server.CnkCWVtf.d.cts → language-server.DJo88TnT.d.cts} +1 -1
  20. package/dist/shared/{language-server.Dym6GL4P.cjs → language-server.DZRuJVSg.cjs} +36 -14
  21. package/dist/shared/{language-server.Bd3NZ8uH.cjs → language-server.N8HLDQqz.cjs} +14 -2
  22. package/dist/shared/{language-server.DwyQ1FtY.d.ts → language-server.PEjk7U9s.d.ts} +1 -1
  23. package/package.json +7 -7
  24. package/src/LikeC4FileSystem.ts +36 -0
  25. package/src/Rpc.ts +2 -2
  26. package/src/generated/ast.ts +1 -1
  27. package/src/generated/grammar.ts +1 -1
  28. package/src/index.ts +3 -3
  29. package/src/like-c4.langium +1 -1
  30. package/src/lsp/SemanticTokenProvider.ts +26 -8
  31. package/src/model/fqn-computation.ts +6 -2
  32. package/src/model-graph/compute-view/__test__/fixture.ts +6 -0
  33. package/src/model-graph/compute-view/compute.ts +9 -2
  34. package/src/model-graph/dynamic-view/compute.ts +8 -1
  35. package/src/model-graph/utils/applyCustomElementProperties.ts +1 -3
package/src/index.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { startLanguageServer as startLanguim } from 'langium/lsp'
2
- import { NodeFileSystem } from 'langium/node'
3
2
  import { createConnection, ProposedFeatures } from 'vscode-languageserver/node'
3
+ import { LikeC4FileSystem } from './LikeC4FileSystem'
4
4
  import { createLanguageServices } from './module'
5
5
 
6
6
  export { logger as lspLogger, setLogLevel } from './logger'
7
7
  export type * from './model'
8
8
  export type * from './module'
9
9
  export { createCustomLanguageServices, createLanguageServices, LikeC4Module } from './module'
10
-
10
+ export { LikeC4FileSystem }
11
11
  export function startLanguageServer() {
12
12
  /* browser specific setup code */
13
13
  const connection = createConnection(ProposedFeatures.all)
14
14
 
15
15
  // Inject the shared services and language-specific services
16
- const services = createLanguageServices({ connection, ...NodeFileSystem })
16
+ const services = createLanguageServices({ connection, ...LikeC4FileSystem })
17
17
 
18
18
  // Start the language server with the shared services
19
19
  startLanguim(services.shared)
@@ -557,7 +557,7 @@ OpacityProperty:
557
557
 
558
558
  // Element properties -------------------------------------
559
559
  IconProperty:
560
- key='icon' ':'? (libicon=[LibIcon:IconId] | value=Uri) ';'?;
560
+ key='icon' ':'? (libicon=[LibIcon:IconId] | value=('none'|Uri)) ';'?;
561
561
 
562
562
  ShapeProperty:
563
563
  key='shape' ':'? value=ElementShape ';'?;
@@ -196,6 +196,32 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
196
196
  property: 'key',
197
197
  type: SemanticTokenTypes.property
198
198
  })
199
+ if (ast.isIconProperty(node)) {
200
+ if (node.libicon) {
201
+ acceptor({
202
+ node,
203
+ property: 'libicon',
204
+ type: SemanticTokenTypes.enum,
205
+ modifier: [SemanticTokenModifiers.defaultLibrary]
206
+ })
207
+ } else {
208
+ if (node.value === 'none') {
209
+ acceptor({
210
+ node,
211
+ property: 'value',
212
+ type: SemanticTokenTypes.enum,
213
+ modifier: [SemanticTokenModifiers.defaultLibrary]
214
+ })
215
+ } else {
216
+ acceptor({
217
+ node,
218
+ property: 'value',
219
+ type: SemanticTokenTypes.string
220
+ })
221
+ }
222
+ }
223
+ return 'prune'
224
+ }
199
225
  if ('value' in node && node.value) {
200
226
  acceptor({
201
227
  node,
@@ -203,14 +229,6 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
203
229
  type: SemanticTokenTypes.string
204
230
  })
205
231
  }
206
- if (ast.isIconProperty(node) && node.libicon) {
207
- acceptor({
208
- node,
209
- property: 'libicon',
210
- type: SemanticTokenTypes.enum,
211
- modifier: [SemanticTokenModifiers.defaultLibrary]
212
- })
213
- }
214
232
  return 'prune'
215
233
  }
216
234
  if (
@@ -52,7 +52,9 @@ export function computeDocumentFqn(document: LikeC4LangiumDocument, services: Li
52
52
  if (isDefined(el.body) && !isEmpty(el.body.elements)) {
53
53
  const fqn = getFqnElementRef(el.element)
54
54
  for (const child of el.body.elements) {
55
- traverseStack.push([child, fqn])
55
+ if (!ast.isRelation(child)) {
56
+ traverseStack.push([child, fqn])
57
+ }
56
58
  }
57
59
  }
58
60
  continue
@@ -66,7 +68,9 @@ export function computeDocumentFqn(document: LikeC4LangiumDocument, services: Li
66
68
  ElementOps.writeId(el, fqn)
67
69
  if (isDefined(el.body) && !isEmpty(el.body.elements)) {
68
70
  for (const child of el.body.elements) {
69
- traverseStack.push([child, fqn])
71
+ if (!ast.isRelation(child)) {
72
+ traverseStack.push([child, fqn])
73
+ }
70
74
  }
71
75
  }
72
76
  continue
@@ -12,6 +12,7 @@ import {
12
12
  type Expression as C4Expression,
13
13
  type Fqn,
14
14
  type GlobalStyleID,
15
+ type IconUrl,
15
16
  type IncomingExpr as C4IncomingExpr,
16
17
  type InOutExpr as C4InOutExpr,
17
18
  isElementRef,
@@ -163,6 +164,7 @@ export const fakeElements = {
163
164
  id: 'cloud',
164
165
  kind: 'system',
165
166
  title: 'cloud',
167
+ icon: 'none',
166
168
  tags: ['next', 'old']
167
169
  }),
168
170
  'cloud.backend': el({
@@ -179,6 +181,7 @@ export const fakeElements = {
179
181
  'cloud.backend.graphql': el({
180
182
  id: 'cloud.backend.graphql',
181
183
  kind: 'component',
184
+ icon: 'tech:graphql' as IconUrl,
182
185
  title: 'graphql'
183
186
  }),
184
187
  'email': el({
@@ -202,12 +205,14 @@ export const fakeElements = {
202
205
  id: 'cloud.frontend.dashboard',
203
206
  kind: 'component',
204
207
  title: 'dashboard',
208
+ icon: 'tech:react' as IconUrl,
205
209
  tags: ['next']
206
210
  }),
207
211
  'amazon': el({
208
212
  id: 'amazon',
209
213
  kind: 'system',
210
214
  title: 'amazon',
215
+ icon: 'tech:aws' as IconUrl,
211
216
  tags: ['aws']
212
217
  }),
213
218
  'amazon.s3': el({
@@ -215,6 +220,7 @@ export const fakeElements = {
215
220
  kind: 'component',
216
221
  title: 's3',
217
222
  shape: 'storage',
223
+ icon: 'aws:s3' as IconUrl,
218
224
  tags: ['aws', 'storage']
219
225
  })
220
226
  } satisfies Record<string, Element>
@@ -181,7 +181,7 @@ export class ComputeCtx {
181
181
 
182
182
  protected get activeGroup() {
183
183
  return this.activeGroupStack[0] ?? this.__rootGroup
184
- }
184
+ }
185
185
 
186
186
  protected get includedElements() {
187
187
  return new Set([
@@ -283,7 +283,14 @@ export class ComputeCtx {
283
283
  ...(autoLayoutRule?.nodeSep && { nodeSep: autoLayoutRule.nodeSep }),
284
284
  ...(autoLayoutRule?.rankSep && { rankSep: autoLayoutRule.rankSep })
285
285
  },
286
- nodes: map(nodes, omit(['notation'])),
286
+ nodes: map(nodes, n => {
287
+ // omit notation
288
+ delete n.notation
289
+ if (n.icon === 'none') {
290
+ delete n.icon
291
+ }
292
+ return n
293
+ }),
287
294
  edges: applyCustomRelationProperties(rules, nodes, sortedEdges),
288
295
  ...(elementNotations.length > 0 && {
289
296
  notation: {
@@ -208,7 +208,14 @@ export class DynamicViewComputeCtx {
208
208
  ...(autoLayoutRule?.nodeSep && { nodeSep: autoLayoutRule.nodeSep }),
209
209
  ...(autoLayoutRule?.rankSep && { rankSep: autoLayoutRule.rankSep })
210
210
  },
211
- nodes: map(nodes, omit(['notation'])),
211
+ nodes: map(nodes, n => {
212
+ // omit notation
213
+ delete n.notation
214
+ if (n.icon === 'none') {
215
+ delete n.icon
216
+ }
217
+ return n
218
+ }),
212
219
  edges,
213
220
  ...(elementNotations.length > 0 && {
214
221
  notation: {
@@ -1,7 +1,5 @@
1
- import { ComputedNode, type Expression, type ViewRule } from '@likec4/core'
2
- import { Expr, isViewRuleGroup, isViewRulePredicate } from '@likec4/core'
1
+ import { ComputedNode, Expr, type Expression, isViewRuleGroup, isViewRulePredicate, type ViewRule } from '@likec4/core'
3
2
  import { isEmpty, isNullish, omitBy } from 'remeda'
4
- import { NodesGroup } from '../compute-view/compute'
5
3
  import { elementExprToPredicate } from './elementExpressionToPredicate'
6
4
 
7
5
  export function flattenGroupRules<T extends Expression>(guard: (expr: Expression) => expr is T) {