@likec4/language-server 1.39.5 → 1.41.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 (41) hide show
  1. package/dist/ast.d.ts +4 -2
  2. package/dist/bundled.mjs +3438 -3428
  3. package/dist/formatting/LikeC4Formatter.mjs +14 -8
  4. package/dist/generated/ast.d.ts +22 -5
  5. package/dist/generated/ast.mjs +28 -2
  6. package/dist/generated/grammar.mjs +1 -1
  7. package/dist/logger.d.ts +1 -1
  8. package/dist/logger.mjs +3 -0
  9. package/dist/lsp/CompletionProvider.mjs +34 -3
  10. package/dist/lsp/HoverProvider.mjs +14 -2
  11. package/dist/lsp/SemanticTokenProvider.mjs +1 -1
  12. package/dist/model/builder/MergedSpecification.d.ts +1 -1
  13. package/dist/model/builder/MergedSpecification.mjs +39 -35
  14. package/dist/model/builder/buildModel.mjs +2 -1
  15. package/dist/model/model-parser.d.ts +72 -45
  16. package/dist/model/parser/Base.d.ts +13 -7
  17. package/dist/model/parser/Base.mjs +27 -16
  18. package/dist/model/parser/DeploymentModelParser.d.ts +8 -5
  19. package/dist/model/parser/DeploymentModelParser.mjs +47 -45
  20. package/dist/model/parser/DeploymentViewParser.d.ts +8 -5
  21. package/dist/model/parser/DeploymentViewParser.mjs +1 -2
  22. package/dist/model/parser/FqnRefParser.d.ts +10 -6
  23. package/dist/model/parser/FqnRefParser.mjs +12 -4
  24. package/dist/model/parser/GlobalsParser.d.ts +8 -5
  25. package/dist/model/parser/GlobalsParser.mjs +5 -3
  26. package/dist/model/parser/ImportsParser.d.ts +8 -5
  27. package/dist/model/parser/ImportsParser.mjs +4 -2
  28. package/dist/model/parser/ModelParser.d.ts +8 -5
  29. package/dist/model/parser/ModelParser.mjs +31 -36
  30. package/dist/model/parser/PredicatesParser.d.ts +8 -5
  31. package/dist/model/parser/SpecificationParser.d.ts +8 -5
  32. package/dist/model/parser/SpecificationParser.mjs +15 -21
  33. package/dist/model/parser/ValueConverter.mjs +1 -1
  34. package/dist/model/parser/ViewsParser.d.ts +8 -5
  35. package/dist/model/parser/ViewsParser.mjs +5 -5
  36. package/dist/test/testServices.mjs +22 -24
  37. package/dist/validation/{dynamic-view-step.d.ts → dynamic-view.d.ts} +2 -1
  38. package/dist/validation/{dynamic-view-step.mjs → dynamic-view.mjs} +19 -0
  39. package/dist/validation/index.d.ts +1 -1
  40. package/dist/validation/index.mjs +4 -2
  41. package/package.json +8 -8
