@likec4/language-server 1.42.0 → 1.43.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.
@@ -4,9 +4,10 @@ import { URI } from "langium";
4
4
  import { NodeFileSystemProvider } from "langium/node";
5
5
  import { LikeC4LanguageMetaData } from "../generated/module.mjs";
6
6
  import { Content, isLikeC4Builtin } from "../likec4lib.mjs";
7
- import { logError } from "../logger.mjs";
7
+ import { logger as rootLogger } from "../logger.mjs";
8
8
  import { chokidarFileSystemWatcher } from "./ChokidarWatcher.mjs";
9
9
  import { noopFileSystemWatcher } from "./FileSystemWatcher.mjs";
10
+ const logger = rootLogger.getChild("filesystem");
10
11
  export const LikeC4FileSystem = (ehableWatcher = true) => ({
11
12
  fileSystemProvider: () => new SymLinkTraversingFileSystemProvider(),
12
13
  ...ehableWatcher ? chokidarFileSystemWatcher : noopFileSystemWatcher
@@ -18,7 +19,12 @@ class SymLinkTraversingFileSystemProvider extends NodeFileSystemProvider {
18
19
  if (isLikeC4Builtin(uri)) {
19
20
  return Promise.resolve(Content);
20
21
  }
21
- return await super.readFile(uri);
22
+ try {
23
+ return await super.readFile(uri);
24
+ } catch (error) {
25
+ logger.error(`Failed to read file ${uri.fsPath}`, { error });
26
+ return "";
27
+ }
22
28
  }
23
29
  async readDirectory(folderPath) {
24
30
  const entries = [];
@@ -32,7 +38,7 @@ class SymLinkTraversingFileSystemProvider extends NodeFileSystemProvider {
32
38
  });
33
39
  }
34
40
  } catch (error) {
35
- logError(error);
41
+ logger.error(`Failed to read directory ${folderPath.fsPath}`, { error });
36
42
  }
37
43
  return entries;
38
44
  }
@@ -48,7 +54,7 @@ class SymLinkTraversingFileSystemProvider extends NodeFileSystemProvider {
48
54
  });
49
55
  }
50
56
  } catch (error) {
51
- logError(error);
57
+ logger.error(`Failed to scan project files ${folderUri.fsPath}`, { error });
52
58
  }
53
59
  return entries;
54
60
  }
@@ -29,8 +29,11 @@ export declare const LikeC4Terminals: {
29
29
  Hex: RegExp;
30
30
  };
31
31
  export type LikeC4TerminalNames = keyof typeof LikeC4Terminals;
