@likec4/language-server 0.33.0 → 0.34.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 (49) hide show
  1. package/contrib/likec4.monarch.ts +17 -3
  2. package/dist/ast.d.ts +24 -11
  3. package/dist/ast.js +11 -8
  4. package/dist/elementRef.d.ts +1 -1
  5. package/dist/elementRef.js +2 -3
  6. package/dist/generated/ast.d.ts +29 -10
  7. package/dist/generated/ast.js +20 -1
  8. package/dist/generated/grammar.d.ts +1 -1
  9. package/dist/generated/grammar.js +11 -11
  10. package/dist/generated/module.d.ts +7 -3
  11. package/dist/generated/module.js +3 -3
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +1 -0
  14. package/dist/logger.d.ts +6 -4
  15. package/dist/logger.js +34 -6
  16. package/dist/{shared → lsp}/CodeLensProvider.d.ts +3 -3
  17. package/dist/{shared → lsp}/DocumentLinkProvider.d.ts +3 -2
  18. package/dist/{shared → lsp}/DocumentLinkProvider.js +3 -3
  19. package/dist/lsp/DocumentSymbolProvider.js +3 -3
  20. package/dist/lsp/index.d.ts +2 -0
  21. package/dist/lsp/index.js +2 -0
  22. package/dist/model/fqn-computation.js +6 -3
  23. package/dist/model/fqn-index.d.ts +4 -7
  24. package/dist/model/fqn-index.js +36 -21
  25. package/dist/model/index.d.ts +1 -0
  26. package/dist/model/index.js +1 -0
  27. package/dist/model/model-builder.d.ts +1 -18
  28. package/dist/model/model-builder.js +111 -340
  29. package/dist/model/model-locator.js +5 -9
  30. package/dist/model/model-parser.d.ts +27 -0
  31. package/dist/model/model-parser.js +281 -0
  32. package/dist/module.d.ts +2 -1
  33. package/dist/module.js +20 -29
  34. package/dist/protocol.d.ts +8 -16
  35. package/dist/protocol.js +2 -6
  36. package/dist/references/scope-provider.js +2 -3
  37. package/dist/registerProtocolHandlers.js +19 -16
  38. package/dist/shared/index.d.ts +0 -2
  39. package/dist/shared/index.js +0 -2
  40. package/dist/test/testServices.d.ts +2 -2
  41. package/dist/test/testServices.js +16 -10
  42. package/dist/utils.d.ts +2 -2
  43. package/dist/utils.js +2 -7
  44. package/dist/validation/element.d.ts +1 -1
  45. package/dist/validation/element.js +16 -3
  46. package/dist/validation/index.js +26 -0
  47. package/dist/validation/relation.js +3 -10
  48. package/package.json +6 -5
  49. /package/dist/{shared → lsp}/CodeLensProvider.js +0 -0
@@ -6,29 +6,43 @@ export default {
6
6
  operators: [
7
7
  '*','.*'
8
8
  ],
9
- symbols: /\*|\.\*/,
9
+ symbols: /\*|\.\*/,
10
10
 
11
11
  tokenizer: {
12
12
  initial: [
13
+ { regex: /#/, action: {"token":"HASH"} },
14
+ { regex: /_/, action: {"token":"UNDERSCORE"} },
15
+ { regex: /-/, action: {"token":"DASH"} },
13
16
  { regex: /[^\W\d_]/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"LETTER"} }} },
14
17
  { regex: /[0-9]/, action: {"token":"DIGIT"} },
15
18
  { regex: /[\t\r\n\v\f]/, action: {"token":"NEWLINE"} },
16
19
  { regex: /\w+:\/\/\S+/, action: {"token":"URI_WITH_SCHEMA"} },
17
20
  { regex: /\.{0,2}\/[^\/]\S+/, action: {"token":"URI_RELATIVE"} },
21
+ { regex: /->/, action: {"token":"RARROW"} },
18
22
  { regex: /\b\.\b/, action: {"token":"Dot"} },
23
+ { regex: /!=/, action: {"token":"NotEqual"} },
24
+ { regex: /=/, action: {"token":"Eq"} },
25
+ { regex: /\{/, action: {"token":"OpenBlock"} },
26
+ { regex: /\}/, action: {"token":"CloseBlock"} },
27
+ { regex: /:/, action: {"token":"Colon"} },
28
+ { regex: /;/, action: {"token":"SemiColon"} },
29
+ { regex: /,/, action: {"token":"Comma"} },
30
+ { regex: /((#)([^\W\d_])(((([^\W\d_])|([0-9]))|(_))|(-))*)/, action: {"token":"TagID"} },
31
+ { regex: /((([^\W\d_])|(_))(((([^\W\d_])|([0-9]))|(_))|(-))*)/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"ID"} }} },
19
32
  { regex: /"[^"]*"|'[^']*'/, action: {"token":"string"} },
20
33
  { include: '@whitespace' },
21
34
  { regex: /@symbols/, action: { cases: { '@operators': {"token":"operator"}, '@default': {"token":""} }} },
22
35
  ],
