@likec4/language-server 1.46.0 → 1.46.2

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.
@@ -1,4 +1,4 @@
1
- import { invariant, isAnyOf, nonNullable } from '@likec4/core/utils';
1
+ import { isAnyOf, nonNullable } from '@likec4/core/utils';
2
2
  import { AbstractSemanticTokenProvider, } from 'langium/lsp';
3
3
  import { isTruthy } from 'remeda';
4
4
  import { SemanticTokenModifiers, SemanticTokenTypes } from 'vscode-languageserver-types';
@@ -109,13 +109,19 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
109
109
  }
110
110
  });
111
111
  when(isAnyOf(ast.isFqnRef, ast.isStrictFqnRef), mark => {
112
- mark.property('value').readonly.definition.variable();
112
+ const text = mark.node.$cstNode?.text ?? '';
113
+ if (text !== '' && text !== 'this' && text !== 'it') {
114
+ mark.property('value').readonly.definition.variable();
115
+ }
113
116
  if (!mark.node.parent) {
114
117
  stopHighlight();
115
118
  }
116
119
  });
117
120
  when(ast.isStrictFqnElementRef, mark => {
118
- mark.property('el').readonly.definition.variable();
121
+ const text = mark.node.el.$refText ?? '';
122
+ if (text !== '') {
123
+ mark.property('el').readonly.definition.variable();
124
+ }
119
125
  if (!mark.node.parent) {
120
126
  stopHighlight();
121
127
  }
@@ -165,34 +171,35 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
165
171
  });
166
172
  }
