@likec4/language-server 1.34.2 → 1.36.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/dist/bundled.mjs +2777 -2760
  2. package/dist/config/schema.d.ts +1 -0
  3. package/dist/config/schema.js +7 -0
  4. package/dist/generated/ast.d.ts +8 -7
  5. package/dist/generated/ast.js +1 -0
  6. package/dist/generated/grammar.d.ts +1 -1
  7. package/dist/generated/grammar.js +1 -1
  8. package/dist/generated/module.d.ts +1 -1
  9. package/dist/logger.js +4 -0
  10. package/dist/mcp/tools/list-projects.js +3 -0
  11. package/dist/mcp/tools/read-project-summary.js +3 -0
  12. package/dist/model/builder/MergedSpecification.d.ts +1 -1
  13. package/dist/model/builder/MergedSpecification.js +8 -0
  14. package/dist/model/builder/buildModel.d.ts +7 -1
  15. package/dist/model/builder/buildModel.js +8 -2
  16. package/dist/model/model-builder.js +2 -1
  17. package/dist/model/model-parser.d.ts +9 -9
  18. package/dist/model/parser/DeploymentModelParser.d.ts +1 -1
  19. package/dist/model/parser/DeploymentViewParser.d.ts +1 -1
  20. package/dist/model/parser/FqnRefParser.d.ts +1 -1
  21. package/dist/model/parser/GlobalsParser.d.ts +1 -1
  22. package/dist/model/parser/ImportsParser.d.ts +1 -1
  23. package/dist/model/parser/ModelParser.d.ts +1 -1
  24. package/dist/model/parser/PredicatesParser.d.ts +1 -1
  25. package/dist/model/parser/SpecificationParser.d.ts +2 -2
  26. package/dist/model/parser/SpecificationParser.js +18 -3
  27. package/dist/model/parser/ViewsParser.d.ts +1 -1
  28. package/dist/model/parser/ViewsParser.js +13 -3
  29. package/dist/protocol.d.ts +1 -1
  30. package/dist/protocol.js +1 -1
  31. package/dist/view-utils/resolve-relative-paths.js +1 -1
  32. package/dist/views/likec4-views.d.ts +29 -8
  33. package/dist/views/likec4-views.js +5 -6
  34. package/dist/workspace/IndexManager.d.ts +1 -1
  35. package/dist/workspace/IndexManager.js +1 -2
  36. package/package.json +17 -16
@@ -1,5 +1,5 @@
1
1
  /******************************************************************************
2
- * This file was generated by langium-cli 3.5.0.
2
+ * This file was generated by langium-cli 3.5.2.
3
3
  * DO NOT EDIT MANUALLY!
4
4
  ******************************************************************************/
5
5
  import type { LangiumSharedCoreServices, LangiumCoreServices, LangiumGeneratedCoreServices, LangiumGeneratedSharedCoreServices, Module, IParserConfig } from 'langium';