23
36
  whitespace: [
24
37
  { regex: /[^\S\r\n]/, action: {"token":"white"} },
38
+ { regex: /(([\t\r\n\v\f])|([^\S\r\n]))+/, action: {"token":"white"} },
25
39
  { regex: /\/\*/, action: {"token":"comment","next":"@comment"} },
26
40
  { regex: /\/\/[^\n\r]*/, action: {"token":"comment"} },
27
41
  ],
28
42
  comment: [
29
- { regex: /[^\/\*]+/, action: {"token":"comment"} },
43
+ { regex: /[^/\*]+/, action: {"token":"comment"} },
30
44
  { regex: /\*\//, action: {"token":"comment","next":"@pop"} },
31
- { regex: /[\/\*]/, action: {"token":"comment"} },
45
+ { regex: /[/\*]/, action: {"token":"comment"} },
32
46
  ],
33
47
  }
34
48
  };
package/dist/ast.d.ts CHANGED
@@ -1,8 +1,13 @@
1
- import type * as c4 from '@likec4/core/types';
1
+ import { type c4 } from '@likec4/core';
2
2
  import type { LangiumDocument, MultiMap } from 'langium';
3
3
  import type { LikeC4Document } from './generated/ast';
4
4
  import * as ast from './generated/ast';
5
5
  export { ast };
