@likec4/language-server 0.43.0 → 0.44.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.
- package/README.md +2 -2
- package/dist/Rpc.js +2 -1
- package/dist/model/fqn-index.js +15 -7
- package/dist/model/model-builder.d.ts +0 -2
- package/dist/model/model-builder.js +6 -12
- package/dist/model/model-parser.d.ts +1 -1
- package/dist/model/model-parser.js +3 -0
- package/dist/module.js +3 -4
- package/dist/validation/index.js +1 -13
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@likec4/language-server`
|
|
2
2
|
|
|
3
|
-
[docs](https://likec4.dev/docs/) | [
|
|
3
|
+
[docs](https://likec4.dev/docs/) | [playground](https://likec4.dev/playground/) | [demo](https://template.likec4.dev/view/cloud)
|
|
4
4
|
|
|
5
5
|
Language Server Protocol (LSP) based on [languim](https://github.com/languim/languim) library.
|
package/dist/Rpc.js
CHANGED
|
@@ -85,6 +85,7 @@ export class Rpc {
|
|
|
85
85
|
`[ServerRpc] received request to buildDocuments:
|
|
86
86
|
${docs.map((d) => " - " + d).join("\n")}`
|
|
87
87
|
);
|
|
88
|
+
const deleted = LangiumDocuments.all.filter((d) => !docs.includes(d.uri.toString())).map((d) => d.uri).toArray();
|
|
88
89
|
const changed = [];
|
|
89
90
|
for (const d of docs) {
|
|
90
91
|
try {
|
|
@@ -112,7 +113,7 @@ We rebuild: [
|
|
|
112
113
|
`.trim()
|
|
113
114
|
);
|
|
114
115
|
}
|
|
115
|
-
await DocumentBuilder.update(changed,
|
|
116
|
+
await DocumentBuilder.update(changed, deleted, cancelToken);
|
|
116
117
|
});
|
|
117
118
|
connection.onRequest(locate, (params) => {
|
|
118
119
|
if ("element" in params) {
|
package/dist/model/fqn-index.js
CHANGED
|
@@ -12,12 +12,20 @@ export class FqnIndex {
|
|
|
12
12
|
langiumDocuments;
|
|
13
13
|
constructor(services) {
|
|
14
14
|
this.langiumDocuments = services.shared.workspace.LangiumDocuments;
|
|
15
|
-
services.shared.workspace.DocumentBuilder.
|
|
16
|
-
|
|
17
|
-
(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
services.shared.workspace.DocumentBuilder.onUpdate((changed, deleted) => {
|
|
16
|
+
const message = [`[FqnIndex] onUpdate`];
|
|
17
|
+
if (changed.length > 0) {
|
|
18
|
+
message.push(` changed:`);
|
|
19
|
+
changed.forEach((u) => message.push(` - ${u}`));
|
|
20
|
+
}
|
|
21
|
+
if (deleted.length > 0) {
|
|
22
|
+
message.push(` deleted:`);
|
|
23
|
+
deleted.forEach((u) => message.push(` - ${u}`));
|
|
24
|
+
}
|
|
25
|
+
logger.debug(message.join("\n"));
|
|
26
|
+
for (const uri of changed) {
|
|
27
|
+
if (this.langiumDocuments.hasDocument(uri)) {
|
|
28
|
+
const doc = this.langiumDocuments.getOrCreateDocument(uri);
|
|
21
29
|
if (isLikeC4LangiumDocument(doc)) {
|
|
22
30
|
delete doc.c4fqns;
|
|
23
31
|
delete doc.c4Elements;
|
|
@@ -27,7 +35,7 @@ export class FqnIndex {
|
|
|
27
35
|
}
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
|
-
);
|
|
38
|
+
});
|
|
31
39
|
services.shared.workspace.DocumentBuilder.onBuildPhase(
|
|
32
40
|
DocumentState.IndexedContent,
|
|
33
41
|
(docs, _cancelToken) => {
|
|
@@ -6,10 +6,8 @@ type ModelParsedListener = (docs: URI[]) => void;
|
|
|
6
6
|
export declare class LikeC4ModelBuilder {
|
|
7
7
|
private services;
|
|
8
8
|
private langiumDocuments;
|
|
9
|
-
private workspaceManager;
|
|
10
9
|
private listeners;
|
|
11
10
|
constructor(services: LikeC4Services);
|
|
12
|
-
get workspaceUri(): string | null;
|
|
13
11
|
buildRawModel(): c4.LikeC4RawModel | null;
|
|
14
12
|
buildModel(): c4.LikeC4Model | null;
|
|
15
13
|
computeView(viewId: ViewID): c4.ComputedView | null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
compareByFqnHierarchically,
|
|
3
|
-
invariant,
|
|
4
3
|
isStrictElementView,
|
|
5
4
|
parentFqn
|
|
6
5
|
} from "@likec4/core";
|
|
6
|
+
import { LikeC4ModelGraph, computeView } from "@likec4/graph";
|
|
7
7
|
import {
|
|
8
8
|
DocumentState,
|
|
9
9
|
interruptAndCheck
|
|
@@ -12,10 +12,8 @@ import * as R from "remeda";
|
|
|
12
12
|
import { Disposable } from "vscode-languageserver";
|
|
13
13
|
import { isValidLikeC4LangiumDocument } from "../ast.js";
|
|
14
14
|
import { logError, logWarnError, logger } from "../logger.js";
|
|
15
|
-
import {
|
|
16
|
-
import { printDocs, queueMicrotask } from "../utils.js";
|
|
15
|
+
import { printDocs } from "../utils.js";
|
|
17
16
|
import { assignNavigateTo, resolveRelativePaths, resolveRulesExtendedViews } from "../view-utils/index.js";
|
|
18
|
-
import { LikeC4ModelGraph, computeView } from "@likec4/graph";
|
|
19
17
|
function isRelativeLink(link) {
|
|
20
18
|
return link.startsWith(".") || link.startsWith("/");
|
|
21
19
|
}
|
|
@@ -162,24 +160,20 @@ export class LikeC4ModelBuilder {
|
|
|
162
160
|
constructor(services) {
|
|
163
161
|
this.services = services;
|
|
164
162
|
this.langiumDocuments = services.shared.workspace.LangiumDocuments;
|
|
165
|
-
invariant(services.shared.workspace.WorkspaceManager instanceof LikeC4WorkspaceManager);
|
|
166
|
-
this.workspaceManager = services.shared.workspace.WorkspaceManager;
|
|
167
163
|
const parser = services.likec4.ModelParser;
|
|
168
164
|
services.shared.workspace.DocumentBuilder.onBuildPhase(
|
|
169
165
|
DocumentState.Validated,
|
|
170
166
|
async (docs, cancelToken) => {
|
|
171
|
-
|
|
167
|
+
const parsed = parser.parse(docs).map((d) => d.uri);
|
|
172
168
|
await interruptAndCheck(cancelToken);
|
|
173
|
-
|
|
169
|
+
if (parsed.length > 0) {
|
|
170
|
+
this.notifyListeners(parsed);
|
|
171
|
+
}
|
|
174
172
|
}
|
|
175
173
|
);
|
|
176
174
|
}
|
|
177
175
|
langiumDocuments;
|
|
178
|
-
workspaceManager;
|
|
179
176
|
listeners = [];
|
|
180
|
-
get workspaceUri() {
|
|
181
|
-
return this.workspaceManager.workspace()?.uri ?? null;
|
|
182
|
-
}
|
|
183
177
|
buildRawModel() {
|
|
184
178
|
const cache = this.services.WorkspaceCache;
|
|
185
179
|
return cache.get(RAW_MODEL_CACHE, () => {
|
|
@@ -8,7 +8,7 @@ export declare class LikeC4ModelParser {
|
|
|
8
8
|
private services;
|
|
9
9
|
private fqnIndex;
|
|
10
10
|
constructor(services: LikeC4Services);
|
|
11
|
-
parse(doc: LangiumDocument | LangiumDocument[]):
|
|
11
|
+
parse(doc: LangiumDocument | LangiumDocument[]): LikeC4LangiumDocument[];
|
|
12
12
|
protected parseLikeC4Document(doc: LikeC4LangiumDocument): void;
|
|
13
13
|
private parseElement;
|
|
14
14
|
private parseRelation;
|
|
@@ -27,16 +27,19 @@ export class LikeC4ModelParser {
|
|
|
27
27
|
const docs = Array.isArray(doc) ? doc : [doc];
|
|
28
28
|
logger.debug(`[ModelParser] onValidated (${docs.length} docs)
|
|
29
29
|
${printDocs(docs)}`);
|
|
30
|
+
const result = [];
|
|
30
31
|
for (const doc2 of docs) {
|
|
31
32
|
if (!isLikeC4LangiumDocument(doc2)) {
|
|
32
33
|
continue;
|
|
33
34
|
}
|
|
34
35
|
try {
|
|
35
36
|
this.parseLikeC4Document(doc2);
|
|
37
|
+
result.push(doc2);
|
|
36
38
|
} catch (cause) {
|
|
37
39
|
logError(new InvalidModelError(`Error parsing document ${doc2.uri.toString()}`, { cause }));
|
|
38
40
|
}
|
|
39
41
|
}
|
|
42
|
+
return result;
|
|
40
43
|
}
|
|
41
44
|
parseLikeC4Document(doc) {
|
|
42
45
|
const { elements, relations, views, specification } = cleanParsedModel(doc);
|
package/dist/module.js
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import { FqnIndex, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser } from "./model/index.js";
|
|
14
14
|
import { LikeC4ScopeComputation, LikeC4ScopeProvider } from "./references/index.js";
|
|
15
15
|
import { Rpc } from "./Rpc.js";
|
|
16
|
-
import { LikeC4WorkspaceManager } from "./shared/index.js";
|
|
17
16
|
import { registerValidationChecks } from "./validation/index.js";
|
|
18
17
|
import { logger } from "./logger.js";
|
|
19
18
|
import { serializeError } from "@likec4/core";
|
|
@@ -42,9 +41,9 @@ export const LikeC4Module = {
|
|
|
42
41
|
}
|
|
43
42
|
};
|
|
44
43
|
const LikeC4SharedModule = {
|
|
45
|
-
workspace: {
|
|
46
|
-
|
|
47
|
-
}
|
|
44
|
+
// workspace: {
|
|
45
|
+
// WorkspaceManager: services => new LikeC4WorkspaceManager(services)
|
|
46
|
+
// }
|
|
48
47
|
};
|
|
49
48
|
export function createLanguageServices(context) {
|
|
50
49
|
const connection = context?.connection;
|
package/dist/validation/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as vscodeUri from "vscode-uri";
|
|
2
1
|
import { logger } from "../logger.js";
|
|
3
2
|
import { elementChecks } from "./element.js";
|
|
4
3
|
import { relationChecks } from "./relation.js";
|
|
5
|
-
import { elementKindChecks,
|
|
4
|
+
import { elementKindChecks, relationshipChecks, tagChecks } from "./specification.js";
|
|
6
5
|
import { viewChecks } from "./view.js";
|
|
7
6
|
import { incomingExpressionChecks, outgoingExpressionChecks } from "./view-predicates/index.js";
|
|
8
7
|
export function registerValidationChecks(services) {
|
|
@@ -20,18 +19,7 @@ export function registerValidationChecks(services) {
|
|
|
20
19
|
});
|
|
21
20
|
const connection = services.shared.lsp.Connection;
|
|
22
21
|
if (connection) {
|
|
23
|
-
logger.info("registerValidationChecks");
|
|
24
22
|
services.shared.workspace.DocumentBuilder.onUpdate((changed, deleted) => {
|
|
25
|
-
const message = [`[DocumentBuilder.onUpdate]`];
|
|
26
|
-
if (changed.length > 0) {
|
|
27
|
-
message.push(` changed:`);
|
|
28
|
-
changed.forEach((u) => message.push(` - ${vscodeUri.Utils.basename(u)}`));
|
|
29
|
-
}
|
|
30
|
-
if (deleted.length > 0) {
|
|
31
|
-
message.push(` deleted:`);
|
|
32
|
-
deleted.forEach((u) => message.push(` - ${vscodeUri.Utils.basename(u)}`));
|
|
33
|
-
}
|
|
34
|
-
logger.debug(message.join("\n"));
|
|
35
23
|
for (const uri of deleted) {
|
|
36
24
|
void connection.sendDiagnostics({
|
|
37
25
|
uri: uri.toString(),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/language-server",
|
|
3
3
|
"description": "LikeC4 Language Server",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.44.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
7
7
|
"homepage": "https://likec4.dev",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"test": "vitest run"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@likec4/core": "0.
|
|
54
|
-
"@likec4/graph": "0.
|
|
53
|
+
"@likec4/core": "0.44.0",
|
|
54
|
+
"@likec4/graph": "0.44.0",
|
|
55
55
|
"langium": "^2.0.2",
|
|
56
56
|
"object-hash": "^3.0.0",
|
|
57
57
|
"p-debounce": "^4.0.0",
|