@likec4/language-server 1.2.2 → 1.4.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 (36) hide show
  1. package/package.json +19 -8
  2. package/src/ast.ts +2 -0
  3. package/src/generated/ast.ts +157 -123
  4. package/src/generated/grammar.ts +2 -2
  5. package/src/generated/module.ts +1 -1
  6. package/src/like-c4.langium +53 -34
  7. package/src/logger.ts +21 -7
  8. package/src/lsp/CompletionProvider.ts +7 -0
  9. package/src/lsp/SemanticTokenProvider.ts +78 -17
  10. package/src/lsp/index.ts +1 -0
  11. package/src/model/model-builder.ts +3 -39
  12. package/src/model/model-parser.ts +19 -4
  13. package/src/model-change/ModelChanges.ts +58 -53
  14. package/src/model-change/changeElementStyle.ts +5 -6
  15. package/src/model-change/saveManualLayout.ts +43 -0
  16. package/src/model-graph/LikeC4ModelGraph.ts +304 -0
  17. package/src/model-graph/compute-view/__test__/fixture.ts +438 -0
  18. package/src/model-graph/compute-view/compute.ts +430 -0
  19. package/src/model-graph/compute-view/index.ts +33 -0
  20. package/src/model-graph/compute-view/predicates.ts +404 -0
  21. package/src/model-graph/dynamic-view/__test__/fixture.ts +56 -0
  22. package/src/model-graph/dynamic-view/compute.ts +198 -0
  23. package/src/model-graph/dynamic-view/index.ts +29 -0
  24. package/src/model-graph/index.ts +3 -0
  25. package/src/model-graph/utils/applyElementCustomProperties.ts +49 -0
  26. package/src/model-graph/utils/applyViewRuleStyles.ts +68 -0
  27. package/src/model-graph/utils/buildComputeNodes.ts +61 -0
  28. package/src/model-graph/utils/sortNodes.ts +105 -0
  29. package/src/module.ts +3 -0
  30. package/src/protocol.ts +3 -18
  31. package/src/references/scope-computation.ts +29 -11
  32. package/src/references/scope-provider.ts +22 -16
  33. package/src/validation/view.ts +9 -4
  34. package/src/view-utils/manual-layout.ts +93 -0
  35. package/contrib/likec4.monarch.ts +0 -41
  36. package/src/lsp/DocumentLinkProvider.test.ts +0 -66
@@ -1,66 +0,0 @@
1
- import { beforeAll, describe, expect, it, vi } from 'vitest'
2
- import type { LikeC4LangiumDocument } from '../ast'
3
- import type { LikeC4Services } from '../module'
4
- import { createTestServices } from '../test'
5
- import type { LikeC4DocumentLinkProvider } from './DocumentLinkProvider'
6
-
7
- vi.mock('../logger')
8
-
9
- describe('DocumentLinkProvider', () => {
10
- let services: LikeC4Services
11
- let doc: LikeC4LangiumDocument
12
- let documentLinkProvider: LikeC4DocumentLinkProvider
13
-
14
- beforeAll(async () => {
15
- const test = createTestServices('vscode-vfs://host/virtual')
16
- services = test.services
17
- documentLinkProvider = services.lsp.DocumentLinkProvider
18
- doc = await test.parse(
19
- `
20
- specification {
21
- element component
22
- }
23
- `,
24
- 'dir1/doc.c4'
25
- )
26
- })
27
-
28
- it('test should have correct doc uri and workspace uri', () => {
29
- expect(services.shared.workspace.WorkspaceManager.workspaceUri.toString()).toBe(
30
- 'vscode-vfs://host/virtual'
31
- )
32
- expect(services.shared.workspace.WorkspaceManager.workspaceURL.toString()).toBe(
33
- 'vscode-vfs://host/virtual'
34
- )
35
- expect(doc.uri.toString()).toBe('vscode-vfs://host/virtual/src/dir1/doc.c4')
36
- })
37
-
38
- it('should return the link unchanged if it has a protocol', () => {
39
- const link = 'http://example.com/link'
40
- expect(documentLinkProvider.resolveLink(doc, link)).toBe(link)
41
- })
42
-
43
- it('should resolve a relative link against the document URI', () => {
44
- const link = './relative/link#fragment'
45
- const expected = 'vscode-vfs://host/virtual/src/dir1/relative/link#fragment'
46
- expect(documentLinkProvider.resolveLink(doc, link)).toBe(expected)
47
- })
48
-
49
- it('should resolve a parent relative link against the document URI', () => {
50
- const link = '../dir2/link?query=1#L1=22'
51
- const expected = 'vscode-vfs://host/virtual/src/dir2/link?query=1#L1=22'
52
- expect(documentLinkProvider.resolveLink(doc, link)).toBe(expected)
53
- })
54
-
55
- it('should resolve a link against the workspace URL', () => {
56
- const link = '/root'
57
- const expected = 'vscode-vfs://host/virtual/root'
58
- expect(documentLinkProvider.resolveLink(doc, link)).toBe(expected)
59
- })
60
-
61
- it('should resolve a link with quary and hash against the workspace URL', () => {
62
- const link = '/root/a/b/c/link?query=1#L1=22'
63
- const expected = 'vscode-vfs://host/virtual/root/a/b/c/link?query=1#L1=22'
64
- expect(documentLinkProvider.resolveLink(doc, link)).toBe(expected)
65
- })
66
- })