167
173
  highlightElement(node, acceptor) {
168
- try {
169
- if (isAnyOf(ast.isElement, ast.isDeploymentNode, ast.isDeployedInstance)(node)) {
170
- return this.highlightNameAndKind(node);
171
- }
172
- if (ast.isLikeC4View(node)) {
173
- return this.highlightView(node);
174
- }
175
- if (ast.isAnyProperty(node) &&
176
- !isAnyOf(ast.isMetadataProperty, ast.isElementStyleProperty, ast.isRelationStyleProperty)(node)) {
177
- invariant(node.key);
178
- acceptor({
179
- node,
180
- property: 'key',
181
- type: SemanticTokenTypes.property,
182
- });
183
- }
184
- for (const { predicate, highlightFn } of this.rules) {
185
- if (predicate(node)) {
186
- highlightFn(this.mark(node));
187
- break;
188
- }
189
- }
174
+ if (isAnyOf(ast.isElement, ast.isDeploymentNode, ast.isDeployedInstance)(node)) {
175
+ return this.highlightNameAndKind(node);
176
+ }
177
+ if (ast.isLikeC4View(node)) {
178
+ return this.highlightView(node);
179
+ }
180
+ if (ast.isAnyProperty(node) &&
181
+ !isAnyOf(ast.isMetadataProperty, ast.isElementStyleProperty, ast.isRelationStyleProperty)(node) &&
182
+ isTruthy(node.key)) {
183
+ acceptor({
184
+ node,
185
+ property: 'key',
186
+ type: SemanticTokenTypes.property,
187
+ });
190
188
  }
191
- catch (error) {
192
- if (error === PRUNE) {
193
- return 'prune';
189
+ let m;
190
+ for (const { predicate, highlightFn } of this.rules) {
191
+ if (predicate(node)) {
192
+ try {
193
+ m ??= this.mark(node);
194
+ highlightFn(m);
195
+ }
196
+ catch (error) {
197
+ if (error === PRUNE) {
198
+ return 'prune';
199
+ }
200
+ logger.warn(`Error highlighting node of type ${node._type}`, { error });
201
+ }
194
202
  }
195
- logger.warn(`Error highlighting node of type ${node._type}`, { error });
196
203
  }
197
204
  }
198
205
  highlightNameAndKind(node) {
@@ -79,7 +79,7 @@ export function SpecificationParser(B) {
79
79
  continue;
80
80
  }
81
81
  c4Specification.colors[colorName] = {
82
- color: nonNullable(this.parseColorLiteral(color), `Color "${colorName}" is not valid: ${color}`),
82
+ color: nonNullable(this.parseColorLiteral(color), `Color "${colorName}" is not valid`),
83
83
  };
84
84
  }
85
85
  catch (e) {
@@ -13,9 +13,18 @@ export class IndexManager extends DefaultIndexManager {
13
13
  }
14
14
  projectElements(projectId, nodeType, uris) {
15
15
  const projects = this.services.workspace.ProjectsManager;
16
+ const project = projects.getProject(projectId);
17
+ const includePathStrings = project.includePaths?.map(uri => {
18
+ const path = uri.toString();
19
+ return path.endsWith('/') ? path : path + '/';
20
+ }) ?? [];
16
21
  let documentUris = stream(this.symbolIndex.keys());
17
22
  return documentUris
18
- .filter(uri => projects.belongsTo(uri) === projectId && (!uris || uris.has(uri)))
23
+ .filter(uri => {
24
+ const belongsToProject = projects.belongsTo(uri) === projectId;
25
+ const inIncludePath = includePathStrings.some(includePath => uri.startsWith(includePath));
26
+ return (belongsToProject || inIncludePath) && (!uris || uris.has(uri));
27
+ })
19
28
  .flatMap(uri => this.getFileDescriptions(uri, nodeType));
20
29
  }
21
30
  }
@@ -64,7 +64,25 @@ export class LangiumDocuments extends DefaultLangiumDocuments {
64
64
  });
65
65
  }
66
66
  projectDocuments(projectId) {
67
- return this.allExcludingBuiltin.filter(doc => doc.likec4ProjectId === projectId);
67
+ const projects = this.services.workspace.ProjectsManager;
68
+ const project = projects.getProject(projectId);
69
+ const projectFolder = project.folderUri.toString() + (project.folderUri.path.endsWith('/') ? '' : '/');
70
+ const includePathStrings = project.includePaths?.map(uri => {
71
+ const path = uri.toString();
72
+ return path.endsWith('/') ? path : path + '/';
73
+ }) ?? [];
74
+ return this.allExcludingBuiltin.filter(doc => {
75
+ const docUri = doc.uri.toString();
76
+ // Always include documents from the project's own folder
77
+ if (docUri.startsWith(projectFolder)) {
78
+ return true;
79
+ }
80
+ // Check for addtional documents when the config has the `include:paths` property set.
81
+ if (includePathStrings.length > 0) {
82
+ return includePathStrings.some(includePath => docUri.startsWith(includePath));
83
+ }
84
+ return false;
85
+ });
68
86
  }
69
87
  groupedByProject() {
70
88
  return groupBy(this.allExcludingBuiltin.toArray(), prop('likec4ProjectId'));
@@ -0,0 +1,159 @@
1
+ {
2
+ "name": "@likec4/language-server",
3
+ "description": "LikeC4 Language Server",
4
+ "version": "1.45.0",
5
+ "license": "MIT",
6
+ "bugs": "https://github.com/likec4/likec4/issues",
7
+ "homepage": "https://likec4.dev",
8
+ "author": "Denis Davydkov <denis@davydkov.com>",
9
+ "files": [
10
+ "bin",
11
+ "dist",
12
+ "**/package.json",
13
+ "!**/__mocks__/",
14
+ "!**/__tests__/",
15
+ "!**/*.spec.*",
16
+ "!**/*.map"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/likec4/likec4.git",
21
+ "directory": "packages/language-server"
22
+ },
23
+ "engines": {
24
+ "node": "^20.19.0 || >=22.18.0"
25
+ },
26
+ "engineStrict": true,
27
+ "type": "module",
28
+ "sideEffects": false,
29
+ "bin": {
30
+ "likec4-language-server": "./bin/likec4-language-server.mjs"
31
+ },
32
+ "exports": {
33
+ ".": {
34
+ "sources": "./src/index.ts",
35
+ "default": {
36
+ "types": "./dist/index.d.ts",
37
+ "default": "./dist/index.js"
38
+ }
39
+ },
40
+ "./likec4lib": {
41
+ "sources": "./src/likec4lib.ts",
42
+ "default": {
43
+ "types": "./dist/likec4lib.d.ts",
44
+ "import": "./dist/likec4lib.js",
45
+ "default": "./dist/likec4lib.js"
46
+ }
47
+ },
48
+ "./browser-worker": {
49
+ "sources": "./src/browser-worker.ts",
50
+ "default": {
51
+ "types": "./dist/browser-worker.d.ts",
52
+ "import": "./dist/browser-worker.js",
53
+ "default": "./dist/browser-worker.js"
54
+ }
55
+ },
56
+ "./browser": {
57
+ "sources": "./src/browser.ts",
58
+ "default": {
59
+ "types": "./dist/browser.d.ts",
60
+ "import": "./dist/browser.js",
61
+ "default": "./dist/browser.js"
62
+ }
63
+ },
64
+ "./protocol": {
65
+ "sources": "./src/protocol.ts",
66
+ "default": {
67
+ "types": "./dist/protocol.d.ts",
68
+ "import": "./dist/protocol.js",
69
+ "default": "./dist/protocol.js"
70
+ }
71
+ },
72
+ "./bundled": "./dist/bundled.mjs"
73
+ },
74
+ "publishConfig": {
75
+ "registry": "https://registry.npmjs.org",
76
+ "access": "public",
77
+ "types": "dist/index.d.ts",
78
+ "module": "dist/index.js"
79
+ },
80
+ "scripts": {
81
+ "typecheck": "tsc -b --verbose",
82
+ "build": "unbuild",
83
+ "prepack": "likec4ops prepack",
84
+ "pack": "pnpm pack",
85
+ "postpack": "cp likec4-language-server-$npm_package_version.tgz package.tgz || true",
86
+ "pregenerate": "rm -f src/generated/* || true",
87
+ "watch:langium": "langium generate --watch",
88
+ "watch:ts": "tsc --watch",
89
+ "generate": "langium generate && tsx scripts/generate-icons.ts",
90
+ "dev": "run-p \"watch:*\"",
91
+ "lint": "oxlint --type-aware",
92
+ "lint:fix": "oxlint --type-aware --fix",
93
+ "lint:package": "pnpx publint ./package.tgz",
94
+ "clean": "likec4ops clean contrib src/generated src/generated-lib",
95
+ "test": "vitest run --no-isolate",
96
+ "test-dbg": "vitest run --no-isolate -t formating",
97
+ "vitest:ui": "vitest --no-isolate --ui",
98
+ "test:watch": "vitest"
99
+ },
100
+ "dependencies": {
101
+ "@hpcc-js/wasm-graphviz": "catalog:utils",
102
+ "bundle-require": "catalog:utils",
103
+ "esbuild": "catalog:esbuild"
104
+ },
105
+ "devDependencies": {
106
+ "@hono/node-server": "catalog:hono",
107
+ "@likec4/config": "workspace:*",
108
+ "@likec4/core": "workspace:*",
109
+ "@likec4/devops": "workspace:*",
110
+ "@likec4/icons": "workspace:*",
111
+ "@likec4/layouts": "workspace:*",
112
+ "@likec4/log": "workspace:*",
113
+ "@likec4/tsconfig": "workspace:*",
114
+ "@modelcontextprotocol/sdk": "catalog:mcp",
115
+ "@msgpack/msgpack": "^3.1.2",
116
+ "@smithy/util-base64": "^4.3.0",
117
+ "@types/natural-compare-lite": "catalog:utils",
118
+ "@types/node": "catalog:",
119
+ "@types/picomatch": "catalog:utils",
120
+ "@types/vscode": "catalog:vscode",
121
+ "@types/which": "^3.0.4",
122
+ "chokidar": "catalog:utils",
123
+ "defu": "catalog:utils",
124
+ "esm-env": "catalog:utils",
125
+ "fast-equals": "catalog:utils",
126
+ "fdir": "catalog:utils",
127
+ "fetch-to-node": "^2.1.0",
128
+ "hono": "catalog:hono",
129
+ "immer": "catalog:utils",
130
+ "indent-string": "^5.0.0",
131
+ "json5": "catalog:utils",
132
+ "langium": "catalog:langium",
133
+ "langium-cli": "catalog:langium",
134
+ "nano-spawn": "catalog:utils",
135
+ "natural-compare-lite": "catalog:utils",
136
+ "oxlint": "catalog:",
137
+ "p-debounce": "catalog:utils",
138
+ "p-queue": "catalog:utils",
139
+ "p-timeout": "catalog:utils",
140
+ "picomatch": "catalog:utils",
141
+ "pretty-ms": "^9.2.0",
142
+ "remeda": "catalog:utils",
143
+ "strip-indent": "catalog:utils",
144
+ "tsx": "catalog:",
145
+ "turbo": "catalog:",
146
+ "type-fest": "catalog:utils",
147
+ "typescript": "catalog:",
148
+ "ufo": "catalog:utils",
149
+ "unbuild": "catalog:",
150
+ "vitest": "catalog:vitest",
151
+ "vscode-jsonrpc": "catalog:vscode",
152
+ "vscode-languageserver": "catalog:vscode",
153
+ "vscode-languageserver-protocol": "catalog:vscode",
154
+ "vscode-languageserver-types": "catalog:vscode",
155
+ "vscode-uri": "catalog:vscode",
156
+ "which": "^5.0.0",
157
+ "zod": "catalog:utils"
158
+ }
159
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likec4/language-server",
3
3
  "description": "LikeC4 Language Server",
4
- "version": "1.46.0",
4
+ "version": "1.46.2",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -21,7 +21,7 @@
21
21
  "directory": "packages/language-server"
22
22
  },
23
23
  "engines": {
24
- "node": "^20.19.0 || >=22.18.0"
24
+ "node": ">=22.21.1"
25
25
  },
26
26
  "engineStrict": true,
27
27
  "type": "module",
@@ -78,10 +78,10 @@
78
78
  "dependencies": {
79
79
  "@hpcc-js/wasm-graphviz": "1.16.0",
80
80
  "bundle-require": "^5.1.0",
81
- "esbuild": "0.27.0"
81
+ "esbuild": "0.27.1"
82
82
  },
83
83
  "devDependencies": {
84
- "@hono/node-server": "^1.19.6",
84
+ "@hono/node-server": "^1.19.7",
85
85
  "@modelcontextprotocol/sdk": "^1.22.0",
86
86
  "@msgpack/msgpack": "^3.1.2",
87
87
  "@smithy/util-base64": "^4.3.0",
@@ -96,15 +96,15 @@
96
96
  "fast-equals": "^5.3.3",
97
97
  "fdir": "6.4.0",
98
98
  "fetch-to-node": "^2.1.0",
99
- "hono": "^4.10.7",
100
- "immer": "^10.2.0",
99
+ "hono": "^4.11.1",
100
+ "immer": "^11.0.1",
101
101
  "indent-string": "^5.0.0",
102
102
  "json5": "^2.2.3",
103
103
  "langium": "3.5.0",
104
104
  "langium-cli": "3.5.2",
105
105
  "nano-spawn": "^1.0.3",
106
106
  "natural-compare-lite": "^1.4.0",
107
- "oxlint": "1.31.0",
107
+ "oxlint": "1.33.0",
108
108
  "p-debounce": "4.0.0",
109
109
  "p-queue": "8.1.1",
110
110
  "p-timeout": "6.1.4",
@@ -118,7 +118,7 @@
118
118
  "typescript": "5.9.3",
119
119
  "ufo": "1.6.1",
120
120
  "unbuild": "3.5.0",
121
- "vitest": "4.0.15",
121
+ "vitest": "4.0.16",
122
122
  "vscode-jsonrpc": "8.2.1",
123
123
  "vscode-languageserver": "9.0.1",
124
124
  "vscode-languageserver-protocol": "3.17.5",
@@ -126,13 +126,13 @@
126
126
  "vscode-uri": "3.1.0",
127
127
  "which": "^5.0.0",
128
128
  "zod": "^3.25.76",
129
- "@likec4/config": "1.46.0",
130
- "@likec4/core": "1.46.0",
131
- "@likec4/devops": "1.42.0",
132
- "@likec4/icons": "1.46.0",
133
- "@likec4/layouts": "1.46.0",
134
- "@likec4/log": "1.46.0",
135
- "@likec4/tsconfig": "1.46.0"
129
+ "@likec4/config": "1.46.2",
130
+ "@likec4/layouts": "1.46.2",
131
+ "@likec4/log": "1.46.1",
132
+ "@likec4/icons": "1.46.1",
133
+ "@likec4/core": "1.46.2",
134
+ "@likec4/tsconfig": "1.46.1",
135
+ "@likec4/devops": "1.42.0"
136
136
  },
137
137
  "scripts": {
138
138
  "typecheck": "tsc -b --verbose",