@likec4/language-server 1.21.0 → 1.22.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 +4 -1
- package/bin/likec4-language-server.mjs +5 -2
- package/dist/LikeC4FileSystem.js +2 -2
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +17 -2
- package/dist/bundled.d.ts +8 -0
- package/dist/bundled.js +25 -0
- package/dist/bundled.mjs +2587 -4306
- package/dist/generated-lib/icons.js +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +23 -2
- package/dist/logger.d.ts +9 -3
- package/dist/logger.js +35 -55
- package/dist/model/fqn-computation.js +2 -2
- package/dist/model/model-builder.js +13 -14
- package/dist/model-change/ModelChanges.js +2 -2
- package/dist/module.js +1 -4
- package/dist/references/scope-provider.js +3 -3
- package/dist/view-utils/manual-layout.js +2 -2
- package/dist/views/configurable-layouter.js +4 -4
- package/dist/views/likec4-views.d.ts +2 -1
- package/dist/views/likec4-views.js +2 -2
- package/package.json +14 -14
- package/dist/test/setup.d.ts +0 -1
- package/dist/test/setup.js +0 -7
- package/src/LikeC4FileSystem.ts +0 -38
- package/src/Rpc.ts +0 -134
- package/src/ast.ts +0 -556
- package/src/browser.ts +0 -35
- package/src/documentation/documentation-provider.ts +0 -52
- package/src/documentation/index.ts +0 -1
- package/src/formatting/LikeC4Formatter.ts +0 -639
- package/src/formatting/utils.ts +0 -26
- package/src/generated/ast.ts +0 -3735
- package/src/generated/grammar.ts +0 -10
- package/src/generated/module.ts +0 -33
- package/src/generated-lib/icons.ts +0 -1537
- package/src/index.ts +0 -30
- package/src/like-c4.langium +0 -901
- package/src/likec4lib.ts +0 -6
- package/src/logger.ts +0 -80
- package/src/lsp/CodeLensProvider.ts +0 -50
- package/src/lsp/CompletionProvider.ts +0 -147
- package/src/lsp/DocumentHighlightProvider.ts +0 -12
- package/src/lsp/DocumentLinkProvider.ts +0 -65
- package/src/lsp/DocumentSymbolProvider.ts +0 -313
- package/src/lsp/HoverProvider.ts +0 -92
- package/src/lsp/RenameProvider.ts +0 -8
- package/src/lsp/SemanticTokenProvider.ts +0 -383
- package/src/lsp/index.ts +0 -8
- package/src/model/deployments-index.ts +0 -209
- package/src/model/fqn-computation.ts +0 -83
- package/src/model/fqn-index.ts +0 -138
- package/src/model/index.ts +0 -6
- package/src/model/model-builder.ts +0 -724
- package/src/model/model-locator.ts +0 -146
- package/src/model/model-parser-where.ts +0 -84
- package/src/model/model-parser.ts +0 -86
- package/src/model/parser/Base.ts +0 -113
- package/src/model/parser/DeploymentModelParser.ts +0 -192
- package/src/model/parser/DeploymentViewParser.ts +0 -122
- package/src/model/parser/FqnRefParser.ts +0 -143
- package/src/model/parser/GlobalsParser.ts +0 -96
- package/src/model/parser/ModelParser.ts +0 -170
- package/src/model/parser/PredicatesParser.ts +0 -315
- package/src/model/parser/SpecificationParser.ts +0 -133
- package/src/model/parser/ViewsParser.ts +0 -428
- package/src/model-change/ModelChanges.ts +0 -101
- package/src/model-change/changeElementStyle.ts +0 -172
- package/src/model-change/changeViewLayout.ts +0 -47
- package/src/model-change/saveManualLayout.ts +0 -41
- package/src/module.ts +0 -255
- package/src/protocol.ts +0 -93
- package/src/references/index.ts +0 -3
- package/src/references/name-provider.ts +0 -37
- package/src/references/scope-computation.ts +0 -364
- package/src/references/scope-provider.ts +0 -201
- package/src/shared/NodeKindProvider.ts +0 -121
- package/src/shared/WorkspaceManager.ts +0 -48
- package/src/shared/WorkspaceSymbolProvider.ts +0 -3
- package/src/shared/index.ts +0 -3
- package/src/test/index.ts +0 -1
- package/src/test/setup.ts +0 -8
- package/src/test/testServices.ts +0 -152
- package/src/utils/disposable.ts +0 -30
- package/src/utils/elementRef.ts +0 -26
- package/src/utils/fqnRef.ts +0 -56
- package/src/utils/index.ts +0 -2
- package/src/utils/printDocs.ts +0 -3
- package/src/utils/stringHash.ts +0 -6
- package/src/validation/_shared.ts +0 -29
- package/src/validation/deployment-checks.ts +0 -131
- package/src/validation/dynamic-view-rule.ts +0 -23
- package/src/validation/dynamic-view-step.ts +0 -36
- package/src/validation/element.ts +0 -56
- package/src/validation/index.ts +0 -171
- package/src/validation/property-checks.ts +0 -52
- package/src/validation/relation.ts +0 -63
- package/src/validation/specification.ts +0 -205
- package/src/validation/view-predicates/element-with.ts +0 -36
- package/src/validation/view-predicates/expanded-element.ts +0 -16
- package/src/validation/view-predicates/expression-v2.ts +0 -101
- package/src/validation/view-predicates/incoming.ts +0 -20
- package/src/validation/view-predicates/index.ts +0 -6
- package/src/validation/view-predicates/outgoing.ts +0 -20
- package/src/validation/view-predicates/relation-with.ts +0 -17
- package/src/validation/view.ts +0 -37
- package/src/view-utils/assignNavigateTo.ts +0 -31
- package/src/view-utils/index.ts +0 -2
- package/src/view-utils/manual-layout.ts +0 -116
- package/src/view-utils/resolve-relative-paths.ts +0 -90
- package/src/views/configurable-layouter.ts +0 -65
- package/src/views/index.ts +0 -1
- package/src/views/likec4-views.ts +0 -139
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { LikeC4FileSystem } from './LikeC4FileSystem';
|
|
2
2
|
import { type LikeC4Services, type LikeC4SharedServices } from './module';
|
|
3
|
-
export { logger as lspLogger
|
|
3
|
+
export { getLspConnectionSink, logger as lspLogger } from './logger';
|
|
4
4
|
export type { DocumentParser, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser } from './model';
|
|
5
5
|
export { createCustomLanguageServices, createLanguageServices, LikeC4Module } from './module';
|
|
6
6
|
export type { LikeC4Services, LikeC4SharedServices } from './module';
|
|
7
7
|
export type { LikeC4Views } from './views';
|
|
8
8
|
export { LikeC4FileSystem };
|
|
9
|
-
export declare function startLanguageServer(): {
|
|
9
|
+
export declare function startLanguageServer(): Promise<{
|
|
10
10
|
shared: LikeC4SharedServices;
|
|
11
11
|
likec4: LikeC4Services;
|
|
12
|
-
}
|
|
12
|
+
}>;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
|
+
import { configureLogger, getConsoleSink, getTextFormatter } from "@likec4/log";
|
|
1
2
|
import { startLanguageServer as startLanguim } from "langium/lsp";
|
|
2
3
|
import { createConnection, ProposedFeatures } from "vscode-languageserver/node";
|
|
3
4
|
import { LikeC4FileSystem } from "./LikeC4FileSystem.js";
|
|
5
|
+
import { getLspConnectionSink, logger } from "./logger.js";
|
|
4
6
|
import { createCustomLanguageServices } from "./module.js";
|
|
5
7
|
import { ConfigurableLayouter } from "./views/configurable-layouter.js";
|
|
6
|
-
export { logger as lspLogger
|
|
8
|
+
export { getLspConnectionSink, logger as lspLogger } from "./logger.js";
|
|
7
9
|
export { createCustomLanguageServices, createLanguageServices, LikeC4Module } from "./module.js";
|
|
8
10
|
export { LikeC4FileSystem };
|
|
9
|
-
export function startLanguageServer() {
|
|
11
|
+
export async function startLanguageServer() {
|
|
10
12
|
const connection = createConnection(ProposedFeatures.all);
|
|
13
|
+
const isDebug = process.env.NODE_ENV === "development";
|
|
14
|
+
await configureLogger({
|
|
15
|
+
sinks: {
|
|
16
|
+
console: getConsoleSink({
|
|
17
|
+
formatter: getTextFormatter()
|
|
18
|
+
}),
|
|
19
|
+
lsp: getLspConnectionSink(connection)
|
|
20
|
+
},
|
|
21
|
+
// filters: {
|
|
22
|
+
// errors: 'error'
|
|
23
|
+
// },
|
|
24
|
+
loggers: [
|
|
25
|
+
{
|
|
26
|
+
category: ["likec4"],
|
|
27
|
+
sinks: ["console", "lsp"]
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
logger.info("Starting LikeC4 language server");
|
|
11
32
|
const services = createCustomLanguageServices({ connection, ...LikeC4FileSystem }, ConfigurableLayouter);
|
|
12
33
|
startLanguim(services.shared);
|
|
13
34
|
return services;
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Sink, type TextFormatter } from '@likec4/log';
|
|
2
2
|
import type { Connection } from 'vscode-languageserver';
|
|
3
3
|
export declare const logger: any;
|
|
4
4
|
export declare function logError(err: unknown): void;
|
|
@@ -6,5 +6,11 @@ export declare function logError(err: unknown): void;
|
|
|
6
6
|
* Logs an error as warning (not critical)
|
|
7
7
|
*/
|
|
8
8
|
export declare function logWarnError(err: unknown): void;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
type LspConnectionSinkProps = {
|
|
10
|
+
/**
|
|
11
|
+
* The text formatter to use. Defaults to {@link defaultTextFormatter}.
|
|
12
|
+
*/
|
|
13
|
+
formatter?: TextFormatter;
|
|
14
|
+
};
|
|
15
|
+
export declare function getLspConnectionSink(connection: Connection, props?: LspConnectionSinkProps): Sink;
|
|
16
|
+
export {};
|
package/dist/logger.js
CHANGED
|
@@ -1,69 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
errorFromLogRecord,
|
|
3
|
+
getMessageOnlyFormatter,
|
|
4
|
+
getTextFormatter,
|
|
5
|
+
loggable,
|
|
6
|
+
logger as root
|
|
7
|
+
} from "@likec4/log";
|
|
8
|
+
export const logger = root.getChild("server");
|
|
5
9
|
export function logError(err) {
|
|
6
|
-
logger.error(err);
|
|
10
|
+
logger.error(loggable(err));
|
|
7
11
|
}
|
|
8
12
|
export function logWarnError(err) {
|
|
9
|
-
logger.warn(err);
|
|
13
|
+
logger.warn(loggable(err));
|
|
10
14
|
}
|
|
11
|
-
export function
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
case
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
case "log": {
|
|
32
|
-
connection.console.log(message);
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
case "info":
|
|
36
|
-
case "box":
|
|
37
|
-
case "ready":
|
|
38
|
-
case "start":
|
|
39
|
-
case "success": {
|
|
40
|
-
connection.console.info(message);
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
case "warn": {
|
|
44
|
-
connection.console.warn(message);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
case "fail":
|
|
15
|
+
export function getLspConnectionSink(connection, props) {
|
|
16
|
+
const format = props?.formatter ?? getTextFormatter({
|
|
17
|
+
format: ({ category, message }) => {
|
|
18
|
+
return `${category} ${message}`;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const messageOnly = getMessageOnlyFormatter();
|
|
22
|
+
return (logObj) => {
|
|
23
|
+
try {
|
|
24
|
+
switch (logObj.level) {
|
|
25
|
+
// case 'debug':
|
|
26
|
+
// connection.console.debug(format(logObj).trimEnd())
|
|
27
|
+
// break
|
|
28
|
+
// case 'info':
|
|
29
|
+
// connection.console.info(format(logObj).trimEnd())
|
|
30
|
+
// break
|
|
31
|
+
// case 'warning':
|
|
32
|
+
// connection.console.warn(format(logObj).trimEnd())
|
|
33
|
+
// break
|
|
48
34
|
case "error":
|
|
49
35
|
case "fatal": {
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
connection.telemetry.logEvent({ eventName: "error", ...
|
|
36
|
+
const err = errorFromLogRecord(logObj);
|
|
37
|
+
if (err) {
|
|
38
|
+
connection.telemetry.logEvent({ eventName: "error", ...err });
|
|
53
39
|
} else {
|
|
54
|
-
connection.telemetry.logEvent({ eventName: "error", message });
|
|
40
|
+
connection.telemetry.logEvent({ eventName: "error", message: messageOnly(logObj) });
|
|
55
41
|
}
|
|
56
42
|
break;
|
|
57
43
|
}
|
|
58
|
-
default:
|
|
59
|
-
nonexhaustive(logObj.type);
|
|
60
44
|
}
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error("Error while logging to LSP connection:", e);
|
|
61
47
|
}
|
|
62
48
|
};
|
|
63
|
-
if (BROWSER) {
|
|
64
|
-
root.addReporter(reporter);
|
|
65
|
-
} else {
|
|
66
|
-
root.setReporters([reporter]);
|
|
67
|
-
}
|
|
68
|
-
logger.setReporters(root.options.reporters);
|
|
69
49
|
}
|
|
@@ -2,7 +2,7 @@ import { AsFqn, LinkedList, nonexhaustive } from "@likec4/core";
|
|
|
2
2
|
import { AstUtils, CstUtils, GrammarUtils, MultiMap } from "langium";
|
|
3
3
|
import { isDefined, isEmpty } from "remeda";
|
|
4
4
|
import { ast, ElementOps } from "../ast.js";
|
|
5
|
-
import {
|
|
5
|
+
import { logWarnError } from "../logger.js";
|
|
6
6
|
import { getFqnElementRef } from "../utils/elementRef.js";
|
|
7
7
|
const { findNodeForProperty } = GrammarUtils;
|
|
8
8
|
const { toDocumentSegment } = CstUtils;
|
|
@@ -66,7 +66,7 @@ export function computeDocumentFqn(document, services) {
|
|
|
66
66
|
}
|
|
67
67
|
nonexhaustive(el);
|
|
68
68
|
} catch (e) {
|
|
69
|
-
|
|
69
|
+
logWarnError(e);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -114,7 +114,7 @@ function buildModel(services, docs) {
|
|
|
114
114
|
try {
|
|
115
115
|
const __kind = c4Specification.elements[kind];
|
|
116
116
|
if (!__kind) {
|
|
117
|
-
logger.warn
|
|
117
|
+
logger.warn`No kind '${kind}' found for ${id}`;
|
|
118
118
|
return null;
|
|
119
119
|
}
|
|
120
120
|
const links = unresolvedLinks ? resolveLinks(doc, unresolvedLinks) : null;
|
|
@@ -210,7 +210,7 @@ function buildModel(services, docs) {
|
|
|
210
210
|
(acc, el) => {
|
|
211
211
|
const parent = parentFqn(el.id);
|
|
212
212
|
if (parent && isNullish(acc[parent])) {
|
|
213
|
-
|
|
213
|
+
logger.debug`No parent found for ${el.id}`;
|
|
214
214
|
return acc;
|
|
215
215
|
}
|
|
216
216
|
acc[el.id] = withExtendElementData(el);
|
|
@@ -230,9 +230,10 @@ function buildModel(services, docs) {
|
|
|
230
230
|
...model
|
|
231
231
|
}) => {
|
|
232
232
|
if (isNullish(elements[source]) || isNullish(elements[target])) {
|
|
233
|
-
logger.
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
logger.debug`Invalid relation ${id}
|
|
234
|
+
source: ${source} resolved: ${!!elements[source]}
|
|
235
|
+
target: ${target} resolved: ${!!elements[target]}
|
|
236
|
+
at ${doc.uri.path}\n`;
|
|
236
237
|
return null;
|
|
237
238
|
}
|
|
238
239
|
const links = unresolvedLinks ? resolveLinks(doc, unresolvedLinks) : null;
|
|
@@ -279,7 +280,7 @@ function buildModel(services, docs) {
|
|
|
279
280
|
try {
|
|
280
281
|
const __kind = c4Specification.deployments[parsed.kind];
|
|
281
282
|
if (!__kind) {
|
|
282
|
-
logger.warn
|
|
283
|
+
logger.warn`No kind ${parsed.kind} found for ${parsed.id}`;
|
|
283
284
|
return null;
|
|
284
285
|
}
|
|
285
286
|
let {
|
|
@@ -317,7 +318,7 @@ function buildModel(services, docs) {
|
|
|
317
318
|
(acc, el) => {
|
|
318
319
|
const parent = parentFqn(el.id);
|
|
319
320
|
if (parent && isNullish(acc[parent])) {
|
|
320
|
-
|
|
321
|
+
logger.debug`No parent found for deployment element ${el.id}`;
|
|
321
322
|
return acc;
|
|
322
323
|
}
|
|
323
324
|
acc[el.id] = el;
|
|
@@ -337,9 +338,7 @@ function buildModel(services, docs) {
|
|
|
337
338
|
...model
|
|
338
339
|
}) => {
|
|
339
340
|
if (isNullish(deploymentElements[source.id]) || isNullish(deploymentElements[target.id])) {
|
|
340
|
-
logger.warn(
|
|
341
|
-
`Invalid deployment relation ${id} at ${doc.uri.path} ${astPath}, source: ${source.id}(${!!deploymentElements[source.id]}), target: ${target.id}(${!!deploymentElements[target.id]})`
|
|
342
|
-
);
|
|
341
|
+
logger.warn`Invalid deployment relation ${id} at ${doc.uri.path} ${astPath}, source: ${source.id}(${!!deploymentElements[source.id]}), target: ${target.id}(${!!deploymentElements[target.id]})`;
|
|
343
342
|
return null;
|
|
344
343
|
}
|
|
345
344
|
const links = unresolvedLinks ? resolveLinks(doc, unresolvedLinks) : null;
|
|
@@ -370,7 +369,7 @@ function buildModel(services, docs) {
|
|
|
370
369
|
reduce(
|
|
371
370
|
(acc, el) => {
|
|
372
371
|
if (isDefined(acc[el.id])) {
|
|
373
|
-
|
|
372
|
+
logger.debug`Duplicate deployment relation ${el.id}`;
|
|
374
373
|
return acc;
|
|
375
374
|
}
|
|
376
375
|
acc[el.id] = el;
|
|
@@ -480,7 +479,7 @@ export class LikeC4ModelBuilder extends ADisposable {
|
|
|
480
479
|
DocumentState.Validated,
|
|
481
480
|
async (docs, _cancelToken) => {
|
|
482
481
|
let parsed = [];
|
|
483
|
-
logger.debug
|
|
482
|
+
logger.debug`[ModelBuilder] onValidated (${docs.length} docs)`;
|
|
484
483
|
for (const doc of docs) {
|
|
485
484
|
try {
|
|
486
485
|
parsed.push(parser.parse(doc).uri);
|
|
@@ -495,7 +494,7 @@ export class LikeC4ModelBuilder extends ADisposable {
|
|
|
495
494
|
}
|
|
496
495
|
)
|
|
497
496
|
);
|
|
498
|
-
logger.debug
|
|
497
|
+
logger.debug`[ModelBuilder] Created`;
|
|
499
498
|
}
|
|
500
499
|
langiumDocuments;
|
|
501
500
|
listeners = [];
|
|
@@ -512,7 +511,7 @@ export class LikeC4ModelBuilder extends ADisposable {
|
|
|
512
511
|
}
|
|
513
512
|
const cache = this.services.WorkspaceCache;
|
|
514
513
|
return cache.get(CACHE_KEY_PARSED_MODEL, () => {
|
|
515
|
-
logger.debug
|
|
514
|
+
logger.debug`[ModelBuilder] buildModel (${docs.length} docs)`;
|
|
516
515
|
return buildModel(this.services, docs);
|
|
517
516
|
});
|
|
518
517
|
}
|
|
@@ -40,8 +40,8 @@ export class LikeC4ModelChanges {
|
|
|
40
40
|
range: modifiedRange
|
|
41
41
|
};
|
|
42
42
|
});
|
|
43
|
-
} catch (
|
|
44
|
-
logger.error(`Failed to apply change ${changeView.change.op} ${changeView.viewId}`,
|
|
43
|
+
} catch (error) {
|
|
44
|
+
logger.error(`Failed to apply change ${changeView.change.op} ${changeView.viewId}`, { error });
|
|
45
45
|
}
|
|
46
46
|
return result;
|
|
47
47
|
}
|
package/dist/module.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
LikeC4GeneratedModule,
|
|
16
16
|
LikeC4GeneratedSharedModule
|
|
17
17
|
} from "./generated/module.js";
|
|
18
|
-
import { logger
|
|
18
|
+
import { logger } from "./logger.js";
|
|
19
19
|
import {
|
|
20
20
|
LikeC4CodeLensProvider,
|
|
21
21
|
LikeC4CompletionProvider,
|
|
@@ -120,9 +120,6 @@ export function createSharedServices(context = {}) {
|
|
|
120
120
|
...EmptyFileSystem,
|
|
121
121
|
...context
|
|
122
122
|
};
|
|
123
|
-
if (context.connection) {
|
|
124
|
-
logToLspConnection(context.connection);
|
|
125
|
-
}
|
|
126
123
|
return inject(
|
|
127
124
|
createDefaultSharedModule(moduleContext),
|
|
128
125
|
LikeC4GeneratedSharedModule,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
StreamScope
|
|
12
12
|
} from "langium";
|
|
13
13
|
import { ast } from "../ast.js";
|
|
14
|
-
import {
|
|
14
|
+
import { logWarnError } from "../logger.js";
|
|
15
15
|
import { elementRef, getFqnElementRef } from "../utils/elementRef.js";
|
|
16
16
|
const { getDocument } = AstUtils;
|
|
17
17
|
export class LikeC4ScopeProvider extends DefaultScopeProvider {
|
|
@@ -98,11 +98,11 @@ export class LikeC4ScopeProvider extends DefaultScopeProvider {
|
|
|
98
98
|
}
|
|
99
99
|
return this.computeScope(context);
|
|
100
100
|
} catch (e) {
|
|
101
|
-
|
|
101
|
+
logWarnError(e);
|
|
102
102
|
return this.getGlobalScope(referenceType, context);
|
|
103
103
|
}
|
|
104
104
|
} catch (e) {
|
|
105
|
-
|
|
105
|
+
logWarnError(e);
|
|
106
106
|
return EMPTY_SCOPE;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -3,7 +3,7 @@ import { decode, encode } from "@msgpack/msgpack";
|
|
|
3
3
|
import { fromBase64, toBase64 } from "@smithy/util-base64";
|
|
4
4
|
import { AstUtils, CstUtils } from "langium";
|
|
5
5
|
import { mapValues } from "remeda";
|
|
6
|
-
import { logger } from "../logger.js";
|
|
6
|
+
import { logger, logWarnError } from "../logger.js";
|
|
7
7
|
const { getDocument } = AstUtils;
|
|
8
8
|
function pack({
|
|
9
9
|
nodes,
|
|
@@ -90,7 +90,7 @@ export function parseViewManualLayout(node) {
|
|
|
90
90
|
return deserializeFromComment(commentNode.text);
|
|
91
91
|
} catch (e) {
|
|
92
92
|
const doc = getDocument(node);
|
|
93
|
-
|
|
93
|
+
logWarnError(e);
|
|
94
94
|
logger.warn(
|
|
95
95
|
`Ignoring manual layout of "${node.name ?? "unnamed"}" at ${doc.uri.fsPath}:${1 + (commentNode.range.start.line || 0)}`
|
|
96
96
|
);
|
|
@@ -7,7 +7,7 @@ function graphvizBinPath() {
|
|
|
7
7
|
try {
|
|
8
8
|
return which.sync("dot");
|
|
9
9
|
} catch (error) {
|
|
10
|
-
logger.error("Error checking for native Graphviz:", error);
|
|
10
|
+
logger.error("Error checking for native Graphviz:", { error });
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -19,7 +19,7 @@ export const ConfigurableLayouter = {
|
|
|
19
19
|
const layouter = new GraphvizLayouter(wasmAdapter);
|
|
20
20
|
const langId = services.LanguageMetaData.languageId;
|
|
21
21
|
services.shared.workspace.ConfigurationProvider.onConfigurationSectionUpdate((update) => {
|
|
22
|
-
logger.debug("Configuration update", update);
|
|
22
|
+
logger.debug("Configuration update", { update });
|
|
23
23
|
if (update.section === langId) {
|
|
24
24
|
try {
|
|
25
25
|
const { mode, path } = update.configuration.graphviz ?? {
|
|
@@ -43,11 +43,11 @@ export const ConfigurableLayouter = {
|
|
|
43
43
|
layouter.changePort(new GraphvizBinaryAdapter(binaryPath));
|
|
44
44
|
logger.info(`use graphviz binary: ${binaryPath}`);
|
|
45
45
|
} catch (error) {
|
|
46
|
-
logger.error("Failed to update configuration", error);
|
|
46
|
+
logger.error("Failed to update configuration", { error });
|
|
47
47
|
}
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
logger.warn("Unexpected configuration update", update);
|
|
50
|
+
logger.warn("Unexpected configuration update", { update });
|
|
51
51
|
});
|
|
52
52
|
return layouter;
|
|
53
53
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComputedView, DiagramView, OverviewGraph, ViewId } from '@likec4/core';
|
|
2
|
+
import { GraphvizLayouter } from '@likec4/layouts';
|
|
2
3
|
import { type Cancellation } from 'langium';
|
|
3
4
|
import type { LikeC4Services } from '../module';
|
|
4
5
|
export type GraphvizOut = {
|
|
@@ -15,7 +16,7 @@ export declare class LikeC4Views {
|
|
|
15
16
|
private cache;
|
|
16
17
|
private viewsWithReportedErrors;
|
|
17
18
|
constructor(services: LikeC4Services);
|
|
18
|
-
|
|
19
|
+
get layouter(): GraphvizLayouter;
|
|
19
20
|
computedViews(cancelToken?: Cancellation.CancellationToken): Promise<ComputedView[]>;
|
|
20
21
|
layoutAllViews(cancelToken?: Cancellation.CancellationToken): Promise<Array<Readonly<GraphvizOut>>>;
|
|
21
22
|
layoutView(viewId: ViewId, cancelToken?: Cancellation.CancellationToken): Promise<GraphvizOut | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { values } from "remeda";
|
|
2
|
-
import {
|
|
2
|
+
import { logError, logWarnError } from "../logger.js";
|
|
3
3
|
export class LikeC4Views {
|
|
4
4
|
constructor(services) {
|
|
5
5
|
this.services = services;
|
|
@@ -64,7 +64,7 @@ export class LikeC4Views {
|
|
|
64
64
|
this.services.shared.lsp.Connection?.window.showErrorMessage(`LikeC4: ${errMessage}`);
|
|
65
65
|
this.viewsWithReportedErrors.add(viewId);
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
logError(e);
|
|
68
68
|
return Promise.reject(e);
|
|
69
69
|
}
|
|
70
70
|
}
|
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.
|
|
4
|
+
"version": "1.22.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
7
7
|
"homepage": "https://likec4.dev",
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"bin",
|
|
11
11
|
"dist",
|
|
12
|
-
"src",
|
|
13
12
|
"!**/__mocks__/",
|
|
14
13
|
"!**/__tests__/",
|
|
15
14
|
"!**/*.spec.*",
|
|
@@ -21,7 +20,7 @@
|
|
|
21
20
|
"directory": "packages/language-server"
|
|
22
21
|
},
|
|
23
22
|
"engines": {
|
|
24
|
-
"node": ">=20"
|
|
23
|
+
"node": ">=20.18.3"
|
|
25
24
|
},
|
|
26
25
|
"engineStrict": true,
|
|
27
26
|
"type": "module",
|
|
@@ -89,19 +88,21 @@
|
|
|
89
88
|
"vitest:ui": "vitest --no-isolate --ui",
|
|
90
89
|
"test:watch": "vitest"
|
|
91
90
|
},
|
|
91
|
+
"dependencies": {
|
|
92
|
+
"@hpcc-js/wasm-graphviz": "1.7.0"
|
|
93
|
+
},
|
|
92
94
|
"devDependencies": {
|
|
93
|
-
"@likec4/core": "1.
|
|
94
|
-
"@likec4/icons": "1.
|
|
95
|
-
"@likec4/layouts": "1.
|
|
96
|
-
"@likec4/log": "1.
|
|
97
|
-
"@likec4/tsconfig": "1.
|
|
98
|
-
"@msgpack/msgpack": "^3.0.0
|
|
95
|
+
"@likec4/core": "1.22.0",
|
|
96
|
+
"@likec4/icons": "1.22.0",
|
|
97
|
+
"@likec4/layouts": "1.22.0",
|
|
98
|
+
"@likec4/log": "1.22.0",
|
|
99
|
+
"@likec4/tsconfig": "1.22.0",
|
|
100
|
+
"@msgpack/msgpack": "^3.0.0",
|
|
99
101
|
"@smithy/util-base64": "^4.0.0",
|
|
100
|
-
"@types/node": "^20.17.
|
|
102
|
+
"@types/node": "^20.17.17",
|
|
101
103
|
"@types/which": "^3.0.4",
|
|
102
104
|
"@vitest/coverage-v8": "^3.0.4",
|
|
103
105
|
"esm-env": "^1.2.2",
|
|
104
|
-
"execa": "^9.3.1",
|
|
105
106
|
"fast-equals": "^5.2.2",
|
|
106
107
|
"fdir": "^6.4.3",
|
|
107
108
|
"indent-string": "^5.0.0",
|
|
@@ -109,13 +110,12 @@
|
|
|
109
110
|
"langium": "3.3.1",
|
|
110
111
|
"langium-cli": "3.3.0",
|
|
111
112
|
"natural-compare-lite": "^1.4.0",
|
|
112
|
-
"npm-run-all2": "^7.0.1",
|
|
113
113
|
"p-debounce": "^4.0.0",
|
|
114
114
|
"remeda": "^2.20.1",
|
|
115
115
|
"strip-indent": "^4.0.0",
|
|
116
116
|
"tsx": "~4.19.2",
|
|
117
117
|
"turbo": "^2.4.0",
|
|
118
|
-
"type-fest": "4.
|
|
118
|
+
"type-fest": "4.34.1",
|
|
119
119
|
"typescript": "^5.7.3",
|
|
120
120
|
"ufo": "^1.5.4",
|
|
121
121
|
"unbuild": "^3.3.1",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"vscode-languageserver": "9.0.1",
|
|
125
125
|
"vscode-languageserver-types": "3.17.5",
|
|
126
126
|
"vscode-uri": "3.0.8",
|
|
127
|
-
"which": "^
|
|
127
|
+
"which": "^5.0.0"
|
|
128
128
|
},
|
|
129
129
|
"packageManager": "yarn@4.6.0"
|
|
130
130
|
}
|
package/dist/test/setup.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test/setup.js
DELETED
package/src/LikeC4FileSystem.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { fdir } from 'fdir'
|
|
2
|
-
import { type FileSystemNode, URI } from 'langium'
|
|
3
|
-
import { NodeFileSystemProvider } from 'langium/node'
|
|
4
|
-
import { LikeC4LanguageMetaData } from './generated/module'
|
|
5
|
-
import { logger } from './logger'
|
|
6
|
-
|
|
7
|
-
export const LikeC4FileSystem = {
|
|
8
|
-
fileSystemProvider: () => new SymLinkTraversingFileSystemProvider(),
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const hasExtension = (path: string) => LikeC4LanguageMetaData.fileExtensions.some((ext) => path.endsWith(ext))
|
|
12
|
-
/**
|
|
13
|
-
* A file system provider that follows symbolic links.
|
|
14
|
-
* @see https://github.com/likec4/likec4/pull/1213
|
|
15
|
-
*/
|
|
16
|
-
class SymLinkTraversingFileSystemProvider extends NodeFileSystemProvider {
|
|
17
|
-
override async readDirectory(folderPath: URI): Promise<FileSystemNode[]> {
|
|
18
|
-
const entries = [] as FileSystemNode[]
|
|
19
|
-
try {
|
|
20
|
-
const crawled = await new fdir()
|
|
21
|
-
.withSymlinks()
|
|
22
|
-
.withFullPaths()
|
|
23
|
-
.filter(hasExtension)
|
|
24
|
-
.crawl(folderPath.fsPath)
|
|
25
|
-
.withPromise()
|
|
26
|
-
for (const path of crawled) {
|
|
27
|
-
entries.push({
|
|
28
|
-
isFile: true,
|
|
29
|
-
isDirectory: false,
|
|
30
|
-
uri: URI.file(path),
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
} catch (error) {
|
|
34
|
-
logger.error(error)
|
|
35
|
-
}
|
|
36
|
-
return entries
|
|
37
|
-
}
|
|
38
|
-
}
|