6
+ declare module './generated/ast' {
7
+ interface Element {
8
+ fqn?: c4.Fqn;
9
+ }
10
+ }
6
11
  export interface ParsedAstSpecification {
7
12
  kinds: Record<c4.ElementKind, {
8
13
  shape?: c4.ElementShape;
@@ -48,13 +53,21 @@ export declare const ElementOps: {
48
53
  writeId(node: ast.Element, id: c4.Fqn | null): ast.Element;
49
54
  readId(node: ast.Element): c4.Fqn | undefined;
50
55
  };
51
- export interface LikeC4LangiumDocument extends LangiumDocument<LikeC4Document> {
52
- c4Specification: ParsedAstSpecification;
53
- c4Elements: ParsedAstElement[];
54
- c4Relations: ParsedAstRelation[];
55
- c4Views: ParsedAstElementView[];
56
- c4fqns?: MultiMap<c4.Fqn, string> | undefined;
56
+ export interface DocFqnIndexEntry {
57
+ name: string;
58
+ el: ast.Element;
59
+ path: string;
60
+ }
61
+ export interface LikeC4DocumentProps {
62
+ c4Specification?: ParsedAstSpecification;
63
+ c4Elements?: ParsedAstElement[];
64
+ c4Relations?: ParsedAstRelation[];
65
+ c4Views?: ParsedAstElementView[];
66
+ c4fqns?: MultiMap<c4.Fqn, DocFqnIndexEntry>;
67
+ }
68
+ export interface LikeC4LangiumDocument extends LangiumDocument<LikeC4Document>, LikeC4DocumentProps {
57
69
  }
70
+ export type ParsedLikeC4LangiumDocument = Omit<LikeC4LangiumDocument, keyof LikeC4DocumentProps> & Required<LikeC4DocumentProps>;
58
71
  export declare function cleanParsedModel(doc: LikeC4LangiumDocument): {
59
72
  elements: ParsedAstElement[];
60
73
  relations: ParsedAstRelation[];
@@ -62,8 +75,8 @@ export declare function cleanParsedModel(doc: LikeC4LangiumDocument): {
62
75
  specification: ParsedAstSpecification;
63
76
  };
64
77
  export declare function isLikeC4LangiumDocument(doc: LangiumDocument): doc is LikeC4LangiumDocument;
65
- export declare function isParsedLikeC4LangiumDocument(doc: LangiumDocument): doc is LikeC4LangiumDocument;
66
- export declare const isValidLikeC4LangiumDocument: (doc: LangiumDocument) => doc is LikeC4LangiumDocument;
78
+ export declare function isParsedLikeC4LangiumDocument(doc: LangiumDocument): doc is ParsedLikeC4LangiumDocument;
79
+ export declare const isValidLikeC4LangiumDocument: (doc: LangiumDocument) => doc is ParsedLikeC4LangiumDocument;
67
80
  export declare function streamModel(doc: LikeC4LangiumDocument): Generator<ast.Relation | ast.Element, void, unknown>;
68
81
  export declare function resolveRelationPoints(node: ast.Relation): {
69
82
  source: ast.Element;
@@ -75,8 +88,8 @@ export declare function toElementStyle(props?: ast.StyleProperties['props']): {
75
88
  icon?: c4.IconUrl;
76
89
  };
77
90
  export declare function toElementStyleExcludeDefaults(props?: ast.StyleProperties['props']): {
78
- shape?: "browser" | "cylinder" | "mobile" | "person" | "queue" | "storage";
79
- color?: "amber" | "blue" | "gray" | "green" | "indigo" | "muted" | "red" | "secondary" | "sky" | "slate";
91
+ shape?: "person" | "browser" | "mobile" | "cylinder" | "storage" | "queue";
92
+ color?: "amber" | "blue" | "gray" | "slate" | "green" | "indigo" | "muted" | "red" | "secondary" | "sky";
80
93
  icon?: c4.IconUrl;
81
94
  };
82
95
  export declare function toAutoLayout(direction: ast.ViewRuleLayoutDirection): c4.ViewRuleAutoLayout['autoLayout'];
package/dist/ast.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DefaultElementShape, DefaultThemeColor, RelationRefError, nonexhaustive } from '@likec4/core';
2
- import { DocumentState } from 'langium/lib/workspace';
2
+ import { DocumentState } from 'langium';
3
3
  import { elementRef } from './elementRef';
4
4
  import * as ast from './generated/ast';
5
5
  import { LikeC4LanguageMetaData } from './generated/module';
@@ -22,11 +22,13 @@ export const ElementOps = {
22
22
  if (id === null) {
23
23
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-dynamic-delete
24
24
  delete node[idattr];
25
+ delete node.fqn;
25
26
  }
26
27
  else {
27
28
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-extra-semi
28
29
  ;
29
30
  node[idattr] = id;
31
+ node.fqn = id;
30
32
  }
31
33
  return node;
32
34
  },
@@ -36,9 +38,9 @@ export const ElementOps = {
36
38
  }
37
39
  };
38
40
  export function cleanParsedModel(doc) {
39
- doc.c4Specification = {
41
+ const specification = (doc.c4Specification = {
40
42
  kinds: {}
41
- };
43
+ });
42
44
  const elements = (doc.c4Elements = []);
43
45
  const relations = (doc.c4Relations = []);
44
46
  const views = (doc.c4Views = []);
@@ -46,7 +48,7 @@ export function cleanParsedModel(doc) {
46
48
  elements,
47
49
  relations,
48
50
  views,
49
- specification: doc.c4Specification
51
+ specification
50
52
  };
51
53
  }
52
54
  export function isLikeC4LangiumDocument(doc) {
@@ -55,10 +57,11 @@ export function isLikeC4LangiumDocument(doc) {
55
57
  export function isParsedLikeC4LangiumDocument(doc) {
56
58
  return (isLikeC4LangiumDocument(doc) &&
57
59
  doc.state >= DocumentState.Validated &&
58
- 'c4Specification' in doc &&
59
- 'c4Elements' in doc &&
60
- 'c4Relations' in doc &&
61
- 'c4Views' in doc);
60
+ !!doc.c4Specification &&
61
+ !!doc.c4Elements &&
62
+ !!doc.c4Relations &&
63
+ !!doc.c4Views &&
64
+ !!doc.c4fqns);
62
65
  }
63
66
  export const isValidLikeC4LangiumDocument = (doc) => {
64
67
  if (!isParsedLikeC4LangiumDocument(doc))
@@ -1,4 +1,4 @@
1
- import type * as c4 from '@likec4/core/types';
1
+ import { type c4 } from '@likec4/core';
2
2
  import { ast } from './ast';
3
3
  export declare function isElementRefHead(node: ast.ElementRef | ast.StrictElementRef): boolean;
4
4
  export declare function elementRef(node: ast.ElementRef | ast.StrictElementRef): ast.Element | undefined;
@@ -1,6 +1,5 @@
1
+ import { invariant, nonexhaustive } from '@likec4/core';
1
2
  import { ast } from './ast';
2
- import { invariant } from '@likec4/core';
3
- import { failExpectedNever } from './utils';
4
3
  export function isElementRefHead(node) {
5
4
  if (ast.isElementRef(node)) {
6
5
  return !ast.isElementRef(node.$container);
@@ -8,7 +7,7 @@ export function isElementRefHead(node) {
8
7
  if (ast.isStrictElementRef(node)) {
9
8
  return !ast.isStrictElementRef(node.$container);
10
9
  }
11
- failExpectedNever(node);
10
+ nonexhaustive(node);
12
11
  }
13
12
  export function elementRef(node) {
14
13
  invariant(isElementRefHead(node), 'Expected head ElementRef');
@@ -1,9 +1,28 @@
1
1
  /******************************************************************************
2
- * This file was generated by langium-cli 1.2.1.
2
+ * This file was generated by langium-cli 2.0.0.
3
3
  * DO NOT EDIT MANUALLY!
4
4
  ******************************************************************************/
5
5
  import type { AstNode, Reference, ReferenceInfo, TypeMetaData } from 'langium';
6
6
  import { AbstractAstReflection } from 'langium';
7
+ export declare const LikeC4Terminals: {
8
+ URI_WITH_SCHEMA: RegExp;
9
+ URI_RELATIVE: RegExp;
10
+ RARROW: RegExp;
11
+ Dot: RegExp;
12
+ NotEqual: RegExp;
13
+ Eq: RegExp;
14
+ OpenBlock: RegExp;
15
+ CloseBlock: RegExp;
16
+ Colon: RegExp;
17
+ SemiColon: RegExp;
18
+ Comma: RegExp;
19
+ TagID: RegExp;
20
+ ID: RegExp;
21
+ STRING: RegExp;
22
+ WS: RegExp;
23
+ BLOCK_COMMENT: RegExp;
24
+ LINE_COMMENT: RegExp;
25
+ };
7
26
  export type ElementExpression = ElementKindExpression | ElementRefExpression | ElementTagExpression | WildcardExpression;
8
27
  export declare const ElementExpression = "ElementExpression";
9
28
  export declare function isElementExpression(item: unknown): item is ElementExpression;
@@ -66,7 +85,7 @@ export interface ElementKind extends AstNode {
66
85
  export declare const ElementKind = "ElementKind";
67
86
  export declare function isElementKind(item: unknown): item is ElementKind;
68
87
  export interface ElementKindExpression extends AstNode {
69
- readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
88
+ readonly $container: IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
70
89
  readonly $type: 'ElementKindExpression';
71
90
  isEqual: boolean;
72
91
  kind: Reference<ElementKind>;
@@ -82,7 +101,7 @@ export interface ElementRef extends AstNode {
82
101
  export declare const ElementRef = "ElementRef";
83
102
  export declare function isElementRef(item: unknown): item is ElementRef;
84
103
  export interface ElementRefExpression extends AstNode {
85
- readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
104
+ readonly $container: IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
86
105
  readonly $type: 'ElementRefExpression';
87
106
  id: ElementRef;
88
107
  isDescedants: boolean;
@@ -90,7 +109,7 @@ export interface ElementRefExpression extends AstNode {
90
109
  export declare const ElementRefExpression = "ElementRefExpression";
91
110
  export declare function isElementRefExpression(item: unknown): item is ElementRefExpression;
92
111
  export interface ElementStringProperty extends AstNode {
93
- readonly $container: ElementBody | SpecificationElementKind | SpecificationTag;
112
+ readonly $container: ElementBody;
94
113
  readonly $type: 'ElementStringProperty';
95
114
  key: 'description' | 'technology' | 'title';
96
115
  value: string;
@@ -98,7 +117,7 @@ export interface ElementStringProperty extends AstNode {
98
117
  export declare const ElementStringProperty = "ElementStringProperty";
99
118
  export declare function isElementStringProperty(item: unknown): item is ElementStringProperty;
100
119
  export interface ElementTagExpression extends AstNode {
101
- readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
120
+ readonly $container: IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
102
121
  readonly $type: 'ElementTagExpression';
103
122
  isEqual: boolean;
104
123
  tag: Reference<Tag>;
@@ -140,7 +159,7 @@ export interface IconProperty extends AstNode {
140
159
  export declare const IconProperty = "IconProperty";
141
160
  export declare function isIconProperty(item: unknown): item is IconProperty;
142
161
  export interface IncomingExpression extends AstNode {
143
- readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
162
+ readonly $container: InOutExpression | ViewRuleExpression;
144
163
  readonly $type: 'IncomingExpression';
145
164
  arr: RArrow;
146
165
  target: ElementExpression;
@@ -148,7 +167,7 @@ export interface IncomingExpression extends AstNode {
148
167
  export declare const IncomingExpression = "IncomingExpression";
149
168
  export declare function isIncomingExpression(item: unknown): item is IncomingExpression;
150
169
  export interface InOutExpression extends AstNode {
151
- readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
170
+ readonly $container: ViewRuleExpression;
152
171
  readonly $type: 'InOutExpression';
153
172
  arr: RArrow;
154
173
  inout: IncomingExpression;
@@ -188,7 +207,7 @@ export interface ModelViews extends AstNode {
188
207
  export declare const ModelViews = "ModelViews";
189
208
  export declare function isModelViews(item: unknown): item is ModelViews;
190
209
  export interface OutgoingExpression extends AstNode {
191
- readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
210
+ readonly $container: ViewRuleExpression;
192
211
  readonly $type: 'OutgoingExpression';
193
212
  arr: RArrow;
194
213
  source: ElementExpression;
@@ -215,7 +234,7 @@ export interface RelationBody extends AstNode {
215
234
  export declare const RelationBody = "RelationBody";
216
235
  export declare function isRelationBody(item: unknown): item is RelationBody;
217
236
  export interface RelationExpression extends AstNode {
218
- readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
237
+ readonly $container: ViewRuleExpression;
219
238
  readonly $type: 'RelationExpression';
220
239
  arr: RArrow;
221
240
  source: ElementExpression;
@@ -325,7 +344,7 @@ export interface ViewRuleStyle extends AstNode {
325
344
  export declare const ViewRuleStyle = "ViewRuleStyle";
326
345
  export declare function isViewRuleStyle(item: unknown): item is ViewRuleStyle;
327
346
  export interface WildcardExpression extends AstNode {
328
- readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
347
+ readonly $container: IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
329
348
  readonly $type: 'WildcardExpression';
330
349
  isWildcard: boolean;
331
350
  }
@@ -1,8 +1,27 @@
1
1
  /******************************************************************************
2
- * This file was generated by langium-cli 1.2.1.
2
+ * This file was generated by langium-cli 2.0.0.
3
3
  * DO NOT EDIT MANUALLY!
4
4
  ******************************************************************************/
5
5
  import { AbstractAstReflection } from 'langium';
6
+ export const LikeC4Terminals = {
7
+ URI_WITH_SCHEMA: /\w+:\/\/\S+/,
8
+ URI_RELATIVE: /\.{0,2}\/[^\/]\S+/,
9
+ RARROW: /->/,
10
+ Dot: /\b\.\b/,
11
+ NotEqual: /!=/,
12
+ Eq: /=/,
13
+ OpenBlock: /\{/,
14
+ CloseBlock: /\}/,
15
+ Colon: /:/,
16
+ SemiColon: /;/,
17
+ Comma: /,/,
18
+ TagID: /((#)([^\W\d_])(((([^\W\d_])|([0-9]))|(_))|(-))*)/,
19
+ ID: /((([^\W\d_])|(_))(((([^\W\d_])|([0-9]))|(_))|(-))*)/,
20
+ STRING: /"[^"]*"|'[^']*'/,
21
+ WS: /(([\t\r\n\v\f])|([^\S\r\n]))+/,
22
+ BLOCK_COMMENT: /\/\*[\s\S]*?\*\//,
23
+ LINE_COMMENT: /\/\/[^\n\r]*/,
24
+ };
6
25
  export const ElementExpression = 'ElementExpression';
7
26
  export function isElementExpression(item) {
8
27
  return reflection.isInstance(item, ElementExpression);
@@ -1,5 +1,5 @@
1
1
  /******************************************************************************
2
- * This file was generated by langium-cli 1.2.1.
2
+ * This file was generated by langium-cli 2.0.0.
3
3
  * DO NOT EDIT MANUALLY!
4
4
  ******************************************************************************/
5
5
  import type { Grammar } from 'langium';
@@ -1,5 +1,5 @@
1
1
  /******************************************************************************
2
- * This file was generated by langium-cli 1.2.1.
2
+ * This file was generated by langium-cli 2.0.0.
3
3
  * DO NOT EDIT MANUALLY!
4
4
  ******************************************************************************/
5
5
  import { loadGrammarFromJson } from 'langium';
@@ -2689,7 +2689,7 @@ export const LikeC4Grammar = () => loadedLikeC4Grammar ?? (loadedLikeC4Grammar =
2689
2689
  "name": "LETTER",
2690
2690
  "definition": {
2691
2691
  "$type": "RegexToken",
2692
- "regex": "[^\\\\W\\\\d_]"
2692
+ "regex": "/[^\\\\W\\\\d_]/"
2693
2693
  },
2694
2694
  "hidden": false
2695
2695
  },
@@ -2699,7 +2699,7 @@ export const LikeC4Grammar = () => loadedLikeC4Grammar ?? (loadedLikeC4Grammar =
2699
2699
  "name": "DIGIT",
2700
2700
  "definition": {
2701
2701
  "$type": "RegexToken",
2702
- "regex": "[0-9]"
2702
+ "regex": "/[0-9]/"
2703
2703
  },
2704
2704
  "hidden": false
2705
2705
  },
@@ -2709,7 +2709,7 @@ export const LikeC4Grammar = () => loadedLikeC4Grammar ?? (loadedLikeC4Grammar =
2709
2709
  "name": "NEWLINE",
2710
2710
  "definition": {
2711
2711
  "$type": "RegexToken",
2712
- "regex": "[\\\\t\\\\r\\\\n\\\\v\\\\f]"
2712
+ "regex": "/[\\\\t\\\\r\\\\n\\\\v\\\\f]/"
2713
2713
  },
2714
2714
  "hidden": false
2715
2715
  },
@@ -2719,7 +2719,7 @@ export const LikeC4Grammar = () => loadedLikeC4Grammar ?? (loadedLikeC4Grammar =
2719
2719
  "name": "SPACE",
2720
2720
  "definition": {
2721
2721
  "$type": "RegexToken",
2722
- "regex": "[^\\\\S\\\\r\\\\n]"
2722
+ "regex": "/[^\\\\S\\\\r\\\\n]/"
2723
2723
  },
2724
2724
  "hidden": false
2725
2725
  },
@@ -2728,7 +2728,7 @@ export const LikeC4Grammar = () => loadedLikeC4Grammar ?? (loadedLikeC4Grammar =
2728
2728
  "name": "URI_WITH_SCHEMA",
2729
2729
  "definition": {
2730
2730
  "$type": "RegexToken",
2731
- "regex": "\\\\w+:\\\\/\\\\/\\\\S+"
2731
+ "regex": "/\\\\w+:\\\\/\\\\/\\\\S+/"
2732
2732
  },
2733
2733
  "fragment": false,
2734
2734
  "hidden": false
@@ -2738,7 +2738,7 @@ export const LikeC4Grammar = () => loadedLikeC4Grammar ?? (loadedLikeC4Grammar =
2738
2738
  "name": "URI_RELATIVE",
2739
2739
  "definition": {
2740
2740
  "$type": "RegexToken",
2741
- "regex": "\\\\.{0,2}\\\\/[^\\\\/]\\\\S+"
2741
+ "regex": "/\\\\.{0,2}\\\\/[^\\\\/]\\\\S+/"
2742
2742
  },
2743
2743
  "fragment": false,
2744
2744
  "hidden": false
@@ -2761,7 +2761,7 @@ export const LikeC4Grammar = () => loadedLikeC4Grammar ?? (loadedLikeC4Grammar =
2761
2761
  "name": "Dot",
2762
2762
  "definition": {
2763
2763
  "$type": "RegexToken",
2764
- "regex": "\\\\b\\\\.\\\\b"
2764
+ "regex": "/\\\\b\\\\.\\\\b/"
2765
2765
  },
2766
2766
  "fragment": false,
2767
2767
  "hidden": false
@@ -2993,7 +2993,7 @@ export const LikeC4Grammar = () => loadedLikeC4Grammar ?? (loadedLikeC4Grammar =
2993
2993
  "name": "STRING",
2994
2994
  "definition": {
2995
2995
  "$type": "RegexToken",
2996
- "regex": "\\"[^\\"]*\\"|'[^']*'"
2996
+ "regex": "/\\"[^\\"]*\\"|'[^']*'/"
2997
2997
  },
2998
2998
  "fragment": false,
2999
2999
  "hidden": false
@@ -3028,7 +3028,7 @@ export const LikeC4Grammar = () => loadedLikeC4Grammar ?? (loadedLikeC4Grammar =
3028
3028
  "name": "BLOCK_COMMENT",
3029
3029
  "definition": {
3030
3030
  "$type": "RegexToken",
3031
- "regex": "\\\\/\\\\*[\\\\s\\\\S]*?\\\\*\\\\/"
3031
+ "regex": "/\\\\/\\\\*[\\\\s\\\\S]*?\\\\*\\\\//"
3032
3032
  },
3033
3033
  "fragment": false
3034
3034
  },
@@ -3038,7 +3038,7 @@ export const LikeC4Grammar = () => loadedLikeC4Grammar ?? (loadedLikeC4Grammar =
3038
3038
  "name": "LINE_COMMENT",
3039
3039
  "definition": {
3040
3040
  "$type": "RegexToken",
3041
- "regex": "\\\\/\\\\/[^\\\\n\\\\r]*"
3041
+ "regex": "/\\\\/\\\\/[^\\\\n\\\\r]*/"
3042
3042
  },
3043
3043
  "fragment": false
3044
3044
  }
@@ -1,9 +1,13 @@
1
1
  /******************************************************************************
2
- * This file was generated by langium-cli 1.2.1.
2
+ * This file was generated by langium-cli 2.0.0.
3
3
  * DO NOT EDIT MANUALLY!
4
4
  ******************************************************************************/
5
- import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LangiumSharedServices, LangiumServices, LanguageMetaData, Module, IParserConfig } from 'langium';
6
- export declare const LikeC4LanguageMetaData: LanguageMetaData;
5
+ import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LangiumSharedServices, LangiumServices, Module, IParserConfig } from 'langium';
6
+ export declare const LikeC4LanguageMetaData: {
7
+ readonly languageId: "likec4";
8
+ readonly fileExtensions: readonly [".c4", ".likec4", ".like-c4"];
9
+ readonly caseInsensitive: false;
10
+ };
7
11
  export declare const parserConfig: IParserConfig;
8
12
  export declare const LikeC4GeneratedSharedModule: Module<LangiumSharedServices, LangiumGeneratedSharedServices>;
9
13
  export declare const LikeC4GeneratedModule: Module<LangiumServices, LangiumGeneratedServices>;
@@ -1,9 +1,9 @@
1
1
  /******************************************************************************
2
- * This file was generated by langium-cli 1.2.1.
2
+ * This file was generated by langium-cli 2.0.0.
3
3
  * DO NOT EDIT MANUALLY!
4
4
  ******************************************************************************/
5
- import { LikeC4AstReflection } from './ast';
6
- import { LikeC4Grammar } from './grammar';
5
+ import { LikeC4AstReflection } from './ast.js';
6
+ import { LikeC4Grammar } from './grammar.js';
7
7
  export const LikeC4LanguageMetaData = {
8
8
  languageId: 'likec4',
9
9
  fileExtensions: ['.c4', '.likec4', '.like-c4'],
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { logger } from './logger';
1
2
  export { createLanguageServices } from './module';
2
3
  export type { LikeC4Services } from './module';
3
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ export { logger } from './logger';
1
2
  export { createLanguageServices } from './module';
2
3
  //# sourceMappingURL=index.js.map
package/dist/logger.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  export declare const logger: {
2
+ trace(message: string): void;
2
3
  debug(message: string): void;
3
4
  info(message: string): void;
4
- warn(message: string | Error | unknown): void;
5
- log(message: string): void;
6
- error(message: string | Error | unknown): void;
7
- trace(message: string): void;
5
+ warn(message: string): void;
6
+ error(message: any): void;
7
+ silent(silent?: boolean): void;
8
8
  };
9
9
  export type Logger = typeof logger;
10
+ export declare function logError(error: unknown): void;
11
+ export declare function logWarnError(err: unknown): void;
10
12
  //# sourceMappingURL=logger.d.ts.map
package/dist/logger.js CHANGED
@@ -1,21 +1,49 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { normalizeError, serializeError } from '@likec4/core';
3
+ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
4
+ let isSilent = false;
1
5
  export const logger = {
6
+ trace(message) {
7
+ if (isSilent)
8
+ return;
9
+ console.trace(message);
10
+ },
2
11
  debug(message) {
12
+ if (isSilent)
13
+ return;
3
14
  console.debug(message);
4
15
  },
5
16
  info(message) {
17
+ if (isSilent)
18
+ return;
6
19
  console.info(message);
7
20
  },
8
21
  warn(message) {
22
+ if (isSilent)
23
+ return;
9
24
  console.warn(message);
10
25
  },
11
- log(message) {
12
- console.log(message);
13
- },
14
26
  error(message) {
15
- console.error(message);
27
+ if (isSilent)
28
+ return;
29
+ if (typeof message === 'string') {
30
+ console.error(message);
31
+ return;
32
+ }
33
+ console.error(normalizeError(message));
16
34
  },
17
- trace(message) {
18
- console.debug(message);
35
+ silent(silent = true) {
36
+ isSilent = silent;
19
37
  }
20
38
  };
39
+ export function logError(error) {
40
+ logger.error(error);
41
+ }
42
+ export function logWarnError(err) {
43
+ if (typeof err === 'string') {
44
+ logger.warn(err);
45
+ return;
46
+ }
47
+ logger.warn(serializeError(err).message);
48
+ }
21
49
  //# sourceMappingURL=logger.js.map
@@ -1,9 +1,9 @@
1
- import type { LangiumDocument, LangiumSharedServices, MaybePromise } from 'langium';
2
- import type { CodeLensProvider } from 'langium/lib/lsp/code-lens-provider';
1
+ import type { CodeLensProvider, LangiumDocument, MaybePromise } from 'langium';
3
2
  import type { CancellationToken, CodeLens, CodeLensParams } from 'vscode-languageserver';
3
+ import type { LikeC4Services } from '../module';
4
4
  export declare class LikeC4CodeLensProvider implements CodeLensProvider {
5
5
  private services;
6
- constructor(services: LangiumSharedServices);
6
+ constructor(services: LikeC4Services);
7
7
  provideCodeLens(doc: LangiumDocument, _params: CodeLensParams, _cancelToken?: CancellationToken): MaybePromise<CodeLens[] | undefined>;
8
8
  }
9
9
  //# sourceMappingURL=CodeLensProvider.d.ts.map
@@ -1,8 +1,9 @@
1
- import type { LangiumDocument, LangiumSharedServices, MaybePromise, DocumentLinkProvider } from 'langium';
1
+ import type { DocumentLinkProvider, LangiumDocument, MaybePromise } from 'langium';
2
2
  import type { DocumentLink, DocumentLinkParams } from 'vscode-languageserver-protocol';
3
+ import type { LikeC4Services } from '../module';
3
4
  export declare class LikeC4DocumentLinkProvider implements DocumentLinkProvider {
4
5
  private services;
5
- constructor(services: LangiumSharedServices);
6
+ constructor(services: LikeC4Services);
6
7
  getDocumentLinks(doc: LangiumDocument, _params: DocumentLinkParams): MaybePromise<DocumentLink[]>;
7
8
  }
8
9
  //# sourceMappingURL=DocumentLinkProvider.d.ts.map
@@ -1,6 +1,6 @@
1
- import { findNodeForProperty, streamAllContents } from 'langium/lib/utils';
1
+ import { findNodeForProperty, streamAllContents } from 'langium';
2
2
  import { ast, isParsedLikeC4LangiumDocument } from '../ast';
3
- import { logger } from '../logger';
3
+ import { logError } from '../logger';
4
4
  export class LikeC4DocumentLinkProvider {
5
5
  services;
6
6
  constructor(services) {
@@ -27,7 +27,7 @@ export class LikeC4DocumentLinkProvider {
27
27
  };
28
28
  }
29
29
  catch (e) {
30
- logger.error(e);
30
+ logError(e);
31
31
  return [];
32
32
  }
33
33
  })
@@ -2,7 +2,7 @@ import { findNodeForProperty } from 'langium';
2
2
  import { compact, isEmpty, map, pipe } from 'remeda';
3
3
  import { SymbolKind } from 'vscode-languageserver-protocol';
4
4
  import { ast } from '../ast';
5
- import { logger } from '../logger';
5
+ import { logError } from '../logger';
6
6
  function getElementKindSymbol(astKind) {
7
7
  if (!astKind.$cstNode || !astKind.kind.$cstNode || isEmpty(astKind.kind.name))
8
8
  return null;
@@ -56,7 +56,7 @@ export class LikeC4DocumentSymbolProvider {
56
56
  return fn() ?? [];
57
57
  }
58
58
  catch (e) {
59
- logger.error(e);
59
+ logError(e);
60
60
  return [];
61
61
  }
62
62
  });
@@ -115,7 +115,7 @@ export class LikeC4DocumentSymbolProvider {
115
115
  }
116
116
  }
117
117
  catch (e) {
118
- logger.error(e);
118
+ logError(e);
119
119
  }
120
120
  return [];
121
121
  }
@@ -1,3 +1,5 @@
1
+ export * from './CodeLensProvider';
2
+ export * from './DocumentLinkProvider';
1
3
  export * from './DocumentSymbolProvider';
2
4
  export * from './HoverProvider';
3
5
  export * from './SemanticTokenProvider';
package/dist/lsp/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './CodeLensProvider';
2
+ export * from './DocumentLinkProvider';
1
3
  export * from './DocumentSymbolProvider';
2
4
  export * from './HoverProvider';
3
5
  export * from './SemanticTokenProvider';