@likec4/language-server 1.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/contrib/likec4.monarch.ts +4 -9
- package/contrib/likec4.tmLanguage.json +1 -1
- package/dist/ast.d.ts +14 -20
- package/dist/ast.js +30 -25
- package/dist/generated/ast.d.ts +24 -3
- package/dist/generated/ast.js +40 -8
- package/dist/generated/grammar.js +1 -1
- package/dist/lsp/SemanticTokenProvider.js +8 -1
- package/dist/model/model-builder.js +62 -28
- package/dist/model/model-locator.js +1 -1
- package/dist/model/model-parser.js +29 -17
- package/dist/model-change/ModelChanges.js +24 -26
- package/dist/model-change/{changeViewStyle.d.ts → changeElementStyle.d.ts} +5 -5
- package/dist/model-change/changeElementStyle.js +141 -0
- package/dist/protocol.d.ts +12 -12
- package/dist/references/scope-computation.js +5 -3
- package/dist/validation/index.js +2 -0
- package/dist/validation/property-checks.d.ts +5 -0
- package/dist/validation/property-checks.js +11 -0
- package/package.json +4 -4
- package/dist/model-change/changeViewStyle.js +0 -123
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# `@likec4/language-server`
|
|
2
2
|
|
|
3
|
-
[docs](https://likec4.dev/
|
|
3
|
+
[docs](https://docs.likec4.dev/) | [playground](https://playground.likec4.dev/) | [demo](https://template.likec4.dev/view/cloud)
|
|
4
4
|
|
|
5
5
|
Language Server Protocol (LSP) based on [languim](https://github.com/languim/languim) library.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Monarch syntax highlighting for the likec4 language.
|
|
2
2
|
export default {
|
|
3
3
|
keywords: [
|
|
4
|
-
'BottomTop','LeftRight','RightLeft','TopBottom','amber','autoLayout','blue','browser','color','crow','cylinder','dashed','description','diamond','dotted','element','exclude','extend','extends','gray','green','head','icon','include','indigo','it','kind','line','link','mobile','model','muted','navigateTo','none','normal','odiamond','of','onormal','open','person','primary','queue','rectangle','red','relationship','secondary','shape','sky','slate','solid','specification','storage','style','tag','tail','technology','this','title','vee','view','views','with'
|
|
4
|
+
'BottomTop','LeftRight','RightLeft','TopBottom','amber','autoLayout','blue','border','browser','color','crow','cylinder','dashed','description','diamond','dotted','element','exclude','extend','extends','gray','green','head','icon','include','indigo','it','kind','line','link','mobile','model','muted','navigateTo','none','normal','odiamond','of','onormal','opacity','open','person','primary','queue','rectangle','red','relationship','secondary','shape','sky','slate','solid','specification','storage','style','tag','tail','technology','this','title','vee','view','views','with'
|
|
5
5
|
],
|
|
6
6
|
operators: [
|
|
7
7
|
'*','->','<->'
|
|
@@ -10,11 +10,6 @@ export default {
|
|
|
10
10
|
|
|
11
11
|
tokenizer: {
|
|
12
12
|
initial: [
|
|
13
|
-
{ regex: /_/, action: {"token":"UNDERSCORE"} },
|
|
14
|
-
{ regex: /-/, action: {"token":"DASH"} },
|
|
15
|
-
{ regex: /[^\W\d_]/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"LETTER"} }} },
|
|
16
|
-
{ regex: /[0-9]/, action: {"token":"DIGIT"} },
|
|
17
|
-
{ regex: /[\r?\n]/, action: {"token":"NEWLINE"} },
|
|
18
13
|
{ regex: /\w+:\/\/\S+/, action: {"token":"URI_WITH_SCHEMA"} },
|
|
19
14
|
{ regex: /\.{0,2}\/[^\/]\S+/, action: {"token":"URI_RELATIVE"} },
|
|
20
15
|
{ regex: /\b\._/, action: {"token":"DotUnderscore"} },
|
|
@@ -26,16 +21,16 @@ export default {
|
|
|
26
21
|
{ regex: /:/, action: {"token":"Colon"} },
|
|
27
22
|
{ regex: /;/, action: {"token":"SemiColon"} },
|
|
28
23
|
{ regex: /,/, action: {"token":"Comma"} },
|
|
24
|
+
{ regex: /\b\d+%/, action: {"token":"Percent"} },
|
|
29
25
|
{ regex: /"[^"]*"|'[^']*'/, action: {"token":"string"} },
|
|
30
|
-
{ regex:
|
|
26
|
+
{ regex: /\b(_+[a-zA-Z]|[a-zA-Z])[\w_-]*/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"IdTerminal"} }} },
|
|
31
27
|
{ include: '@whitespace' },
|
|
32
28
|
{ regex: /@symbols/, action: { cases: { '@operators': {"token":"operator"}, '@default': {"token":""} }} },
|
|
33
29
|
],
|
|
34
30
|
whitespace: [
|
|
35
|
-
{ regex: /[^\S\r\n]/, action: {"token":"white"} },
|
|
36
31
|
{ regex: /\/\*/, action: {"token":"comment","next":"@comment"} },
|
|
37
32
|
{ regex: /\/\/[^\n\r]*/, action: {"token":"comment"} },
|
|
38
|
-
{ regex:
|
|
33
|
+
{ regex: /\s+/, action: {"token":"white"} },
|
|
39
34
|
],
|
|
40
35
|
comment: [
|
|
41
36
|
{ regex: /[^/\*]+/, action: {"token":"comment"} },
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"name": "keyword.control.likec4",
|
|
15
|
-
"match": "\\b(BottomTop|LeftRight|RightLeft|TopBottom|amber|autoLayout|blue|browser|color|crow|cylinder|dashed|description|diamond|dotted|element|exclude|extend|extends|gray|green|head|icon|include|indigo|it|kind|line|link|mobile|model|muted|navigateTo|none|normal|odiamond|of|onormal|open|person|primary|queue|rectangle|red|relationship|secondary|shape|sky|slate|solid|specification|storage|style|tag|tail|technology|this|title|vee|view|views|with)\\b"
|
|
15
|
+
"match": "\\b(BottomTop|LeftRight|RightLeft|TopBottom|amber|autoLayout|blue|border|browser|color|crow|cylinder|dashed|description|diamond|dotted|element|exclude|extend|extends|gray|green|head|icon|include|indigo|it|kind|line|link|mobile|model|muted|navigateTo|none|normal|odiamond|of|onormal|opacity|open|person|primary|queue|rectangle|red|relationship|secondary|shape|sky|slate|solid|specification|storage|style|tag|tail|technology|this|title|vee|view|views|with)\\b"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"name": "string.quoted.double.likec4",
|
package/dist/ast.d.ts
CHANGED
|
@@ -15,12 +15,15 @@ declare module './generated/ast' {
|
|
|
15
15
|
[idattr]?: c4.ViewID | undefined;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
type ParsedElementStyle = {
|
|
19
|
+
shape?: c4.ElementShape;
|
|
20
|
+
icon?: c4.IconUrl;
|
|
21
|
+
color?: c4.ThemeColor;
|
|
22
|
+
border?: c4.BorderStyle;
|
|
23
|
+
opacity?: number;
|
|
24
|
+
};
|
|
18
25
|
export interface ParsedAstSpecification {
|
|
19
|
-
kinds: Record<c4.ElementKind,
|
|
20
|
-
shape?: c4.ElementShape;
|
|
21
|
-
color?: c4.ThemeColor;
|
|
22
|
-
icon?: c4.IconUrl;
|
|
23
|
-
}>;
|
|
26
|
+
kinds: Record<c4.ElementKind, ParsedElementStyle>;
|
|
24
27
|
relationships: Record<c4.RelationshipKind, {
|
|
25
28
|
color?: c4.ThemeColor;
|
|
26
29
|
line?: c4.RelationshipLineType;
|
|
@@ -35,11 +38,9 @@ export interface ParsedAstElement {
|
|
|
35
38
|
title: string;
|
|
36
39
|
description?: string;
|
|
37
40
|
technology?: string;
|
|
38
|
-
icon?: c4.IconUrl;
|
|
39
41
|
tags?: c4.NonEmptyArray<c4.Tag>;
|
|
40
42
|
links?: c4.NonEmptyArray<string>;
|
|
41
|
-
|
|
42
|
-
color?: c4.ThemeColor;
|
|
43
|
+
style: ParsedElementStyle;
|
|
43
44
|
}
|
|
44
45
|
export interface ParsedAstRelation {
|
|
45
46
|
id: c4.RelationID;
|
|
@@ -101,27 +102,20 @@ export declare function isLikeC4LangiumDocument(doc: LangiumDocument): doc is Li
|
|
|
101
102
|
export declare function isParsedLikeC4LangiumDocument(doc: LangiumDocument): doc is ParsedLikeC4LangiumDocument;
|
|
102
103
|
type Guard<N extends AstNode> = (n: AstNode) => n is N;
|
|
103
104
|
type Guarded<G> = G extends Guard<infer N> ? N : never;
|
|
104
|
-
declare const isValidatableAstNode: (n: AstNode) => n is ast.DescedantsExpr | ast.ElementKindExpr | ast.ElementRef | ast.ElementTagExpr | ast.ExpandElementExpr | ast.WildcardExpr | ast.ElementStringProperty | ast.LinkProperty | ast.StyleProperties | ast.ExplicitRelation | ast.ImplicitRelation | ast.RelationStringProperty | ast.RelationStyleProperty | ast.ViewStringProperty | ast.ViewRuleAutoLayout | ast.ExcludePredicate | ast.IncludePredicate | ast.ViewRuleStyle | ast.CustomElementExpr | ast.InOutExpr | ast.IncomingExpr | ast.OutgoingExpr | ast.RelationExpr | ast.SpecificationRelationshipKind | ast.RelationBody | ast.ElementBody | ast.ExtendElementBody | ast.Model | ast.Element | ast.ExtendElement | ast.SpecificationRule | ast.SpecificationElementKind | ast.ElementViewBody | ast.ElementView | ast.ModelViews | ast.SpecificationTag;
|
|
105
|
+
declare const isValidatableAstNode: (n: AstNode) => n is ast.DescedantsExpr | ast.ElementKindExpr | ast.ElementRef | ast.ElementTagExpr | ast.ExpandElementExpr | ast.WildcardExpr | ast.ElementStringProperty | ast.LinkProperty | ast.StyleProperties | ast.ExplicitRelation | ast.ImplicitRelation | ast.RelationStringProperty | ast.RelationStyleProperty | ast.ViewStringProperty | ast.ViewRuleAutoLayout | ast.ExcludePredicate | ast.IncludePredicate | ast.ViewRuleStyle | ast.CustomElementExpr | ast.InOutExpr | ast.IncomingExpr | ast.OutgoingExpr | ast.RelationExpr | ast.SpecificationRelationshipKind | ast.RelationBody | ast.ElementBody | ast.ExtendElementBody | ast.Model | ast.Element | ast.ExtendElement | ast.SpecificationRule | ast.CustomElementExprBody | ast.SpecificationElementKind | ast.ElementViewBody | ast.ElementView | ast.ModelViews | ast.Tags | ast.SpecificationTag;
|
|
105
106
|
type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
|
|
106
107
|
export declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
|
|
107
108
|
isValid: (n: ValidatableAstNode) => boolean;
|
|
108
|
-
invalidNodes: WeakSet<ast.DescedantsExpr | ast.ElementKindExpr | ast.ElementRef | ast.ElementTagExpr | ast.ExpandElementExpr | ast.WildcardExpr | ast.ElementStringProperty | ast.LinkProperty | ast.StyleProperties | ast.ExplicitRelation | ast.ImplicitRelation | ast.RelationStringProperty | ast.RelationStyleProperty | ast.ViewStringProperty | ast.ViewRuleAutoLayout | ast.ExcludePredicate | ast.IncludePredicate | ast.ViewRuleStyle | ast.CustomElementExpr | ast.InOutExpr | ast.IncomingExpr | ast.OutgoingExpr | ast.RelationExpr | ast.SpecificationRelationshipKind | ast.RelationBody | ast.ElementBody | ast.ExtendElementBody | ast.Model | ast.Element | ast.ExtendElement | ast.SpecificationRule | ast.SpecificationElementKind | ast.ElementViewBody | ast.ElementView | ast.ModelViews | ast.SpecificationTag>;
|
|
109
|
+
invalidNodes: WeakSet<ast.DescedantsExpr | ast.ElementKindExpr | ast.ElementRef | ast.ElementTagExpr | ast.ExpandElementExpr | ast.WildcardExpr | ast.ElementStringProperty | ast.LinkProperty | ast.StyleProperties | ast.ExplicitRelation | ast.ImplicitRelation | ast.RelationStringProperty | ast.RelationStyleProperty | ast.ViewStringProperty | ast.ViewRuleAutoLayout | ast.ExcludePredicate | ast.IncludePredicate | ast.ViewRuleStyle | ast.CustomElementExpr | ast.InOutExpr | ast.IncomingExpr | ast.OutgoingExpr | ast.RelationExpr | ast.SpecificationRelationshipKind | ast.RelationBody | ast.ElementBody | ast.ExtendElementBody | ast.Model | ast.Element | ast.ExtendElement | ast.SpecificationRule | ast.CustomElementExprBody | ast.SpecificationElementKind | ast.ElementViewBody | ast.ElementView | ast.ModelViews | ast.Tags | ast.SpecificationTag>;
|
|
109
110
|
};
|
|
111
|
+
export type ChecksFromDiagnostics = ReturnType<typeof checksFromDiagnostics>;
|
|
110
112
|
export declare function streamModel(doc: LikeC4LangiumDocument): Generator<ast.Relation | ast.Element, void, unknown>;
|
|
111
113
|
export declare function resolveRelationPoints(node: ast.Relation): {
|
|
112
114
|
source: ast.Element;
|
|
113
115
|
target: ast.Element;
|
|
114
116
|
};
|
|
115
|
-
export declare function
|
|
116
|
-
|
|
117
|
-
shape?: c4.ElementShape;
|
|
118
|
-
icon?: c4.IconUrl;
|
|
119
|
-
};
|
|
120
|
-
export declare function toElementStyleExcludeDefaults(props?: ast.StyleProperties['props']): {
|
|
121
|
-
shape?: "browser" | "cylinder" | "mobile" | "person" | "queue" | "storage";
|
|
122
|
-
color?: "amber" | "blue" | "gray" | "green" | "indigo" | "muted" | "red" | "secondary" | "sky" | "slate";
|
|
123
|
-
icon?: c4.IconUrl;
|
|
124
|
-
};
|
|
117
|
+
export declare function parseAstOpacityProperty({ value }: ast.OpacityProperty): number;
|
|
118
|
+
export declare function toElementStyle(props?: Array<ast.StyleProperty>): ParsedElementStyle;
|
|
125
119
|
export declare function toRelationshipStyle(props?: ast.SpecificationRelationshipKind['props']): {
|
|
126
120
|
color?: c4.ThemeColor;
|
|
127
121
|
line?: c4.RelationshipLineType;
|
package/dist/ast.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DefaultArrowType,
|
|
3
|
-
DefaultElementShape,
|
|
4
3
|
DefaultLineStyle,
|
|
5
4
|
DefaultRelationshipColor,
|
|
6
|
-
DefaultThemeColor,
|
|
7
5
|
nonexhaustive,
|
|
8
6
|
RelationRefError
|
|
9
7
|
} from "@likec4/core";
|
|
10
8
|
import { AstUtils, DocumentState } from "langium";
|
|
11
|
-
import { isNullish } from "remeda";
|
|
9
|
+
import { clamp, isNullish } from "remeda";
|
|
12
10
|
import { DiagnosticSeverity } from "vscode-languageserver-protocol";
|
|
13
11
|
import { elementRef } from "./elementRef.js";
|
|
14
12
|
import * as ast from "./generated/ast.js";
|
|
@@ -62,9 +60,9 @@ function validatableAstNodeGuards(predicates) {
|
|
|
62
60
|
return (n) => predicates.some((p) => p(n));
|
|
63
61
|
}
|
|
64
62
|
const isValidatableAstNode = validatableAstNodeGuards([
|
|
65
|
-
ast.
|
|
63
|
+
ast.isCustomElementExprBody,
|
|
66
64
|
ast.isViewRulePredicateExpr,
|
|
67
|
-
ast.
|
|
65
|
+
ast.isTags,
|
|
68
66
|
ast.isViewRule,
|
|
69
67
|
ast.isViewProperty,
|
|
70
68
|
ast.isElementViewBody,
|
|
@@ -151,36 +149,43 @@ export function resolveRelationPoints(node) {
|
|
|
151
149
|
target
|
|
152
150
|
};
|
|
153
151
|
}
|
|
152
|
+
export function parseAstOpacityProperty({ value }) {
|
|
153
|
+
const opacity = parseFloat(value);
|
|
154
|
+
return isNaN(opacity) ? 100 : clamp(opacity, { min: 0, max: 100 });
|
|
155
|
+
}
|
|
154
156
|
export function toElementStyle(props) {
|
|
155
157
|
const result = {};
|
|
156
158
|
if (!props || props.length === 0) {
|
|
157
159
|
return result;
|
|
158
160
|
}
|
|
159
161
|
for (const prop of props) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
switch (true) {
|
|
163
|
+
case ast.isBorderProperty(prop): {
|
|
164
|
+
result.border = prop.value;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case ast.isColorProperty(prop): {
|
|
168
|
+
result.color = prop.value;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case ast.isShapeProperty(prop): {
|
|
172
|
+
result.shape = prop.value;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
case ast.isIconProperty(prop): {
|
|
176
|
+
result.icon = prop.value;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case ast.isOpacityProperty(prop): {
|
|
180
|
+
result.opacity = parseAstOpacityProperty(prop);
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
default:
|
|
184
|
+
nonexhaustive(prop.$type);
|
|
171
185
|
}
|
|
172
|
-
nonexhaustive(prop);
|
|
173
186
|
}
|
|
174
187
|
return result;
|
|
175
188
|
}
|
|
176
|
-
export function toElementStyleExcludeDefaults(props) {
|
|
177
|
-
const { color, shape, ...rest } = toElementStyle(props);
|
|
178
|
-
return {
|
|
179
|
-
...rest,
|
|
180
|
-
...color && color !== DefaultThemeColor ? { color } : {},
|
|
181
|
-
...shape && shape !== DefaultElementShape ? { shape } : {}
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
189
|
export function toRelationshipStyle(props) {
|
|
185
190
|
const result = {};
|
|
186
191
|
if (!props || props.length === 0) {
|
package/dist/generated/ast.d.ts
CHANGED
|
@@ -19,11 +19,14 @@ export declare const LikeC4Terminals: {
|
|
|
19
19
|
Colon: RegExp;
|
|
20
20
|
SemiColon: RegExp;
|
|
21
21
|
Comma: RegExp;
|
|
22
|
+
Percent: RegExp;
|
|
22
23
|
String: RegExp;
|
|
23
24
|
IdTerminal: RegExp;
|
|
24
25
|
};
|
|
25
26
|
export type ArrowType = 'crow' | 'diamond' | 'none' | 'normal' | 'odiamond' | 'onormal' | 'open' | 'vee';
|
|
26
27
|
export declare function isArrowType(item: unknown): item is ArrowType;
|
|
28
|
+
export type BorderStyleValue = 'none' | LineOptions;
|
|
29
|
+
export declare function isBorderStyleValue(item: unknown): item is BorderStyleValue;
|
|
27
30
|
export type ElementExpr = DescedantsExpr | ElementKindExpr | ElementRef | ElementTagExpr | ExpandElementExpr | WildcardExpr;
|
|
28
31
|
export declare const ElementExpr = "ElementExpr";
|
|
29
32
|
export declare function isElementExpr(item: unknown): item is ElementExpr;
|
|
@@ -45,7 +48,7 @@ export declare function isRelationProperty(item: unknown): item is RelationPrope
|
|
|
45
48
|
export type RelationshipStyleProperty = ArrowProperty | ColorProperty | LineProperty;
|
|
46
49
|
export declare const RelationshipStyleProperty = "RelationshipStyleProperty";
|
|
47
50
|
export declare function isRelationshipStyleProperty(item: unknown): item is RelationshipStyleProperty;
|
|
48
|
-
export type StyleProperty = ColorProperty | IconProperty | ShapeProperty;
|
|
51
|
+
export type StyleProperty = BorderProperty | ColorProperty | IconProperty | OpacityProperty | ShapeProperty;
|
|
49
52
|
export declare const StyleProperty = "StyleProperty";
|
|
50
53
|
export declare function isStyleProperty(item: unknown): item is StyleProperty;
|
|
51
54
|
export type TagId = string;
|
|
@@ -76,6 +79,14 @@ export interface ArrowProperty extends AstNode {
|
|
|
76
79
|
}
|
|
77
80
|
export declare const ArrowProperty = "ArrowProperty";
|
|
78
81
|
export declare function isArrowProperty(item: unknown): item is ArrowProperty;
|
|
82
|
+
export interface BorderProperty extends AstNode {
|
|
83
|
+
readonly $container: CustomElementExprBody | StyleProperties | ViewRuleStyle;
|
|
84
|
+
readonly $type: 'BorderProperty';
|
|
85
|
+
key: 'border';
|
|
86
|
+
value: BorderStyleValue;
|
|
87
|
+
}
|
|
88
|
+
export declare const BorderProperty = "BorderProperty";
|
|
89
|
+
export declare function isBorderProperty(item: unknown): item is BorderProperty;
|
|
79
90
|
export interface ColorProperty extends AstNode {
|
|
80
91
|
readonly $container: CustomElementExprBody | RelationStyleProperty | SpecificationRelationshipKind | StyleProperties | ViewRuleStyle;
|
|
81
92
|
readonly $type: 'ColorProperty';
|
|
@@ -95,7 +106,7 @@ export declare function isCustomElementExpr(item: unknown): item is CustomElemen
|
|
|
95
106
|
export interface CustomElementExprBody extends AstNode {
|
|
96
107
|
readonly $container: CustomElementExpr;
|
|
97
108
|
readonly $type: 'CustomElementExprBody';
|
|
98
|
-
props: Array<
|
|
109
|
+
props: Array<ElementStringProperty | NavigateToProperty | StyleProperty>;
|
|
99
110
|
}
|
|
100
111
|
export declare const CustomElementExprBody = "CustomElementExprBody";
|
|
101
112
|
export declare function isCustomElementExprBody(item: unknown): item is CustomElementExprBody;
|
|
@@ -240,7 +251,7 @@ export interface FqnElementRef extends AstNode {
|
|
|
240
251
|
export declare const FqnElementRef = "FqnElementRef";
|
|
241
252
|
export declare function isFqnElementRef(item: unknown): item is FqnElementRef;
|
|
242
253
|
export interface IconProperty extends AstNode {
|
|
243
|
-
readonly $container: StyleProperties | ViewRuleStyle;
|
|
254
|
+
readonly $container: CustomElementExprBody | StyleProperties | ViewRuleStyle;
|
|
244
255
|
readonly $type: 'IconProperty';
|
|
245
256
|
key: 'icon';
|
|
246
257
|
value: Uri;
|
|
@@ -326,6 +337,14 @@ export interface NavigateToProperty extends AstNode {
|
|
|
326
337
|
}
|
|
327
338
|
export declare const NavigateToProperty = "NavigateToProperty";
|
|
328
339
|
export declare function isNavigateToProperty(item: unknown): item is NavigateToProperty;
|
|
340
|
+
export interface OpacityProperty extends AstNode {
|
|
341
|
+
readonly $container: CustomElementExprBody | StyleProperties | ViewRuleStyle;
|
|
342
|
+
readonly $type: 'OpacityProperty';
|
|
343
|
+
key: 'opacity';
|
|
344
|
+
value: string;
|
|
345
|
+
}
|
|
346
|
+
export declare const OpacityProperty = "OpacityProperty";
|
|
347
|
+
export declare function isOpacityProperty(item: unknown): item is OpacityProperty;
|
|
329
348
|
export interface OutgoingExpr extends AstNode {
|
|
330
349
|
readonly $container: ExcludePredicate | IncludePredicate;
|
|
331
350
|
readonly $type: 'OutgoingExpr';
|
|
@@ -468,6 +487,7 @@ export declare const WildcardExpr = "WildcardExpr";
|
|
|
468
487
|
export declare function isWildcardExpr(item: unknown): item is WildcardExpr;
|
|
469
488
|
export type LikeC4AstType = {
|
|
470
489
|
ArrowProperty: ArrowProperty;
|
|
490
|
+
BorderProperty: BorderProperty;
|
|
471
491
|
ColorProperty: ColorProperty;
|
|
472
492
|
CustomElementExpr: CustomElementExpr;
|
|
473
493
|
CustomElementExprBody: CustomElementExprBody;
|
|
@@ -501,6 +521,7 @@ export type LikeC4AstType = {
|
|
|
501
521
|
Model: Model;
|
|
502
522
|
ModelViews: ModelViews;
|
|
503
523
|
NavigateToProperty: NavigateToProperty;
|
|
524
|
+
OpacityProperty: OpacityProperty;
|
|
504
525
|
OutgoingExpr: OutgoingExpr;
|
|
505
526
|
Relation: Relation;
|
|
506
527
|
RelationBody: RelationBody;
|
package/dist/generated/ast.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AbstractAstReflection } from "langium";
|
|
|
2
2
|
export const LikeC4Terminals = {
|
|
3
3
|
BLOCK_COMMENT: /\/\*[\s\S]*?\*\//,
|
|
4
4
|
LINE_COMMENT: /\/\/[^\n\r]*/,
|
|
5
|
-
WS:
|
|
5
|
+
WS: /\s+/,
|
|
6
6
|
URI_WITH_SCHEMA: /\w+:\/\/\S+/,
|
|
7
7
|
URI_RELATIVE: /\.{0,2}\/[^\/]\S+/,
|
|
8
8
|
DotUnderscore: /\b\._/,
|
|
@@ -14,12 +14,16 @@ export const LikeC4Terminals = {
|
|
|
14
14
|
Colon: /:/,
|
|
15
15
|
SemiColon: /;/,
|
|
16
16
|
Comma: /,/,
|
|
17
|
+
Percent: /\b\d+%/,
|
|
17
18
|
String: /"[^"]*"|'[^']*'/,
|
|
18
|
-
IdTerminal:
|
|
19
|
+
IdTerminal: /\b(_+[a-zA-Z]|[a-zA-Z])[\w_-]*/
|
|
19
20
|
};
|
|
20
21
|
export function isArrowType(item) {
|
|
21
22
|
return item === "none" || item === "normal" || item === "onormal" || item === "diamond" || item === "odiamond" || item === "crow" || item === "open" || item === "vee";
|
|
22
23
|
}
|
|
24
|
+
export function isBorderStyleValue(item) {
|
|
25
|
+
return isLineOptions(item) || item === "none";
|
|
26
|
+
}
|
|
23
27
|
export const ElementExpr = "ElementExpr";
|
|
24
28
|
export function isElementExpr(item) {
|
|
25
29
|
return reflection.isInstance(item, ElementExpr);
|
|
@@ -32,7 +36,7 @@ export function isElementShape(item) {
|
|
|
32
36
|
return item === "rectangle" || item === "person" || item === "browser" || item === "mobile" || item === "cylinder" || item === "storage" || item === "queue";
|
|
33
37
|
}
|
|
34
38
|
export function isId(item) {
|
|
35
|
-
return isElementShape(item) || isThemeColor(item) || isArrowType(item) || isLineOptions(item) || item === "element" || item === "model" || typeof item === "string" &&
|
|
39
|
+
return isElementShape(item) || isThemeColor(item) || isArrowType(item) || isLineOptions(item) || item === "element" || item === "model" || typeof item === "string" && /\b(_+[a-zA-Z]|[a-zA-Z])[\w_-]*/.test(item);
|
|
36
40
|
}
|
|
37
41
|
export function isLineOptions(item) {
|
|
38
42
|
return item === "solid" || item === "dashed" || item === "dotted";
|
|
@@ -85,6 +89,10 @@ export const ArrowProperty = "ArrowProperty";
|
|
|
85
89
|
export function isArrowProperty(item) {
|
|
86
90
|
return reflection.isInstance(item, ArrowProperty);
|
|
87
91
|
}
|
|
92
|
+
export const BorderProperty = "BorderProperty";
|
|
93
|
+
export function isBorderProperty(item) {
|
|
94
|
+
return reflection.isInstance(item, BorderProperty);
|
|
95
|
+
}
|
|
88
96
|
export const ColorProperty = "ColorProperty";
|
|
89
97
|
export function isColorProperty(item) {
|
|
90
98
|
return reflection.isInstance(item, ColorProperty);
|
|
@@ -209,6 +217,10 @@ export const NavigateToProperty = "NavigateToProperty";
|
|
|
209
217
|
export function isNavigateToProperty(item) {
|
|
210
218
|
return reflection.isInstance(item, NavigateToProperty);
|
|
211
219
|
}
|
|
220
|
+
export const OpacityProperty = "OpacityProperty";
|
|
221
|
+
export function isOpacityProperty(item) {
|
|
222
|
+
return reflection.isInstance(item, OpacityProperty);
|
|
223
|
+
}
|
|
212
224
|
export const OutgoingExpr = "OutgoingExpr";
|
|
213
225
|
export function isOutgoingExpr(item) {
|
|
214
226
|
return reflection.isInstance(item, OutgoingExpr);
|
|
@@ -283,7 +295,7 @@ export function isWildcardExpr(item) {
|
|
|
283
295
|
}
|
|
284
296
|
export class LikeC4AstReflection extends AbstractAstReflection {
|
|
285
297
|
getAllTypes() {
|
|
286
|
-
return ["ArrowProperty", "ColorProperty", "CustomElementExpr", "CustomElementExprBody", "DescedantsExpr", "Element", "ElementBody", "ElementExpr", "ElementKind", "ElementKindExpr", "ElementProperty", "ElementRef", "ElementStringProperty", "ElementTagExpr", "ElementView", "ElementViewBody", "ElementViewRef", "ExcludePredicate", "ExpandElementExpr", "ExplicitRelation", "ExtendElement", "ExtendElementBody", "FqnElementRef", "IconProperty", "ImplicitRelation", "InOutExpr", "IncludePredicate", "IncomingExpr", "LikeC4Grammar", "LineProperty", "LinkProperty", "Model", "ModelViews", "NavigateToProperty", "OutgoingExpr", "Relation", "RelationBody", "RelationExpr", "RelationProperty", "RelationStringProperty", "RelationStyleProperty", "RelationshipKind", "RelationshipStyleProperty", "ShapeProperty", "SpecificationElementKind", "SpecificationRelationshipKind", "SpecificationRule", "SpecificationTag", "StyleProperties", "StyleProperty", "Tag", "Tags", "ViewProperty", "ViewRule", "ViewRuleAutoLayout", "ViewRulePredicate", "ViewRulePredicateExpr", "ViewRuleStyle", "ViewStringProperty", "WildcardExpr"];
|
|
298
|
+
return ["ArrowProperty", "BorderProperty", "ColorProperty", "CustomElementExpr", "CustomElementExprBody", "DescedantsExpr", "Element", "ElementBody", "ElementExpr", "ElementKind", "ElementKindExpr", "ElementProperty", "ElementRef", "ElementStringProperty", "ElementTagExpr", "ElementView", "ElementViewBody", "ElementViewRef", "ExcludePredicate", "ExpandElementExpr", "ExplicitRelation", "ExtendElement", "ExtendElementBody", "FqnElementRef", "IconProperty", "ImplicitRelation", "InOutExpr", "IncludePredicate", "IncomingExpr", "LikeC4Grammar", "LineProperty", "LinkProperty", "Model", "ModelViews", "NavigateToProperty", "OpacityProperty", "OutgoingExpr", "Relation", "RelationBody", "RelationExpr", "RelationProperty", "RelationStringProperty", "RelationStyleProperty", "RelationshipKind", "RelationshipStyleProperty", "ShapeProperty", "SpecificationElementKind", "SpecificationRelationshipKind", "SpecificationRule", "SpecificationTag", "StyleProperties", "StyleProperty", "Tag", "Tags", "ViewProperty", "ViewRule", "ViewRuleAutoLayout", "ViewRulePredicate", "ViewRulePredicateExpr", "ViewRuleStyle", "ViewStringProperty", "WildcardExpr"];
|
|
287
299
|
}
|
|
288
300
|
computeIsSubtype(subtype, supertype) {
|
|
289
301
|
switch (subtype) {
|
|
@@ -291,6 +303,12 @@ export class LikeC4AstReflection extends AbstractAstReflection {
|
|
|
291
303
|
case LineProperty: {
|
|
292
304
|
return this.isSubtype(RelationshipStyleProperty, supertype);
|
|
293
305
|
}
|
|
306
|
+
case BorderProperty:
|
|
307
|
+
case IconProperty:
|
|
308
|
+
case OpacityProperty:
|
|
309
|
+
case ShapeProperty: {
|
|
310
|
+
return this.isSubtype(StyleProperty, supertype);
|
|
311
|
+
}
|
|
294
312
|
case ColorProperty: {
|
|
295
313
|
return this.isSubtype(RelationshipStyleProperty, supertype) || this.isSubtype(StyleProperty, supertype);
|
|
296
314
|
}
|
|
@@ -322,10 +340,6 @@ export class LikeC4AstReflection extends AbstractAstReflection {
|
|
|
322
340
|
case ImplicitRelation: {
|
|
323
341
|
return this.isSubtype(Relation, supertype);
|
|
324
342
|
}
|
|
325
|
-
case IconProperty:
|
|
326
|
-
case ShapeProperty: {
|
|
327
|
-
return this.isSubtype(StyleProperty, supertype);
|
|
328
|
-
}
|
|
329
343
|
case LinkProperty: {
|
|
330
344
|
return this.isSubtype(ElementProperty, supertype) || this.isSubtype(RelationProperty, supertype) || this.isSubtype(ViewProperty, supertype);
|
|
331
345
|
}
|
|
@@ -384,6 +398,15 @@ export class LikeC4AstReflection extends AbstractAstReflection {
|
|
|
384
398
|
]
|
|
385
399
|
};
|
|
386
400
|
}
|
|
401
|
+
case "BorderProperty": {
|
|
402
|
+
return {
|
|
403
|
+
name: "BorderProperty",
|
|
404
|
+
properties: [
|
|
405
|
+
{ name: "key" },
|
|
406
|
+
{ name: "value" }
|
|
407
|
+
]
|
|
408
|
+
};
|
|
409
|
+
}
|
|
387
410
|
case "ColorProperty": {
|
|
388
411
|
return {
|
|
389
412
|
name: "ColorProperty",
|
|
@@ -666,6 +689,15 @@ export class LikeC4AstReflection extends AbstractAstReflection {
|
|
|
666
689
|
]
|
|
667
690
|
};
|
|
668
691
|
}
|
|
692
|
+
case "OpacityProperty": {
|
|
693
|
+
return {
|
|
694
|
+
name: "OpacityProperty",
|
|
695
|
+
properties: [
|
|
696
|
+
{ name: "key" },
|
|
697
|
+
{ name: "value" }
|
|
698
|
+
]
|
|
699
|
+
};
|
|
700
|
+
}
|
|
669
701
|
case "OutgoingExpr": {
|
|
670
702
|
return {
|
|
671
703
|
name: "OutgoingExpr",
|