32
- export type LikeC4KeywordNames = "(" | ")" | "*" | "," | "->" | "-[" | ":" | ";" | "<-" | "<->" | "BottomTop" | "LeftRight" | "RightLeft" | "TopBottom" | "]->" | "amber" | "and" | "autoLayout" | "blue" | "border" | "browser" | "color" | "crow" | "cylinder" | "dashed" | "deployment" | "deploymentNode" | "description" | "diagram" | "diamond" | "dot" | "dotted" | "dynamic" | "dynamicPredicateGroup" | "element" | "element.kind" | "element.tag" | "exclude" | "extend" | "extends" | "from" | "global" | "gray" | "green" | "group" | "head" | "icon" | "icons" | "import" | "include" | "indigo" | "instance" | "instanceOf" | "is" | "kind" | "large" | "lg" | "likec4lib" | "line" | "link" | "md" | "medium" | "metadata" | "mobile" | "model" | "multiple" | "muted" | "navigateTo" | "node" | "none" | "normal" | "not" | "notation" | "notes" | "odiamond" | "odot" | "of" | "onormal" | "opacity" | "open" | "or" | "padding" | "par" | "parallel" | "person" | "predicate" | "predicateGroup" | "primary" | "queue" | "rectangle" | "red" | "relationship" | "rgb" | "rgba" | "secondary" | "sequence" | "shape" | "size" | "sky" | "slate" | "sm" | "small" | "solid" | "source" | "specification" | "storage" | "style" | "styleGroup" | "summary" | "tag" | "tail" | "target" | "technology" | "textSize" | "title" | "variant" | "vee" | "view" | "views" | "where" | "with" | "xl" | "xlarge" | "xs" | "xsmall" | "{" | "}";
32
+ export type LikeC4KeywordNames = "(" | ")" | "*" | "," | "->" | "-[" | ":" | ";" | "<-" | "<->" | "BottomTop" | "LeftRight" | "RightLeft" | "TopBottom" | "[" | "]" | "]->" | "amber" | "and" | "autoLayout" | "blue" | "border" | "browser" | "color" | "crow" | "cylinder" | "dashed" | "deployment" | "deploymentNode" | "description" | "diagram" | "diamond" | "dot" | "dotted" | "dynamic" | "dynamicPredicateGroup" | "element" | "element.kind" | "element.tag" | "exclude" | "extend" | "extends" | "from" | "global" | "gray" | "green" | "group" | "head" | "icon" | "icons" | "import" | "include" | "indigo" | "instance" | "instanceOf" | "is" | "kind" | "large" | "lg" | "likec4lib" | "line" | "link" | "md" | "medium" | "metadata" | "mobile" | "model" | "multiple" | "muted" | "navigateTo" | "node" | "none" | "normal" | "not" | "notation" | "notes" | "odiamond" | "odot" | "of" | "onormal" | "opacity" | "open" | "or" | "padding" | "par" | "parallel" | "person" | "predicate" | "predicateGroup" | "primary" | "queue" | "rectangle" | "red" | "relationship" | "rgb" | "rgba" | "secondary" | "sequence" | "shape" | "size" | "sky" | "slate" | "sm" | "small" | "solid" | "source" | "specification" | "storage" | "style" | "styleGroup" | "summary" | "tag" | "tail" | "target" | "technology" | "textSize" | "title" | "variant" | "vee" | "view" | "views" | "where" | "with" | "xl" | "xlarge" | "xs" | "xsmall" | "{" | "}";
33
33
  export type LikeC4TokenNames = LikeC4TerminalNames | LikeC4KeywordNames;
34
+ export type AnyProperty = DynamicViewProperty | ElementProperty | RelationProperty | StringProperty | ViewProperty;
35
+ export declare const AnyProperty = "AnyProperty";
36
+ export declare function isAnyProperty(item: unknown): item is AnyProperty;
34
37
  export type ArrowType = 'crow' | 'diamond' | 'dot' | 'none' | 'normal' | 'odiamond' | 'odot' | 'onormal' | 'open' | 'vee';
35
38
  export declare function isArrowType(item: unknown): item is ArrowType;
36
39
  export type BorderStyleValue = 'none' | LineOptions;
@@ -95,6 +98,9 @@ export declare function isLineOptions(item: unknown): item is LineOptions;
95
98
  export type MetadataProperty = MetadataBody;
96
99
  export declare const MetadataProperty = "MetadataProperty";
97
100
  export declare function isMetadataProperty(item: unknown): item is MetadataProperty;
101
+ export type MetadataValue = MarkdownOrString | MetadataArray;
102
+ export declare const MetadataValue = "MetadataValue";
103
+ export declare function isMetadataValue(item: unknown): item is MetadataValue;
98
104
  export type ModelReferenceable = Element | Imported;
99
105
  export declare const ModelReferenceable = "ModelReferenceable";
100
106
  export declare function isModelReferenceable(item: unknown): item is ModelReferenceable;