package/dist/logger.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { nonexhaustive } from "@likec4/core";
1
2
  import {
2
3
  errorFromLogRecord,
3
4
  getMessageOnlyFormatter,
@@ -21,6 +22,7 @@ export function getLspConnectionSink(connection, props) {
21
22
  return (logObj) => {
22
23
  try {
23
24
  switch (logObj.level) {
25
+ case "trace":
24
26
  case "debug":
25
27
  connection.console.debug(format(logObj));
26
28
  break;
@@ -35,6 +37,8 @@ export function getLspConnectionSink(connection, props) {
35
37
  connection.console.error(format(logObj));
36
38
  break;
37
39
  }
40
+ default:
41
+ nonexhaustive(logObj.level);
38
42
  }
39
43
  } catch (e) {
40
44
  console.error("Error while logging to LSP connection:", e);
@@ -6,6 +6,7 @@ export const listProjects = likec4Tool({
6
6
  Lists all available LikeC4 projects in the workspace.
7
7
  Returns array of projects with:
8
8
  - name: project name (project id)
9
+ - title: human readable title
9
10
  - folder: project folder
10
11
  - sources: array of project sources
11
12
  `,
@@ -15,6 +16,7 @@ Returns array of projects with:
15
16
  outputSchema: {
16
17
  projects: z.array(z.object({
17
18
  name: z.string(),
19
+ title: z.string().optional(),
18
20
  folder: z.string(),
19
21
  sources: z.array(z.string())
20
22
  }))
@@ -24,6 +26,7 @@ Returns array of projects with:
24
26
  return {
25
27
  projects: projects.map((p) => ({
26
28
  name: p.id,
29
+ title: p.config?.title,
27
30
  folder: p.folder.toString(),
28
31
  sources: p.documents?.map((d) => d.toString()) ?? []
29
32
  }))
@@ -11,6 +11,7 @@ export const readProjectSummary = likec4Tool({
11
11
  },
12
12
  description: `
13
13
  Searches for LikeC4 project by name in workspace and returns its summary:
14
+ - project human readable title
14
15
  - project folder
15
16
  - array of the source filenames
16
17
  - specification:
@@ -28,6 +29,7 @@ Searches for LikeC4 project by name in workspace and returns its summary:
28
29
  project: z.string().optional().describe('Project name (optional, will use "default" if not specified)')
29
30
  },
30
31
  outputSchema: {
32
+ title: z.string().optional(),
31
33
  folder: z.string(),
32
34
  sources: z.array(z.string()),
33
35
  specification: z.object({
@@ -50,6 +52,7 @@ Searches for LikeC4 project by name in workspace and returns its summary:
50
52
  invariant(project, `Project "${projectId}" not found`);
51
53
  const model = await languageServices.computedModel(project.id);
52
54
  return {
55
+ title: project.config?.title,
53
56
  folder: project.folder.toString(),
54
57
  sources: project.documents?.map((d) => d.toString()) ?? [],
55
58
  specification: {
@@ -1,4 +1,4 @@
1
- import type * as c4 from '@likec4/core';
1
+ import * as c4 from '@likec4/core';
2
2
  import { MultiMap } from '@likec4/core';
3
3
  import type { ParsedAstDeployment, ParsedAstDeploymentRelation, ParsedAstElement, ParsedAstRelation, ParsedAstSpecification, ParsedLikeC4LangiumDocument } from '../../ast';
4
4
  /**
@@ -1,3 +1,4 @@
1
+ import * as c4 from "@likec4/core";
1
2
  import { MultiMap } from "@likec4/core";
2
3
  import {
3
4
  FqnRef
@@ -86,6 +87,9 @@ export class MergedSpecification {
86
87
  size ??= __kind.style.size;
87
88
  padding ??= __kind.style.padding;
88
89
  textSize ??= __kind.style.textSize;
90
+ description ??= __kind.description;
91
+ links ??= __kind.links;
92
+ title = title === c4.nameFromFqn(id) && __kind.title ? __kind.title : title;
89
93
  return {
90
94
  ...color && { color },
91
95
  ...shape && { shape },
@@ -168,11 +172,15 @@ export class MergedSpecification {
168
172
  technology = __kind.technology,
169
173
  notation = __kind.notation,
170
174
  style,
175
+ title,
171
176
  description,
172
177
  ...rest
173
178
  } = parsed;
179
+ description ??= __kind.description;
180
+ title = title === c4.nameFromFqn(parsed.id) && __kind.title ? __kind.title : title;
174
181
  return {
175
182
  ...rest,
183
+ ...{ title },
176
184
  ...description && { description },
177
185
  ...notation && { notation },
178
186
  ...technology && { technology },
@@ -1,6 +1,8 @@
1
1
  import * as c4 from '@likec4/core';
2
2
  import { type MultiMap } from '@likec4/core';
3
+ import type { URI } from 'langium';
3
4
  import type { ParsedLikeC4LangiumDocument } from '../../ast';
5
+ import type { ProjectConfig } from '../../config';
4
6
  export type BuildModelData = {
5
7
  data: c4.ParsedLikeC4ModelData;
6
8
  imports: MultiMap<c4.ProjectId, c4.Fqn, Set<c4.Fqn>>;
@@ -12,4 +14,8 @@ export type BuildModelData = {
12
14
  * This function builds a model from all documents, merging the specifications
13
15
  * and globals, and applying the extends to the elements.
14
16
  */
15
- export declare function buildModelData(projectId: string, docs: ParsedLikeC4LangiumDocument[]): BuildModelData;
17
+ export declare function buildModelData(project: {
18
+ id: c4.ProjectId;
19
+ folder: URI;
20
+ config: Readonly<ProjectConfig>;
21
+ }, docs: ParsedLikeC4LangiumDocument[]): BuildModelData;
@@ -26,7 +26,7 @@ import { logger } from "../../logger.js";
26
26
  import { resolveRelativePaths } from "../../view-utils/index.js";
27
27
  import { MergedExtends } from "./MergedExtends.js";
28
28
  import { MergedSpecification } from "./MergedSpecification.js";
29
- export function buildModelData(projectId, docs) {
29
+ export function buildModelData(project, docs) {
30
30
  const c4Specification = new MergedSpecification(docs);
31
31
  const customColors = mapValues(
32
32
  c4Specification.specs.colors,
@@ -190,10 +190,16 @@ export function buildModelData(projectId, docs) {
190
190
  indexBy(prop("id")),
191
191
  resolveRulesExtendedViews
192
192
  );
193
+ const projectInfo = {
194
+ id: project.id,
195
+ name: project.config.name,
196
+ ...project.config.title && { title: project.config.title }
197
+ };
193
198
  return {
194
199
  data: {
195
200
  [c4._stage]: "parsed",
196
- projectId,
201
+ projectId: project.id,
202
+ project: projectInfo,
197
203
  specification: {
198
204
  tags: c4Specification.tags,
199
205
  elements: c4Specification.specs.elements,
@@ -82,13 +82,14 @@ export class DefaultLikeC4ModelBuilder extends ADisposable {
82
82
  }
83
83
  return cache.get(key, () => {
84
84
  try {
85
+ const project = this.projects.getProject(projectId);
85
86
  const docs = this.documents(projectId);
86
87
  if (docs.length === 0) {
87
88
  logger.debug`no documents to build model`;
88
89
  return null;
89
90
  }
90
91
  logger.debug`unsafeSyncBuildModelData`;
91
- return buildModelData(projectId, docs);
92
+ return buildModelData(project, docs);
92
93
  } catch (e) {
93
94
  logWarnError(e);
94
95
  return null;
@@ -55,7 +55,7 @@ declare const DocumentParserFromMixins: {
55
55
  isValid: import("../validation").IsValidFn;
56
56
  readonly services: LikeC4Services;
57
57
  readonly doc: ParsedLikeC4LangiumDocument;
58
- readonly project: {
58
+ get project(): {
59
59
  id: ProjectId;
60
60
  folder: ProjectId;
61
61
  config: Readonly<import("../config").ProjectConfig>;
@@ -148,7 +148,7 @@ declare const DocumentParserFromMixins: {
148
148
  isValid: import("../validation").IsValidFn;
149
149
  readonly services: LikeC4Services;
150
150
  readonly doc: ParsedLikeC4LangiumDocument;
151
- readonly project: {
151
+ get project(): {
152
152
  id: ProjectId;
153
153
  folder: ProjectId;
154
154
  config: Readonly<import("../config").ProjectConfig>;
@@ -203,7 +203,7 @@ declare const DocumentParserFromMixins: {
203
203
  isValid: import("../validation").IsValidFn;
204
204
  readonly services: LikeC4Services;
205
205
  readonly doc: ParsedLikeC4LangiumDocument;
206
- readonly project: {
206
+ get project(): {
207
207
  id: ProjectId;
208
208
  folder: ProjectId;
209
209
  config: Readonly<import("../config").ProjectConfig>;
@@ -272,7 +272,7 @@ declare const DocumentParserFromMixins: {
272
272
  isValid: import("../validation").IsValidFn;
273
273
  readonly services: LikeC4Services;
274
274
  readonly doc: ParsedLikeC4LangiumDocument;
275
- readonly project: {
275
+ get project(): {
276
276
  id: ProjectId;
277
277
  folder: ProjectId;
278
278
  config: Readonly<import("../config").ProjectConfig>;
@@ -334,7 +334,7 @@ declare const DocumentParserFromMixins: {
334
334
  isValid: import("../validation").IsValidFn;
335
335
  readonly services: LikeC4Services;
336
336
  readonly doc: ParsedLikeC4LangiumDocument;
337
- readonly project: {
337
+ get project(): {
338
338
  id: ProjectId;
339
339
  folder: ProjectId;
340
340
  config: Readonly<import("../config").ProjectConfig>;
@@ -404,7 +404,7 @@ declare const DocumentParserFromMixins: {
404
404
  isValid: import("../validation").IsValidFn;
405
405
  readonly services: LikeC4Services;
406
406
  readonly doc: ParsedLikeC4LangiumDocument;
407
- readonly project: {
407
+ get project(): {
408
408
  id: ProjectId;
409
409
  folder: ProjectId;
410
410
  config: Readonly<import("../config").ProjectConfig>;
@@ -467,7 +467,7 @@ declare const DocumentParserFromMixins: {
467
467
  isValid: import("../validation").IsValidFn;
468
468
  readonly services: LikeC4Services;
469
469
  readonly doc: ParsedLikeC4LangiumDocument;
470
- readonly project: {
470
+ get project(): {
471
471
  id: ProjectId;
472
472
  folder: ProjectId;
473
473
  config: Readonly<import("../config").ProjectConfig>;
@@ -510,7 +510,7 @@ declare const DocumentParserFromMixins: {
510
510
  isValid: import("../validation").IsValidFn;
511
511
  readonly services: LikeC4Services;
512
512
  readonly doc: ParsedLikeC4LangiumDocument;
513
- readonly project: {
513
+ get project(): {
514
514
  id: ProjectId;
515
515
  folder: ProjectId;
516
516
  config: Readonly<import("../config").ProjectConfig>;
@@ -568,7 +568,7 @@ declare const DocumentParserFromMixins: {
568
568
  isValid: import("../validation").IsValidFn;
569
569
  readonly services: LikeC4Services;
570
570
  readonly doc: ParsedLikeC4LangiumDocument;
571
- readonly project: {
571
+ get project(): {
572
572
  id: ProjectId;
573
573
  folder: ProjectId;
574
574
  config: Readonly<import("../config").ProjectConfig>;
@@ -30,7 +30,7 @@ export declare function DeploymentModelParser<TBase extends WithExpressionV2>(B:
30
30
  isValid: import("../../validation").IsValidFn;
31
31
  readonly services: import("../..").LikeC4Services;
32
32
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
33
- readonly project: {
33
+ get project(): {
34
34
  id: c4.ProjectId;
35
35
  folder: c4;
36
36
  config: Readonly<import("../../config").ProjectConfig>;
@@ -28,7 +28,7 @@ export declare function DeploymentViewParser<TBase extends WithExpressionV2 & Wi
28
28
  isValid: import("../../validation").IsValidFn;
29
29
  readonly services: import("../..").LikeC4Services;
30
30
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
31
- readonly project: {
31
+ get project(): {
32
32
  id: c4.ProjectId;
33
33
  folder: c4;
34
34
  config: Readonly<import("../../config").ProjectConfig>;
@@ -23,7 +23,7 @@ export declare function ExpressionV2Parser<TBase extends Base>(B: TBase): {
23
23
  isValid: import("../../validation").IsValidFn;
24
24
  readonly services: import("../..").LikeC4Services;
25
25
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
26
- readonly project: {
26
+ get project(): {
27
27
  id: c4.ProjectId;
28
28
  folder: c4;
29
29
  config: Readonly<import("../../config").ProjectConfig>;
@@ -52,7 +52,7 @@ export declare function GlobalsParser<TBase extends WithViewsParser>(B: TBase):
52
52
  isValid: import("../../validation").IsValidFn;
53
53
  readonly services: import("../..").LikeC4Services;
54
54
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
55
- readonly project: {
55
+ get project(): {
56
56
  id: c4.ProjectId;
57
57
  folder: c4;
58
58
  config: Readonly<import("../../config").ProjectConfig>;
@@ -7,7 +7,7 @@ export declare function ImportsParser<TBase extends Base>(B: TBase): {
7
7
  isValid: import("../../validation").IsValidFn;
8
8
  readonly services: import("../..").LikeC4Services;
9
9
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
10
- readonly project: {
10
+ get project(): {
11
11
  id: ProjectId;
12
12
  folder: ProjectId;
13
13
  config: Readonly<import("../../config").ProjectConfig>;
@@ -29,7 +29,7 @@ export declare function ModelParser<TBase extends WithExpressionV2>(B: TBase): {
29
29
  isValid: import("../../validation").IsValidFn;
30
30
  readonly services: import("../..").LikeC4Services;
31
31
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
32
- readonly project: {
32
+ get project(): {
33
33
  id: c4.ProjectId;
34
34
  folder: c4;
35
35
  config: Readonly<import("../../config").ProjectConfig>;
@@ -34,7 +34,7 @@ export declare function PredicatesParser<TBase extends WithExpressionV2>(B: TBas
34
34
  isValid: import("../../validation").IsValidFn;
35
35
  readonly services: import("../..").LikeC4Services;
36
36
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
37
- readonly project: {
37
+ get project(): {
38
38
  id: c4.ProjectId;
39
39
  folder: c4;
40
40
  config: Readonly<import("../../config").ProjectConfig>;
@@ -1,4 +1,4 @@
1
- import type * as c4 from '@likec4/core';
1
+ import * as c4 from '@likec4/core';
2
2
  import { ast } from '../../ast';
3
3
  import { type Base } from './Base';
4
4
  export declare function SpecificationParser<TBase extends Base>(B: TBase): {
@@ -13,7 +13,7 @@ export declare function SpecificationParser<TBase extends Base>(B: TBase): {
13
13
  isValid: import("../../validation").IsValidFn;
14
14
  readonly services: import("../..").LikeC4Services;
15
15
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
16
- readonly project: {
16
+ get project(): {
17
17
  id: c4.ProjectId;
18
18
  folder: c4;
19
19
  config: Readonly<import("../../config").ProjectConfig>;
@@ -1,3 +1,4 @@
1
+ import * as c4 from "@likec4/core";
1
2
  import { nonNullable } from "@likec4/core/utils";
2
3
  import { filter, isNonNullish, isNullish, isTruthy, mapToObj, omitBy, pipe } from "remeda";
3
4
  import { ast, parseMarkdownAsString, toRelationshipStyleExcludeDefaults } from "../../ast.js";
@@ -94,15 +95,29 @@ export function SpecificationParser(B) {
94
95
  }
95
96
  const tags = this.parseTags(specAst);
96
97
  const style = this.parseElementStyle(props.find(ast.isElementStyleProperty));
98
+ const links = this.parseLinks(specAst);
97
99
  const bodyProps = pipe(
98
100
  props.filter(ast.isSpecificationElementStringProperty) ?? [],
99
- filter((p) => this.isValid(p) && isNonNullish(p.value)),
100
- mapToObj((p) => [p.key, removeIndent(p.value)])
101
+ filter((p) => this.isValid(p)),
102
+ mapToObj((p) => [p.key, p.value])
101
103
  );
104
+ const { title, description, technology } = this.parseTitleDescriptionTechnology(
105
+ {
106
+ title: void 0,
107
+ description: void 0,
108
+ technology: void 0
109
+ },
110
+ bodyProps
111
+ );
112
+ const notation = removeIndent(parseMarkdownAsString(bodyProps.notation));
102
113
  return {
103
114
  [kindName]: {
104
- ...bodyProps,
115
+ ...title && { title },
116
+ ...description && { description },
117
+ ...technology && { technology },
118
+ ...notation && { notation },
105
119
  ...tags && { tags },
120
+ ...links && c4.isNonEmptyArray(links) && { links },
106
121
  style
107
122
  }
108
123
  };
@@ -50,7 +50,7 @@ export declare function ViewsParser<TBase extends WithPredicates & WithDeploymen
50
50
  isValid: import("../../validation").IsValidFn;
51
51
  readonly services: import("../..").LikeC4Services;
52
52
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
53
- readonly project: {
53
+ get project(): {
54
54
  id: c4.ProjectId;
55
55
  folder: c4;
56
56
  config: Readonly<import("../../config").ProjectConfig>;
@@ -1,6 +1,6 @@
1
1
  import * as c4 from "@likec4/core";
2
2
  import { invariant, isNonEmptyArray, nonexhaustive } from "@likec4/core";
3
- import { filter, isArray, isDefined, isNonNullish, isTruthy, mapToObj, pipe } from "remeda";
3
+ import { filter, isArray, isDefined, isEmpty, isNonNullish, isTruthy, mapToObj, pipe } from "remeda";
4
4
  import {
5
5
  ast,
6
6
  parseMarkdownAsString,
@@ -26,6 +26,7 @@ export function ViewsParser(B) {
26
26
  return [];
27
27
  }
28
28
  });
29
+ const folder = viewBlock.folder && !isEmpty(viewBlock.folder.trim()) ? viewBlock.folder : null;
29
30
  for (const view of viewBlock.views) {
30
31
  try {
31
32
  if (!isValid(view)) {
@@ -44,6 +45,10 @@ export function ViewsParser(B) {
44
45
  default:
45
46
  nonexhaustive(view);
46
47
  }
48
+ if (folder) {
49
+ const view2 = this.doc.c4Views.at(-1);
50
+ view2.title = folder + " / " + (view2.title || view2.id);
51
+ }
47
52
  } catch (e) {
48
53
  logWarnError(e);
49
54
  }
@@ -349,13 +354,18 @@ export function ViewsParser(B) {
349
354
  break;
350
355
  }
351
356
  case ast.isRelationStringProperty(prop):
352
- case ast.isNotationProperty(prop):
353
- case ast.isNotesProperty(prop): {
357
+ case ast.isNotationProperty(prop): {
354
358
  if (isDefined(prop.value)) {
355
359
  step[prop.key] = removeIndent(parseMarkdownAsString(prop.value)) ?? "";
356
360
  }
357
361
  break;
358
362
  }
363
+ case ast.isNotesProperty(prop): {
364
+ if (isDefined(prop.value)) {
365
+ step[prop.key] = removeIndent(prop.value);
366
+ }
367
+ break;
368
+ }
359
369
  case ast.isArrowProperty(prop): {
360
370
  if (isDefined(prop.value)) {
361
371
  step[prop.key] = prop.value;
@@ -1,5 +1,5 @@
1
1
  import type { ComputedLikeC4ModelData, ComputedView, DeploymentFqn, DiagramView, Fqn, LayoutedLikeC4ModelData, NonEmptyArray, ProjectId, RelationId, ViewChange, ViewId } from '@likec4/core';
2
- import { NotificationType, RequestType, RequestType0 } from 'vscode-jsonrpc';
2
+ import { NotificationType, RequestType, RequestType0 } from 'vscode-languageserver';
3
3
  import type { DiagnosticSeverity, DocumentUri, Location, Position, Range } from 'vscode-languageserver-types';
4
4
  export declare namespace DidChangeModelNotification {
5
5
  const type: NotificationType<string>;
package/dist/protocol.js CHANGED
@@ -1,4 +1,4 @@
1
- import { NotificationType, RequestType, RequestType0 } from "vscode-jsonrpc";
1
+ import { NotificationType, RequestType, RequestType0 } from "vscode-languageserver";
2
2
  export var DidChangeModelNotification;
3
3
  ((DidChangeModelNotification2) => {
4
4
  DidChangeModelNotification2.type = new NotificationType("likec4/onDidChangeModel");
@@ -68,7 +68,7 @@ export function resolveRelativePaths(views) {
68
68
  return compare;
69
69
  }
70
70
  }
71
- return compareNatural(a.view.title ?? a.view.id, b.view.title ?? b.view.id);
71
+ return 0;
72
72
  }).map(({ parts, view }) => {
73
73
  return {
74
74
  ...view,
@@ -1,23 +1,44 @@
1
1
  import type { ComputedView, DiagramView, ProjectId, ViewId } from '@likec4/core';
2
2
  import { type QueueGraphvizLayoter, GraphvizLayouter } from '@likec4/layouts';
3
- import { CancellationToken } from 'vscode-jsonrpc';
3
+ import type { CancellationToken } from 'vscode-languageserver';
4
4
  import type { LikeC4Services } from '../module';
5
5
  export type GraphvizOut = {
6
- dot: string;
7
- diagram: DiagramView;
6
+ readonly dot: string;
7
+ readonly diagram: DiagramView;
8
8
  };
9
9
  type GraphvizSvgOut = {
10
- id: ViewId;
11
- dot: string;
12
- svg: string;
10
+ readonly id: ViewId;
11
+ readonly dot: string;
12
+ readonly svg: string;
13
13
  };
14
14
  export interface LikeC4Views {
15
15
  readonly layouter: GraphvizLayouter;
16
+ /**
17
+ * Returns computed views (i.e. views with predicates computed)
18
+ */
16
19
  computedViews(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<ComputedView[]>;
17
- layoutAllViews(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<Array<Readonly<GraphvizOut>>>;
20
+ /**
21
+ * Returns all layouted views (i.e. views with layout computed)
22
+ * Result includes dot and diagram
23
+ */
24
+ layoutAllViews(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<GraphvizOut[]>;
25
+ /**
26
+ * Returns layouted view (i.e. view with layout computed)
27
+ * Result includes dot and diagram
28
+ */
18
29
  layoutView(viewId: ViewId, projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<GraphvizOut | null>;
30
+ /**
31
+ * Returns diagrams (i.e. views with layout computed)
32
+ */
19
33
  diagrams(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<Array<DiagramView>>;
34
+ /**
35
+ * Returns all layouted views as Graphviz output (i.e. views with layout computed)
36
+ */
20
37
  viewsAsGraphvizOut(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<Array<GraphvizSvgOut>>;
38
+ /**
39
+ * Open view in the preview panel.
40
+ * (works only if running as a vscode extension)
41
+ */
21
42
  openView(viewId: ViewId, projectId?: ProjectId | undefined): Promise<void>;
22
43
  }
23
44
  export declare class DefaultLikeC4Views implements LikeC4Views {
@@ -28,7 +49,7 @@ export declare class DefaultLikeC4Views implements LikeC4Views {
28
49
  constructor(services: LikeC4Services);
29
50
  get layouter(): QueueGraphvizLayoter;
30
51
  computedViews(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<ComputedView[]>;
31
- layoutAllViews(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<Array<Readonly<GraphvizOut>>>;
52
+ layoutAllViews(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<GraphvizOut[]>;
32
53
  layoutView(viewId: ViewId, projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<GraphvizOut | null>;
33
54
  diagrams(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<Array<DiagramView>>;
34
55
  viewsAsGraphvizOut(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<Array<GraphvizSvgOut>>;
@@ -1,6 +1,5 @@
1
1
  import { loggable } from "@likec4/log";
2
2
  import { values } from "remeda";
3
- import { CancellationToken } from "vscode-jsonrpc";
4
3
  import { logError, logger as rootLogger, logWarnError } from "../logger.js";
5
4
  import { performanceMark } from "../utils/index.js";
6
5
  const viewsLogger = rootLogger.getChild("views");
@@ -15,11 +14,11 @@ export class DefaultLikeC4Views {
15
14
  get layouter() {
16
15
  return this.services.likec4.Layouter;
17
16
  }
18
- async computedViews(projectId, cancelToken = CancellationToken.None) {
17
+ async computedViews(projectId, cancelToken) {
19
18
  const likeC4Model = await this.ModelBuilder.buildLikeC4Model(projectId, cancelToken);
20
19
  return values(likeC4Model.$data.views);
21
20
  }
22
- async layoutAllViews(projectId, cancelToken = CancellationToken.None) {
21
+ async layoutAllViews(projectId, cancelToken) {
23
22
  const likeC4Model = await this.ModelBuilder.buildLikeC4Model(projectId, cancelToken);
24
23
  const views = values(likeC4Model.$data.views);
25
24
  if (views.length === 0) {
@@ -63,7 +62,7 @@ export class DefaultLikeC4Views {
63
62
  }
64
63
  return results;
65
64
  }
66
- async layoutView(viewId, projectId, cancelToken = CancellationToken.None) {
65
+ async layoutView(viewId, projectId, cancelToken) {
67
66
  const model = await this.ModelBuilder.buildLikeC4Model(projectId, cancelToken);
68
67
  const view = model.findView(viewId)?.$view;
69
68
  const logger = projectId ? viewsLogger.getChild(projectId) : viewsLogger;
@@ -96,11 +95,11 @@ export class DefaultLikeC4Views {
96
95
  return Promise.reject(e);
97
96
  }
98
97
  }
99
- async diagrams(projectId, cancelToken = CancellationToken.None) {
98
+ async diagrams(projectId, cancelToken) {
100
99
  const layouted = await this.layoutAllViews(projectId, cancelToken);
101
100
  return layouted.map((l) => l.diagram);
102
101
  }
103
- async viewsAsGraphvizOut(projectId, cancelToken = CancellationToken.None) {
102
+ async viewsAsGraphvizOut(projectId, cancelToken) {
104
103
  const KEY = "All-LayoutedViews-DotWithSvg";
105
104
  const cache = this.services.ValidatedWorkspaceCache;
106
105
  if (cache.has(KEY)) {
@@ -1,6 +1,6 @@
1
1
  import type { ProjectId } from '@likec4/core';
2
2
  import { type AstNodeDescription, type LangiumDocument, type Stream, DefaultIndexManager } from 'langium';
3
- import { CancellationToken } from 'vscode-jsonrpc';
3
+ import type { CancellationToken } from 'vscode-languageserver';
4
4
  import type { LikeC4SharedServices } from '../module';
5
5
  export declare class IndexManager extends DefaultIndexManager {
6
6
  protected services: LikeC4SharedServices;
@@ -1,11 +1,10 @@
1
1
  import { DefaultIndexManager, stream } from "langium";
2
- import { CancellationToken } from "vscode-jsonrpc";
3
2
  export class IndexManager extends DefaultIndexManager {
4
3
  constructor(services) {
5
4
  super(services);
6
5
  this.services = services;
7
6
  }
8
- async updateContent(document, cancelToken = CancellationToken.None) {
7
+ async updateContent(document, cancelToken) {
9
8
  const projects = this.services.workspace.ProjectsManager;
10
9
  document.likec4ProjectId = projects.belongsTo(document.uri);
11
10
  await super.updateContent(document, cancelToken);