@@ -3,7 +3,7 @@ export class LikeC4ValueConverter extends DefaultValueConverter {
3
3
  runConverter(rule, input, cstNode) {
4
4
  if (rule.name === "MarkdownString") {
5
5
  if (input.startsWith('"""') && input.endsWith('"""') || input.startsWith(`'''`) && input.endsWith(`'''`)) {
6
- input = input.slice(3, -3);
6
+ input = input.slice(2, -2);
7
7
  }
8
8
  return ValueConverter.convertString(input);
9
9
  }
@@ -70,16 +70,19 @@ export declare function ViewsParser<TBase extends WithPredicates & WithDeploymen
70
70
  parseColorLiteral(astNode: ast.ColorLiteral): c4.ColorLiteral | undefined;
71
71
  parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
72
72
  parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
73
- parseTitleDescriptionTechnology(inlineProps: {
74
- title?: string | undefined;
75
- description?: string | undefined;
76
- technology?: string | undefined;
77
- }, bodyProps: {
73
+ parseBaseProps(props: {
78
74
  title?: ast.MarkdownOrString | undefined;
75
+ summary?: ast.MarkdownOrString | undefined;
79
76
  description?: ast.MarkdownOrString | undefined;
80
77
  technology?: ast.MarkdownOrString | undefined;
78
+ }, override?: {
79
+ title?: string | undefined;
80
+ summary?: string | undefined;
81
+ description?: string | undefined;
82
+ technology?: string | undefined;
81
83
  }): {
82
84
  title?: string;
85
+ summary?: c4.MarkdownOrString;
83
86
  description?: c4.MarkdownOrString;
84
87
  technology?: string;
85
88
  };
@@ -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, isEmpty, isNonNullish, isTruthy, mapToObj, pipe } from "remeda";
3
+ import { filter, find, isArray, isDefined, isEmpty, isNonNullish, isTruthy, mapToObj, pipe } from "remeda";
4
4
  import {
5
5
  ast,
6
6
  parseMarkdownAsString,
@@ -77,8 +77,7 @@ export function ViewsParser(B) {
77
77
  viewOf ?? ""
78
78
  );
79
79
  }
80
- const { title = null, description = null } = this.parseTitleDescriptionTechnology(
81
- {},
80
+ const { title = null, description = null } = this.parseBaseProps(
82
81
  pipe(
83
82
  body.props,
84
83
  filter((p) => this.isValid(p)),
@@ -229,8 +228,7 @@ export function ViewsParser(B) {
229
228
  astPath
230
229
  );
231
230
  }
232
- const { title = null, description = null } = this.parseTitleDescriptionTechnology(
233
- {},
231
+ const { title = null, description = null } = this.parseBaseProps(
234
232
  pipe(
235
233
  props,
236
234
  filter(ast.isViewStringProperty),
@@ -241,6 +239,7 @@ export function ViewsParser(B) {
241
239
  const links = this.convertLinks(body);
242
240
  ViewOps.writeId(astNode, id);
243
241
  const manualLayout = parseViewManualLayout(astNode);
242
+ const variant = find(props, ast.isDynamicViewDisplayVariantProperty)?.value;
244
243
  return {
245
244
  [c4._type]: "dynamic",
246
245
  id,
@@ -249,6 +248,7 @@ export function ViewsParser(B) {
249
248
  description,
250
249
  tags,
251
250
  links: isNonEmptyArray(links) ? links : null,
251
+ variant,
252
252
  rules: [
253
253
  ...additionalStyles,
254
254
  ...body.rules.flatMap((n) => {
@@ -25,31 +25,29 @@ export function createTestServices(options) {
25
25
  async function initialize() {
26
26
  if (isInitialized) return;
27
27
  isInitialized = true;
28
- await services.shared.workspace.WorkspaceLock.write(async (_cancelToken) => {
29
- services.shared.workspace.ConfigurationProvider.updateConfiguration({
30
- settings: { likec4: { formatting: { quoteStyle: "single" } } }
31
- });
32
- services.shared.workspace.WorkspaceManager.initialize({
33
- capabilities: {},
34
- processId: null,
35
- rootUri: workspaceFolder.uri,
36
- workspaceFolders: [workspaceFolder]
37
- });
38
- await services.shared.workspace.WorkspaceManager.initializeWorkspace([workspaceFolder]);
39
- if (projectConfig) {
40
- const projectFolderUri = Utils.resolvePath(workspaceUri, "src");
41
- services.shared.workspace.ProjectsManager.registerProject({
42
- config: {
43
- name: projectConfig?.name || "test-project",
44
- title: projectConfig?.title || "Test Project",
45
- contactPerson: projectConfig?.contactPerson || "Unknown",
46
- imageAliases: projectConfig?.imageAliases || {},
47
- exclude: projectConfig?.exclude || ["node_modules"]
48
- },
49
- folderUri: projectFolderUri
50
- });
51
- }
28
+ services.shared.workspace.ConfigurationProvider.updateConfiguration({
29
+ settings: { likec4: { formatting: { quoteStyle: "single" } } }
52
30
  });
31
+ services.shared.workspace.WorkspaceManager.initialize({
32
+ capabilities: {},
33
+ processId: null,
34
+ rootUri: workspaceFolder.uri,
35
+ workspaceFolders: [workspaceFolder]
36
+ });
37
+ await services.shared.workspace.WorkspaceManager.initializeWorkspace([workspaceFolder]);
38
+ if (projectConfig) {
39
+ const projectFolderUri = Utils.resolvePath(workspaceUri, "src");
40
+ await services.shared.workspace.ProjectsManager.registerProject({
41
+ config: {
42
+ name: projectConfig?.name || "test-project",
43
+ title: projectConfig?.title || "Test Project",
44
+ contactPerson: projectConfig?.contactPerson || "Unknown",
45
+ imageAliases: projectConfig?.imageAliases || {},
46
+ exclude: projectConfig?.exclude || ["node_modules"]
47
+ },
48
+ folderUri: projectFolderUri
49
+ });
50
+ }
53
51
  }
54
52
  const addDocument = async (input, uri) => {
55
53
  await initialize();
@@ -1,4 +1,5 @@
1
- import type { ValidationCheck } from 'langium';
1
+ import { type ValidationCheck } from 'langium';
2
2
  import { ast } from '../ast';
3
3
  import type { LikeC4Services } from '../module';
4
4
  export declare const dynamicViewStep: (services: LikeC4Services) => ValidationCheck<ast.DynamicViewStep>;
5
+ export declare const dynamicViewDisplayVariant: (services: LikeC4Services) => ValidationCheck<ast.DynamicViewDisplayVariantProperty>;
@@ -1,4 +1,7 @@
1
1
  import { isAncestor } from "@likec4/core";
2
+ import { AstUtils } from "langium";
3
+ import { isEmpty } from "remeda";
4
+ import { ast } from "../ast.mjs";
2
5
  import { elementRef } from "../utils/elementRef.mjs";
3
6
  import { tryOrLog } from "./_shared.mjs";
4
7
  export const dynamicViewStep = (services) => {
@@ -27,3 +30,19 @@ export const dynamicViewStep = (services) => {
27
30
  }
28
31
  });
29
32
  };
33
+ export const dynamicViewDisplayVariant = (services) => {
34
+ return tryOrLog((prop, accept) => {
35
+ if (isEmpty(prop.value) || prop.value !== "diagram" && prop.value !== "sequence") {
36
+ accept("error", 'Invalid display variant: "diagram" or "sequence" are allowed', {
37
+ node: prop,
38
+ property: "value"
39
+ });
40
+ return;
41
+ }
42
+ if (!AstUtils.hasContainerOfType(prop, ast.isDynamicViewBody)) {
43
+ accept("error", `Display mode can be defined only inside dynamic view`, {
44
+ node: prop
45
+ });
46
+ }
47
+ });
48
+ };
@@ -4,7 +4,7 @@ import type { LikeC4Services } from '../module';
4
4
  export { LikeC4DocumentValidator } from './DocumentValidator';
5
5
  type Guard<N extends AstNode> = (n: AstNode) => n is N;
6
6
  type Guarded<G> = G extends Guard<infer N> ? N : never;
7
- declare const isValidatableAstNode: (n: AstNode) => n is ast.HexColor | ast.RGBAColor | ast.DeployedInstance | ast.DeploymentNode | ast.DeploymentViewRulePredicate | ast.DeploymentViewRuleStyle | ast.ViewRuleAutoLayout | ast.DynamicViewGlobalPredicateRef | ast.DynamicViewIncludePredicate | ast.ViewRuleGlobalStyle | ast.ViewRuleStyle | ast.ElementStringProperty | ast.ElementStyleProperty | ast.IconProperty | ast.LinkProperty | ast.MetadataBody | ast.ElementKindExpression | ast.ElementTagExpression | ast.FqnRefExpr | ast.WildcardExpression | ast.FqnExprWhere | ast.FqnExprWith | ast.DirectedRelationExpr | ast.InOutRelationExpr | ast.IncomingRelationExpr | ast.OutgoingRelationExpr | ast.RelationExprWhere | ast.RelationExprWith | ast.Element | ast.ExtendDeployment | ast.ExtendElement | ast.Imported | ast.DeploymentView | ast.DynamicView | ast.ElementView | ast.RelationStringProperty | ast.ArrowProperty | ast.ColorProperty | ast.LineProperty | ast.PaddingSizeProperty | ast.ShapeSizeProperty | ast.TextSizeProperty | ast.MetadataAttribute | ast.NotationProperty | ast.NotesProperty | ast.SpecificationElementStringProperty | ast.SpecificationRelationshipStringProperty | ast.ViewStringProperty | ast.BorderProperty | ast.MultipleProperty | ast.OpacityProperty | ast.ShapeProperty | ast.ViewRuleGlobalPredicateRef | ast.ViewRuleGroup | ast.ViewRulePredicate | ast.SpecificationRelationshipKind | ast.GlobalStyle | ast.SpecificationColor | ast.NavigateToProperty | ast.DynamicViewStep | ast.ElementRef | ast.DeploymentRelation | ast.Tags | ast.SpecificationDeploymentNodeKind | ast.DynamicViewParallelSteps | ast.GlobalDynamicPredicateGroup | ast.Relation | ast.SpecificationElementKind | ast.Globals | ast.GlobalPredicateGroup | ast.GlobalStyleGroup | ast.SpecificationTag | ast.ImportsFromPoject | ast.SpecificationRule;
7
+ declare const isValidatableAstNode: (n: AstNode) => n is ast.HexColor | ast.RGBAColor | ast.DeployedInstance | ast.DeploymentNode | ast.DeploymentViewRulePredicate | ast.DeploymentViewRuleStyle | ast.ViewRuleAutoLayout | ast.DynamicViewDisplayVariantProperty | ast.LinkProperty | ast.ViewStringProperty | ast.DynamicViewGlobalPredicateRef | ast.DynamicViewIncludePredicate | ast.ViewRuleGlobalStyle | ast.ViewRuleStyle | ast.ElementStringProperty | ast.ElementStyleProperty | ast.IconProperty | ast.MetadataBody | ast.ElementKindExpression | ast.ElementTagExpression | ast.FqnRefExpr | ast.WildcardExpression | ast.FqnExprWhere | ast.FqnExprWith | ast.DirectedRelationExpr | ast.InOutRelationExpr | ast.IncomingRelationExpr | ast.OutgoingRelationExpr | ast.RelationExprWhere | ast.RelationExprWith | ast.Element | ast.ExtendDeployment | ast.ExtendElement | ast.Imported | ast.DeploymentView | ast.DynamicView | ast.ElementView | ast.RelationStringProperty | ast.ArrowProperty | ast.ColorProperty | ast.LineProperty | ast.PaddingSizeProperty | ast.ShapeSizeProperty | ast.TextSizeProperty | ast.MetadataAttribute | ast.NotationProperty | ast.NotesProperty | ast.SpecificationElementStringProperty | ast.SpecificationRelationshipStringProperty | ast.BorderProperty | ast.MultipleProperty | ast.OpacityProperty | ast.ShapeProperty | ast.ViewRuleGlobalPredicateRef | ast.ViewRuleGroup | ast.ViewRulePredicate | ast.SpecificationRelationshipKind | ast.GlobalStyle | ast.SpecificationColor | ast.NavigateToProperty | ast.DynamicViewStep | ast.ElementRef | ast.DeploymentRelation | ast.Tags | ast.SpecificationDeploymentNodeKind | ast.DynamicViewParallelSteps | ast.GlobalDynamicPredicateGroup | ast.Relation | ast.SpecificationElementKind | ast.Globals | ast.GlobalPredicateGroup | ast.GlobalStyleGroup | ast.SpecificationTag | ast.ImportsFromPoject | ast.SpecificationRule;
8
8
  type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
9
9
  export declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
10
10
  isValid: (n: ValidatableAstNode) => boolean;
@@ -9,7 +9,7 @@ import {
9
9
  deploymentRelationChecks,
10
10
  extendDeploymentChecks
11
11
  } from "./deployment-checks.mjs";
12
- import { dynamicViewStep } from "./dynamic-view-step.mjs";
12
+ import { dynamicViewDisplayVariant, dynamicViewStep } from "./dynamic-view.mjs";
13
13
  import { checkElement } from "./element.mjs";
14
14
  import { checkElementRef } from "./element-ref.mjs";
15
15
  import { checkImported, checkImportsFromPoject } from "./imports.mjs";
@@ -74,6 +74,7 @@ const isValidatableAstNode = validatableAstNodeGuards([
74
74
  ast.isDeploymentNode,
75
75
  ast.isDeploymentRelation,
76
76
  ast.isRelationshipStyleProperty,
77
+ ast.isDynamicViewDisplayVariantProperty,
77
78
  ast.isMetadataProperty,
78
79
  ast.isRelation,
79
80
  ast.isElementProperty,
@@ -155,7 +156,8 @@ export function registerValidationChecks(services) {
155
156
  OutgoingRelationExpr: checkOutgoingRelationExpr(services),
156
157
  ImportsFromPoject: checkImportsFromPoject(services),
157
158
  Imported: checkImported(services),
158
- ColorLiteral: colorLiteralRuleChecks(services)
159
+ ColorLiteral: colorLiteralRuleChecks(services),
160
+ DynamicViewDisplayVariantProperty: dynamicViewDisplayVariant(services)
159
161
  });
160
162
  const connection = services.shared.lsp.Connection;
161
163
  if (connection) {
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.39.5",
4
+ "version": "1.41.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -112,7 +112,7 @@
112
112
  "langium-cli": "3.5.2",
113
113
  "natural-compare-lite": "^1.4.0",
114
114
  "p-debounce": "4.0.0",
115
- "p-queue": "8.1.0",
115
+ "p-queue": "8.1.1",
116
116
  "p-timeout": "6.1.4",
117
117
  "picomatch": "^4.0.3",
118
118
  "pretty-ms": "^9.2.0",
@@ -132,12 +132,12 @@
132
132
  "vscode-uri": "3.1.0",
133
133
  "which": "^5.0.0",
134
134
  "zod": "3.25.76",
135
- "@likec4/core": "1.39.5",
136
- "@likec4/config": "1.39.5",
137
- "@likec4/icons": "1.39.5",
138
- "@likec4/layouts": "1.39.5",
139
- "@likec4/tsconfig": "1.39.5",
140
- "@likec4/log": "1.39.5"
135
+ "@likec4/core": "1.41.0",
136
+ "@likec4/config": "1.41.0",
137
+ "@likec4/layouts": "1.41.0",
138
+ "@likec4/log": "1.41.0",
139
+ "@likec4/icons": "1.41.0",
140
+ "@likec4/tsconfig": "1.41.0"
141
141
  },
142
142
  "scripts": {
143
143
  "typecheck": "tsc -b --verbose",