@likec4/language-server 0.4.0 → 0.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.
@@ -0,0 +1,53 @@
1
+ import { resolveRelationPoints } from '../ast';
2
+ import { isSameHierarchy } from '@likec4/core/utils';
3
+ export const relationChecks = (services) => {
4
+ const fqnIndex = services.likec4.FqnIndex;
5
+ return (el, accept) => {
6
+ try {
7
+ const coupling = resolveRelationPoints(el);
8
+ const target = fqnIndex.get(coupling.target);
9
+ if (!target) {
10
+ return accept('error', 'Invalid target', {
11
+ node: el,
12
+ property: 'target'
13
+ });
14
+ }
15
+ const source = fqnIndex.get(coupling.source);
16
+ if (!source) {
17
+ return accept('error', 'Invalid source', {
18
+ node: el
19
+ });
20
+ }
21
+ if (isSameHierarchy(source, target)) {
22
+ return accept('error', 'Invalid relation (same hierarchy)', {
23
+ node: el
24
+ });
25
+ }
26
+ }
27
+ catch (e) {
28
+ if (e instanceof Error) {
29
+ return accept('error', e.message, {
30
+ node: el
31
+ });
32
+ }
33
+ accept('error', 'Invalid relation', {
34
+ node: el
35
+ });
36
+ }
37
+ // const fqn = fqnIndex.get(el)
38
+ // if (!fqn) {
39
+ // accept('error', 'Not indexed', {
40
+ // node: el,
41
+ // property: 'name',
42
+ // })
43
+ // return
44
+ // }
45
+ // const withSameFqn = fqnIndex.byFqn(fqn)
46
+ // if (withSameFqn.length > 1) {
47
+ // accept('error', `Duplicate element name ${el.name !== fqn ? el.name +' (' + fqn + ')' : el.name}`, {
48
+ // node: el,
49
+ // property: 'name',
50
+ // })
51
+ // }
52
+ };
53
+ };
@@ -2,14 +2,15 @@ import { ast } from '../ast';
2
2
  export const elementKindChecks = (services) => {
3
3
  const index = services.shared.workspace.IndexManager;
4
4
  return (node, accept) => {
5
- const sameKinds = index.allElements(ast.ElementKind)
5
+ const sameKinds = index
6
+ .allElements(ast.ElementKind)
6
7
  .filter(n => n.name === node.name)
7
8
  .limit(2)
8
9
  .count();
9
10
  if (sameKinds > 1) {
10
11
  accept('error', `Duplicate element kind '${node.name}'`, {
11
12
  node: node,
12
- property: 'name',
13
+ property: 'name'
13
14
  });
14
15
  }
15
16
  };
@@ -17,14 +18,15 @@ export const elementKindChecks = (services) => {
17
18
  export const tagChecks = (services) => {
18
19
  const index = services.shared.workspace.IndexManager;
19
20
  return (node, accept) => {
20
- const sameKinds = index.allElements(ast.Tag)
21
+ const sameKinds = index
22
+ .allElements(ast.Tag)
21
23
  .filter(n => n.name === node.name)
22
24
  .limit(2)
23
25
  .count();
24
26
  if (sameKinds > 1) {
25
27
  accept('error', `Duplicate tag '${node.name}'`, {
26
28
  node: node,
27
- property: 'name',
29
+ property: 'name'
28
30
  });
29
31
  }
30
32
  };
@@ -5,7 +5,8 @@ export const viewChecks = (services) => {
5
5
  if (!el.name) {
6
6
  return;
7
7
  }
8
- const anotherViews = index.allElements(ast.View)
8
+ const anotherViews = index
9
+ .allElements(ast.View)
9
10
  .filter(n => n.name === el.name)
10
11
  .limit(2)
11
12
  .count();
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "@likec4/language-server",
3
- "version": "0.4.0",
3
+ "description": "LikeC4 Language Server",
4
+ "version": "0.6.0",
5
+ "license": "MIT",
4
6
  "type": "module",
5
7
  "bugs": "https://github.com/likec4/likec4/issues",
6
8
  "homepage": "https://like-c4.dev",
@@ -10,7 +12,8 @@
10
12
  ],
11
13
  "repository": {
12
14
  "type": "git",
13
- "url": "https://github.com/likec4/likec4.git"
15
+ "url": "https://github.com/likec4/likec4.git",
16
+ "directory": "packages/language-server"
14
17
  },
15
18
  "main": "./dist/index.js",
16
19
  "types": "./dist/index.d.ts",
@@ -24,6 +27,11 @@
24
27
  "types": "./dist/protocol.d.ts",
25
28
  "import": "./dist/protocol.js",
26
29
  "require": "./dist/protocol.cjs"
30
+ },
31
+ "./builtin": {
32
+ "types": "./dist/builtin.d.ts",
33
+ "import": "./dist/builtin.js",
34
+ "require": "./dist/builtin.cjs"
27
35
  }
28
36
  },
29
37
  "publishConfig": {
@@ -41,6 +49,11 @@
41
49
  "types": "./dist/protocol.d.ts",
42
50
  "import": "./dist/protocol.js",
43
51
  "require": "./dist/protocol.cjs"
52
+ },
53
+ "./builtin": {
54
+ "types": "./dist/builtin.d.ts",
55
+ "import": "./dist/builtin.js",
56
+ "require": "./dist/builtin.cjs"
44
57
  }
45
58
  }
46
59
  },
@@ -53,14 +66,14 @@
53
66
  "watch:ts": "tsc --watch",
54
67
  "generate": "langium generate",
55
68
  "build": "run-s 'build:langium' 'build:ts'",
56
- "dev": "run-p 'watch:*'",
69
+ "dev": "run generate && run-p 'watch:*'",
57
70
  "lint": "run -T eslint src/ --fix",
58
- "clean": "rimraf dist",
71
+ "clean": "run -T rimraf dist contrib",
59
72
  "test": "vitest run",
60
73
  "test:watch": "vitest"
61
74
  },
62
75
  "dependencies": {
63
- "@likec4/core": "0.4.0",
76
+ "@likec4/core": "0.6.0",
64
77
  "@mobily/ts-belt": "^3.13.1",
65
78
  "langium": "^1.1.0",
66
79
  "nanoid": "^4.0.2",
@@ -68,7 +81,7 @@
68
81
  "rambdax": "^9.1.0",
69
82
  "strip-indent": "^4.0.0",
70
83
  "tiny-invariant": "^1.3.1",
71
- "type-fest": "^3.7.2",
84
+ "type-fest": "^3.8.0",
72
85
  "vscode-languageserver-protocol": "3.17.2",
73
86
  "vscode-uri": "3.0.7"
74
87
  },
@@ -77,8 +90,8 @@
77
90
  "@types/object-hash": "^3.0.2",
78
91
  "langium-cli": "^1.1.0",
79
92
  "npm-run-all": "^4.1.5",
80
- "typescript": "^5.0.3",
81
- "vite": "^4.2.1",
93
+ "typescript": "^5.0.4",
94
+ "vite": "^4.2.2",
82
95
  "vitest": "^0.30.1"
83
96
  }
84
97
  }
File without changes