@@ -699,18 +705,25 @@ export interface LinkProperty extends langium.AstNode {
699
705
  export declare const LinkProperty = "LinkProperty";
700
706
  export declare function isLinkProperty(item: unknown): item is LinkProperty;
701
707
  export interface MarkdownOrString extends langium.AstNode {
702
- readonly $container: ElementStringProperty | MetadataAttribute | NotationProperty | NotesProperty | RelationStringProperty | SpecificationElementStringProperty | SpecificationRelationshipStringProperty | ViewStringProperty;
708
+ readonly $container: ElementStringProperty | MetadataArray | MetadataAttribute | NotationProperty | NotesProperty | RelationStringProperty | SpecificationElementStringProperty | SpecificationRelationshipStringProperty | ViewStringProperty;
703
709
  readonly $type: 'MarkdownOrString';
704
710
  markdown?: string;
705
711
  text?: string;
706
712
  }
707
713
  export declare const MarkdownOrString = "MarkdownOrString";
708
714
  export declare function isMarkdownOrString(item: unknown): item is MarkdownOrString;
715
+ export interface MetadataArray extends langium.AstNode {
716
+ readonly $container: MetadataAttribute;
717
+ readonly $type: 'MetadataArray';
718
+ values: Array<MarkdownOrString>;
719
+ }
720
+ export declare const MetadataArray = "MetadataArray";
721
+ export declare function isMetadataArray(item: unknown): item is MetadataArray;
709
722
  export interface MetadataAttribute extends langium.AstNode {
710
723
  readonly $container: MetadataBody;
711
724
  readonly $type: 'MetadataAttribute';
712
725
  key: string;
713
- value: MarkdownOrString;
726
+ value: MetadataValue;
714
727
  }
715
728
  export declare const MetadataAttribute = "MetadataAttribute";
716
729
  export declare function isMetadataAttribute(item: unknown): item is MetadataAttribute;
@@ -1190,6 +1203,7 @@ export declare const DynamicStepSingle = "DynamicStepSingle";
1190
1203
  export declare function isDynamicStepSingle(item: unknown): item is DynamicStepSingle;
1191
1204
  export type LikeC4AstType = {
1192
1205
  AbstractDynamicStep: AbstractDynamicStep;
1206
+ AnyProperty: AnyProperty;
1193
1207
  ArrowProperty: ArrowProperty;
1194
1208
  BorderProperty: BorderProperty;
1195
1209
  ColorLiteral: ColorLiteral;
@@ -1271,9 +1285,11 @@ export type LikeC4AstType = {
1271
1285
  LineProperty: LineProperty;
1272
1286
  LinkProperty: LinkProperty;
1273
1287
  MarkdownOrString: MarkdownOrString;
1288
+ MetadataArray: MetadataArray;
1274
1289
  MetadataAttribute: MetadataAttribute;
1275
1290
  MetadataBody: MetadataBody;
1276
1291
  MetadataProperty: MetadataProperty;
1292
+ MetadataValue: MetadataValue;
1277
1293
  Model: Model;
1278
1294
  ModelDeployments: ModelDeployments;
1279
1295
  ModelReferenceable: ModelReferenceable;
@@ -24,6 +24,10 @@ export const LikeC4Terminals = {
24
24
  IdTerminal: /[_]*[a-zA-Z][-\w]*/,
25
25
  Hex: /[a-fA-F0-9]{3,}(?![-_g-zG-Z])/
26
26
  };
27
+ export const AnyProperty = "AnyProperty";
28
+ export function isAnyProperty(item) {
29
+ return reflection.isInstance(item, AnyProperty);
30
+ }
27
31
  export function isArrowType(item) {
28
32
  return item === "none" || item === "normal" || item === "onormal" || item === "dot" || item === "odot" || item === "diamond" || item === "odiamond" || item === "crow" || item === "open" || item === "vee";
29
33
  }
@@ -112,6 +116,10 @@ export const MetadataProperty = "MetadataProperty";
112
116
  export function isMetadataProperty(item) {
113
117
  return reflection.isInstance(item, MetadataProperty);
114
118
  }
119
+ export const MetadataValue = "MetadataValue";
120
+ export function isMetadataValue(item) {
121
+ return reflection.isInstance(item, MetadataValue);
122
+ }
115
123
  export const ModelReferenceable = "ModelReferenceable";
116
124
  export function isModelReferenceable(item) {
117
125
  return reflection.isInstance(item, ModelReferenceable);
@@ -467,6 +475,10 @@ export const MarkdownOrString = "MarkdownOrString";
467
475
  export function isMarkdownOrString(item) {
468
476
  return reflection.isInstance(item, MarkdownOrString);
469
477
  }
478
+ export const MetadataArray = "MetadataArray";
479
+ export function isMetadataArray(item) {
480
+ return reflection.isInstance(item, MetadataArray);
481
+ }
470
482
  export const MetadataAttribute = "MetadataAttribute";
471
483
  export function isMetadataAttribute(item) {
472
484
  return reflection.isInstance(item, MetadataAttribute);
@@ -701,7 +713,7 @@ export function isDynamicStepSingle(item) {
701
713
  }
702
714
  export class LikeC4AstReflection extends langium.AbstractAstReflection {
703
715
  getAllTypes() {
704
- return [AbstractDynamicStep, ArrowProperty, BorderProperty, ColorLiteral, ColorProperty, CustomColor, CustomElementProperties, CustomRelationProperties, DeployedInstance, DeployedInstanceBody, DeploymentElement, DeploymentNode, DeploymentNodeBody, DeploymentNodeKind, DeploymentNodeOrElementKind, DeploymentRelation, DeploymentRelationBody, DeploymentView, DeploymentViewBody, DeploymentViewRule, DeploymentViewRulePredicate, DeploymentViewRuleStyle, DirectedRelationExpr, DynamicStepChain, DynamicStepSingle, DynamicView, DynamicViewBody, DynamicViewDisplayVariantProperty, DynamicViewGlobalPredicateRef, DynamicViewIncludePredicate, DynamicViewParallelSteps, DynamicViewProperty, DynamicViewRef, DynamicViewRule, DynamicViewStep, Element, ElementBody, ElementKind, ElementKindExpression, ElementProperty, ElementRef, ElementStringProperty, ElementStyleProperty, ElementTagExpression, ElementView, ElementViewBody, ElementViewRef, ExpressionV2, Expressions, ExtendDeployment, ExtendDeploymentBody, ExtendElement, ExtendElementBody, ExtendElementProperty, FqnExpr, FqnExprOrWhere, FqnExprOrWith, FqnExprWhere, FqnExprWith, FqnExpressions, FqnRef, FqnRefExpr, FqnReferenceable, GlobalDynamicPredicateGroup, GlobalPredicateGroup, GlobalStyle, GlobalStyleGroup, GlobalStyleId, Globals, HexColor, IconProperty, Imported, ImportsFromPoject, InOutRelationExpr, IncomingRelationExpr, LibIcon, LikeC4Grammar, LikeC4Lib, LikeC4View, LineProperty, LinkProperty, MarkdownOrString, MetadataAttribute, MetadataBody, MetadataProperty, Model, ModelDeployments, ModelReferenceable, ModelViews, MultipleProperty, NavigateToProperty, NotationProperty, NotesProperty, OpacityProperty, OutgoingRelationExpr, PaddingSizeProperty, RGBAColor, Referenceable, Relation, RelationBody, RelationExpr, RelationExprOrWhere, RelationExprOrWith, RelationExprWhere, RelationExprWith, RelationKindDotRef, RelationNavigateToProperty, RelationProperty, RelationStringProperty, RelationStyleProperty, RelationshipKind, RelationshipStyleProperty, ShapeProperty, ShapeSizeProperty, SizeProperty, SpecificationColor, SpecificationDeploymentNodeKind, SpecificationElementKind, SpecificationElementStringProperty, SpecificationRelationshipKind, SpecificationRelationshipStringProperty, SpecificationRule, SpecificationTag, StrictFqnElementRef, StrictFqnRef, StringProperty, StyleProperty, Tag, TagRef, Tags, TextSizeProperty, ViewProperty, ViewRef, ViewRule, ViewRuleAutoLayout, ViewRuleGlobalPredicateRef, ViewRuleGlobalStyle, ViewRuleGroup, ViewRulePredicate, ViewRuleStyle, ViewRuleStyleOrGlobalRef, ViewStringProperty, WhereBinaryExpression, WhereElement, WhereElementExpression, WhereElementKind, WhereElementNegation, WhereElementTag, WhereExpression, WhereKindEqual, WhereRelation, WhereRelationExpression, WhereRelationKind, WhereRelationNegation, WhereRelationParticipantKind, WhereRelationParticipantTag, WhereRelationTag, WhereTagEqual, WildcardExpression];
716
+ return [AbstractDynamicStep, AnyProperty, ArrowProperty, BorderProperty, ColorLiteral, ColorProperty, CustomColor, CustomElementProperties, CustomRelationProperties, DeployedInstance, DeployedInstanceBody, DeploymentElement, DeploymentNode, DeploymentNodeBody, DeploymentNodeKind, DeploymentNodeOrElementKind, DeploymentRelation, DeploymentRelationBody, DeploymentView, DeploymentViewBody, DeploymentViewRule, DeploymentViewRulePredicate, DeploymentViewRuleStyle, DirectedRelationExpr, DynamicStepChain, DynamicStepSingle, DynamicView, DynamicViewBody, DynamicViewDisplayVariantProperty, DynamicViewGlobalPredicateRef, DynamicViewIncludePredicate, DynamicViewParallelSteps, DynamicViewProperty, DynamicViewRef, DynamicViewRule, DynamicViewStep, Element, ElementBody, ElementKind, ElementKindExpression, ElementProperty, ElementRef, ElementStringProperty, ElementStyleProperty, ElementTagExpression, ElementView, ElementViewBody, ElementViewRef, ExpressionV2, Expressions, ExtendDeployment, ExtendDeploymentBody, ExtendElement, ExtendElementBody, ExtendElementProperty, FqnExpr, FqnExprOrWhere, FqnExprOrWith, FqnExprWhere, FqnExprWith, FqnExpressions, FqnRef, FqnRefExpr, FqnReferenceable, GlobalDynamicPredicateGroup, GlobalPredicateGroup, GlobalStyle, GlobalStyleGroup, GlobalStyleId, Globals, HexColor, IconProperty, Imported, ImportsFromPoject, InOutRelationExpr, IncomingRelationExpr, LibIcon, LikeC4Grammar, LikeC4Lib, LikeC4View, LineProperty, LinkProperty, MarkdownOrString, MetadataArray, MetadataAttribute, MetadataBody, MetadataProperty, MetadataValue, Model, ModelDeployments, ModelReferenceable, ModelViews, MultipleProperty, NavigateToProperty, NotationProperty, NotesProperty, OpacityProperty, OutgoingRelationExpr, PaddingSizeProperty, RGBAColor, Referenceable, Relation, RelationBody, RelationExpr, RelationExprOrWhere, RelationExprOrWith, RelationExprWhere, RelationExprWith, RelationKindDotRef, RelationNavigateToProperty, RelationProperty, RelationStringProperty, RelationStyleProperty, RelationshipKind, RelationshipStyleProperty, ShapeProperty, ShapeSizeProperty, SizeProperty, SpecificationColor, SpecificationDeploymentNodeKind, SpecificationElementKind, SpecificationElementStringProperty, SpecificationRelationshipKind, SpecificationRelationshipStringProperty, SpecificationRule, SpecificationTag, StrictFqnElementRef, StrictFqnRef, StringProperty, StyleProperty, Tag, TagRef, Tags, TextSizeProperty, ViewProperty, ViewRef, ViewRule, ViewRuleAutoLayout, ViewRuleGlobalPredicateRef, ViewRuleGlobalStyle, ViewRuleGroup, ViewRulePredicate, ViewRuleStyle, ViewRuleStyleOrGlobalRef, ViewStringProperty, WhereBinaryExpression, WhereElement, WhereElementExpression, WhereElementKind, WhereElementNegation, WhereElementTag, WhereExpression, WhereKindEqual, WhereRelation, WhereRelationExpression, WhereRelationKind, WhereRelationNegation, WhereRelationParticipantKind, WhereRelationParticipantTag, WhereRelationTag, WhereTagEqual, WildcardExpression];
705
717
  }
706
718
  computeIsSubtype(subtype, supertype) {
707
719
  switch (subtype) {
@@ -745,14 +757,19 @@ export class LikeC4AstReflection extends langium.AbstractAstReflection {
745
757
  case DynamicStepSingle: {
746
758
  return this.isSubtype(AbstractDynamicStep, supertype) || this.isSubtype(DynamicViewStep, supertype);
747
759
  }
748
- case DynamicViewDisplayVariantProperty:
749
- case ViewProperty: {
760
+ case DynamicViewDisplayVariantProperty: {
750
761
  return this.isSubtype(DynamicViewProperty, supertype);
751
762
  }
752
763
  case DynamicViewGlobalPredicateRef:
753
764
  case DynamicViewIncludePredicate: {
754
765
  return this.isSubtype(DynamicViewRule, supertype);
755
766
  }
767
+ case DynamicViewProperty:
768
+ case ElementProperty:
769
+ case RelationProperty:
770
+ case StringProperty: {
771
+ return this.isSubtype(AnyProperty, supertype);
772
+ }
756
773
  case Element: {
757
774
  return this.isSubtype(FqnReferenceable, supertype) || this.isSubtype(ModelReferenceable, supertype) || this.isSubtype(Referenceable, supertype);
758
775
  }
@@ -798,6 +815,10 @@ export class LikeC4AstReflection extends langium.AbstractAstReflection {
798
815
  case LinkProperty: {
799
816
  return this.isSubtype(ElementProperty, supertype) || this.isSubtype(ExtendElementProperty, supertype) || this.isSubtype(RelationProperty, supertype) || this.isSubtype(ViewProperty, supertype);
800
817
  }
818
+ case MarkdownOrString:
819
+ case MetadataArray: {
820
+ return this.isSubtype(MetadataValue, supertype);
821
+ }
801
822
  case MetadataAttribute:
802
823
  case NotationProperty:
803
824
  case NotesProperty:
@@ -831,6 +852,9 @@ export class LikeC4AstReflection extends langium.AbstractAstReflection {
831
852
  case RelationStringProperty: {
832
853
  return this.isSubtype(RelationProperty, supertype) || this.isSubtype(StringProperty, supertype);
833
854
  }
855
+ case ViewProperty: {
856
+ return this.isSubtype(AnyProperty, supertype) || this.isSubtype(DynamicViewProperty, supertype);
857
+ }
834
858
  case ViewRuleAutoLayout: {
835
859
  return this.isSubtype(DeploymentViewRule, supertype) || this.isSubtype(DynamicViewRule, supertype) || this.isSubtype(ViewRule, supertype);
836
860
  }
@@ -1556,6 +1580,14 @@ export class LikeC4AstReflection extends langium.AbstractAstReflection {
1556
1580
  ]
1557
1581
  };
1558
1582
  }
1583
+ case MetadataArray: {
1584
+ return {
1585
+ name: MetadataArray,
1586
+ properties: [
1587
+ { name: "values", defaultValue: [] }
1588
+ ]
1589
+ };
1590
+ }
1559
1591
  case MetadataAttribute: {
1560
1592
  return {
1561
1593
  name: MetadataAttribute,