@likec4/language-server 0.6.1 → 0.6.3
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/dist/index.d.ts +0 -1
- package/dist/index.js +0 -13
- package/dist/module.d.ts +3 -1
- package/dist/module.js +6 -2
- package/package.json +5 -5
- package/dist/__test__/parser-smoke/01-Specification.d.ts +0 -3
- package/dist/__test__/parser-smoke/01-Specification.js +0 -42
- package/dist/__test__/parser-smoke/02-Model.d.ts +0 -9
- package/dist/__test__/parser-smoke/02-Model.js +0 -110
- package/dist/__test__/parser-smoke/03-ModelRelation.d.ts +0 -6
- package/dist/__test__/parser-smoke/03-ModelRelation.js +0 -81
- package/dist/__test__/parser-smoke/04-Scope.d.ts +0 -2
- package/dist/__test__/parser-smoke/04-Scope.js +0 -38
- package/dist/__test__/parser-smoke/05-StrictElementRef.d.ts +0 -3
- package/dist/__test__/parser-smoke/05-StrictElementRef.js +0 -46
- package/dist/__test__/parser-smoke/06-ElementRef.d.ts +0 -2
- package/dist/__test__/parser-smoke/06-ElementRef.js +0 -59
- package/dist/__test__/parser-smoke/07-Views.d.ts +0 -10
- package/dist/__test__/parser-smoke/07-Views.js +0 -146
- package/dist/__test__/parser-smoke/08-Structurizr.d.ts +0 -1
- package/dist/__test__/parser-smoke/08-Structurizr.js +0 -22
- package/dist/__test__/parser-smoke/index.d.ts +0 -8
- package/dist/__test__/parser-smoke/index.js +0 -8
- package/dist/__test__/parser-smoke-extendsElement.spec.d.ts +0 -1
- package/dist/__test__/parser-smoke-extendsElement.spec.js +0 -36
- package/dist/__test__/parser-smoke.spec.d.ts +0 -1
- package/dist/__test__/parser-smoke.spec.js +0 -28
- package/dist/model/model-builder.spec.d.ts +0 -1
- package/dist/model/model-builder.spec.js +0 -141
- package/dist/protocol.d.ts +0 -39
- package/dist/protocol.js +0 -19
- package/dist/test/index.d.ts +0 -1
- package/dist/test/index.js +0 -1
- package/dist/test/testServices.d.ts +0 -15
- package/dist/test/testServices.js +0 -57
- package/dist/validation/element.spec.d.ts +0 -1
- package/dist/validation/element.spec.js +0 -65
- package/dist/validation/relation.spec.d.ts +0 -1
- package/dist/validation/relation.spec.js +0 -93
- package/dist/validation/specification.spec.d.ts +0 -1
- package/dist/validation/specification.spec.js +0 -31
- package/dist/validation/view.spec.d.ts +0 -1
- package/dist/validation/view.spec.js +0 -20
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
// import { type DefaultSharedModuleContext, startLanguageServer as startLangiumLanguageServer } from 'langium'
|
|
2
1
|
export { createLanguageServices } from './module';
|
|
3
|
-
// export type { C4XModel } from './c4x-model'
|
|
4
|
-
// export type { C4XLangiumDocument } from './ast'
|
|
5
|
-
// export {
|
|
6
|
-
// LanguageId
|
|
7
|
-
// } from './const'
|
|
8
|
-
export { LikeC4LanguageMetaData as LanguageMetaData } from './generated/module';
|
|
9
|
-
// export { createC4XServices }
|
|
10
|
-
// export function startLanguageServices(context: DefaultSharedModuleContext) {
|
|
11
|
-
// const { shared, likec4 } = createLikeC4Services(context)
|
|
12
|
-
// startLangiumLanguageServer(shared)
|
|
13
|
-
// return likec4
|
|
14
|
-
// }
|
package/dist/module.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ export interface LikeC4AddedServices {
|
|
|
12
12
|
}
|
|
13
13
|
export type LikeC4Services = LangiumServices & LikeC4AddedServices;
|
|
14
14
|
export declare const LikeC4Module: Module<LikeC4Services, PartialLangiumServices & LikeC4AddedServices>;
|
|
15
|
-
|
|
15
|
+
type LanguageServicesContext = Partial<DefaultSharedModuleContext>;
|
|
16
|
+
export declare function createLanguageServices(context?: LanguageServicesContext): {
|
|
16
17
|
shared: LangiumSharedServices;
|
|
17
18
|
likec4: LikeC4Services;
|
|
18
19
|
};
|
|
20
|
+
export {};
|
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createDefaultModule, createDefaultSharedModule, inject } from 'langium';
|
|
1
|
+
import { createDefaultModule, createDefaultSharedModule, EmptyFileSystem, inject } from 'langium';
|
|
2
2
|
import { LikeC4GeneratedModule, LikeC4GeneratedSharedModule } from './generated/module';
|
|
3
3
|
import { LikeC4DocumentSymbolProvider, LikeC4HoverProvider, LikeC4SemanticTokenProvider } from './lsp';
|
|
4
4
|
import { FqnIndex, LikeC4ModelBuilder, LikeC4ModelLocator } from './model';
|
|
@@ -52,7 +52,11 @@ export function createLanguageServices(context) {
|
|
|
52
52
|
// logger.debug = connection.tracer.log.bind(connection.tracer)
|
|
53
53
|
// logger.trace = connection.tracer.log.bind(connection.tracer)
|
|
54
54
|
// }
|
|
55
|
-
const
|
|
55
|
+
const moduleContext = {
|
|
56
|
+
...EmptyFileSystem,
|
|
57
|
+
...context
|
|
58
|
+
};
|
|
59
|
+
const shared = inject(createDefaultSharedModule(moduleContext), LikeC4SharedModule);
|
|
56
60
|
const likec4 = inject(createDefaultModule({ shared }), LikeC4GeneratedModule, LikeC4Module);
|
|
57
61
|
shared.ServiceRegistry.register(likec4);
|
|
58
62
|
registerValidationChecks(likec4);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/language-server",
|
|
3
3
|
"description": "LikeC4 Language Server",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
|
-
"compile": "",
|
|
55
|
-
"release
|
|
54
|
+
"compile": "tsc --emitDeclarationOnly",
|
|
55
|
+
"build:release": "run generate && tsc -p tsconfig.esm.json",
|
|
56
56
|
"build:langium": "langium generate",
|
|
57
57
|
"build:ts": "tsc",
|
|
58
58
|
"watch:langium": "langium generate --watch",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"test:watch": "vitest"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@likec4/core": "0.6.
|
|
70
|
-
"@likec4/language-protocol": "0.6.
|
|
69
|
+
"@likec4/core": "0.6.3",
|
|
70
|
+
"@likec4/language-protocol": "0.6.3",
|
|
71
71
|
"@mobily/ts-belt": "^3.13.1",
|
|
72
72
|
"nanoid": "^4.0.2",
|
|
73
73
|
"object-hash": "^3.0.0",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const valid_01_Specification = "\nspecification {\n element container\n element component {\n style {\n shape: rectangle\n }\n }\n element person {\n style {\n shape: person\n }\n }\n\n tag gray\n tag lightgray\n}\n";
|
|
2
|
-
export declare const valid_01_Specification_ElementKindStyle = "\nspecification {\n element frontend {\n style {\n shape browser\n color secondary\n }\n }\n element person {\n style {\n shape: person\n }\n }\n}\n";
|
|
3
|
-
export declare const invalid_01_Specification_ElementKind = "\nspecification {\n element element {\n style {\n shape browser\n }\n }\n}\n";
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export const valid_01_Specification = `
|
|
2
|
-
specification {
|
|
3
|
-
element container
|
|
4
|
-
element component {
|
|
5
|
-
style {
|
|
6
|
-
shape: rectangle
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
element person {
|
|
10
|
-
style {
|
|
11
|
-
shape: person
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
tag gray
|
|
16
|
-
tag lightgray
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
export const valid_01_Specification_ElementKindStyle = `
|
|
20
|
-
specification {
|
|
21
|
-
element frontend {
|
|
22
|
-
style {
|
|
23
|
-
shape browser
|
|
24
|
-
color secondary
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
element person {
|
|
28
|
-
style {
|
|
29
|
-
shape: person
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
export const invalid_01_Specification_ElementKind = `
|
|
35
|
-
specification {
|
|
36
|
-
element element {
|
|
37
|
-
style {
|
|
38
|
-
shape browser
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
`;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const valid_02_Model_Element = "\nspecification {\n element person\n}\nmodel {\n person user1\n person user2\n}\n";
|
|
2
|
-
export declare const valid_02_Model_Element_2 = "\nspecification {\n element person\n}\nmodel {\n user1 = person\n user2 = person\n}\n";
|
|
3
|
-
export declare const valid_02_Model_Builtin = "\nmodel {\n el1 = element\n el2 = element\n}\n";
|
|
4
|
-
export declare const valid_02_Model_ElementWithTitle = "\nspecification {\n element person\n}\nmodel {\n person user1\n user2 = person 'Person2'\n user3 = person\n}\n";
|
|
5
|
-
export declare const valid_02_Model_Element_Style = "\nspecification {\n element person\n}\nmodel {\n user1 = person {\n style {\n shape person\n color secondary\n }\n }\n user2 = person\n}\n";
|
|
6
|
-
export declare const invalid_02_Model = "\nspecification {\n element person\n}\nmodel {\n user = person\n person 'Person2'\n}\n";
|
|
7
|
-
export declare const valid_02_Model_NestedElemenets = "\nspecification {\n element person\n element system\n element component\n}\nmodel {\n person user1\n user2 = person {\n }\n user3 = person 'Person3'\n component system {\n subsystem = component\n backend = component {\n api = component 'API'\n }\n }\n}\n";
|
|
8
|
-
export declare const invalid_02_Model_NestedElemenets = "\nspecification {\n element person\n element component\n}\nmodel {\n person user1\n component system {\n component 'Subsystem'\n component backend\n }\n}\n";
|
|
9
|
-
export declare const valid_02_ModelElementProps = "\nspecification {\n element component\n tag one\n}\nmodel {\n component system {\n #one\n\n component subsystem {\n title: 'SubSystem'\n }\n component storage {\n title 'Storage'\n style {\n shape: storage\n }\n }\n }\n}\n";
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
export const valid_02_Model_Element = `
|
|
2
|
-
specification {
|
|
3
|
-
element person
|
|
4
|
-
}
|
|
5
|
-
model {
|
|
6
|
-
person user1
|
|
7
|
-
person user2
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
export const valid_02_Model_Element_2 = `
|
|
11
|
-
specification {
|
|
12
|
-
element person
|
|
13
|
-
}
|
|
14
|
-
model {
|
|
15
|
-
user1 = person
|
|
16
|
-
user2 = person
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
export const valid_02_Model_Builtin = `
|
|
20
|
-
model {
|
|
21
|
-
el1 = element
|
|
22
|
-
el2 = element
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
export const valid_02_Model_ElementWithTitle = `
|
|
26
|
-
specification {
|
|
27
|
-
element person
|
|
28
|
-
}
|
|
29
|
-
model {
|
|
30
|
-
person user1
|
|
31
|
-
user2 = person 'Person2'
|
|
32
|
-
user3 = person
|
|
33
|
-
}
|
|
34
|
-
`;
|
|
35
|
-
export const valid_02_Model_Element_Style = `
|
|
36
|
-
specification {
|
|
37
|
-
element person
|
|
38
|
-
}
|
|
39
|
-
model {
|
|
40
|
-
user1 = person {
|
|
41
|
-
style {
|
|
42
|
-
shape person
|
|
43
|
-
color secondary
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
user2 = person
|
|
47
|
-
}
|
|
48
|
-
`;
|
|
49
|
-
export const invalid_02_Model = `
|
|
50
|
-
specification {
|
|
51
|
-
element person
|
|
52
|
-
}
|
|
53
|
-
model {
|
|
54
|
-
user = person
|
|
55
|
-
person 'Person2'
|
|
56
|
-
}
|
|
57
|
-
`;
|
|
58
|
-
export const valid_02_Model_NestedElemenets = `
|
|
59
|
-
specification {
|
|
60
|
-
element person
|
|
61
|
-
element system
|
|
62
|
-
element component
|
|
63
|
-
}
|
|
64
|
-
model {
|
|
65
|
-
person user1
|
|
66
|
-
user2 = person {
|
|
67
|
-
}
|
|
68
|
-
user3 = person 'Person3'
|
|
69
|
-
component system {
|
|
70
|
-
subsystem = component
|
|
71
|
-
backend = component {
|
|
72
|
-
api = component 'API'
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
export const invalid_02_Model_NestedElemenets = `
|
|
78
|
-
specification {
|
|
79
|
-
element person
|
|
80
|
-
element component
|
|
81
|
-
}
|
|
82
|
-
model {
|
|
83
|
-
person user1
|
|
84
|
-
component system {
|
|
85
|
-
component 'Subsystem'
|
|
86
|
-
component backend
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`;
|
|
90
|
-
export const valid_02_ModelElementProps = `
|
|
91
|
-
specification {
|
|
92
|
-
element component
|
|
93
|
-
tag one
|
|
94
|
-
}
|
|
95
|
-
model {
|
|
96
|
-
component system {
|
|
97
|
-
#one
|
|
98
|
-
|
|
99
|
-
component subsystem {
|
|
100
|
-
title: 'SubSystem'
|
|
101
|
-
}
|
|
102
|
-
component storage {
|
|
103
|
-
title 'Storage'
|
|
104
|
-
style {
|
|
105
|
-
shape: storage
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const valid_03_Relation = "\nspecification {\n element person\n}\nmodel {\n person user1\n person user2\n user1 -> user2\n}\n";
|
|
2
|
-
export declare const valid_03_Relation2 = "\nspecification {\n element person\n}\nmodel {\n person user1\n person user2 {\n -> user1\n }\n}\n";
|
|
3
|
-
export declare const valid_03_Relation3 = "\nspecification {\n element person\n}\nmodel {\n person user1 {\n -> user2\n }\n person user2\n}\n";
|
|
4
|
-
export declare const valid_03_Relation4 = "\nspecification {\n element person\n element component\n}\nmodel {\n person user\n component system {\n component subsystem {\n it -> api\n }\n backend = component {\n api = component 'API' {\n -> user\n }\n this -> subsystem\n }\n }\n user -> api\n}\n";
|
|
5
|
-
export declare const valid_03_Relation_with_title = "\nspecification {\n element person\n}\nmodel {\n person user1\n person user2 {\n -> user1 'calls'\n }\n user1 -> user2 'responds to'\n}\n";
|
|
6
|
-
export declare const valid_03_Relation_with_props = "\nspecification {\n element person\n}\nmodel {\n person user1\n person user2 {\n -> user1 {\n title 'calls'\n }\n }\n user1 -> user2 'responds to' {\n title 'some description'\n }\n}\n";
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
export const valid_03_Relation = `
|
|
2
|
-
specification {
|
|
3
|
-
element person
|
|
4
|
-
}
|
|
5
|
-
model {
|
|
6
|
-
person user1
|
|
7
|
-
person user2
|
|
8
|
-
user1 -> user2
|
|
9
|
-
}
|
|
10
|
-
`;
|
|
11
|
-
export const valid_03_Relation2 = `
|
|
12
|
-
specification {
|
|
13
|
-
element person
|
|
14
|
-
}
|
|
15
|
-
model {
|
|
16
|
-
person user1
|
|
17
|
-
person user2 {
|
|
18
|
-
-> user1
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
`;
|
|
22
|
-
export const valid_03_Relation3 = `
|
|
23
|
-
specification {
|
|
24
|
-
element person
|
|
25
|
-
}
|
|
26
|
-
model {
|
|
27
|
-
person user1 {
|
|
28
|
-
-> user2
|
|
29
|
-
}
|
|
30
|
-
person user2
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
export const valid_03_Relation4 = `
|
|
34
|
-
specification {
|
|
35
|
-
element person
|
|
36
|
-
element component
|
|
37
|
-
}
|
|
38
|
-
model {
|
|
39
|
-
person user
|
|
40
|
-
component system {
|
|
41
|
-
component subsystem {
|
|
42
|
-
it -> api
|
|
43
|
-
}
|
|
44
|
-
backend = component {
|
|
45
|
-
api = component 'API' {
|
|
46
|
-
-> user
|
|
47
|
-
}
|
|
48
|
-
this -> subsystem
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
user -> api
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
export const valid_03_Relation_with_title = `
|
|
55
|
-
specification {
|
|
56
|
-
element person
|
|
57
|
-
}
|
|
58
|
-
model {
|
|
59
|
-
person user1
|
|
60
|
-
person user2 {
|
|
61
|
-
-> user1 'calls'
|
|
62
|
-
}
|
|
63
|
-
user1 -> user2 'responds to'
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
export const valid_03_Relation_with_props = `
|
|
67
|
-
specification {
|
|
68
|
-
element person
|
|
69
|
-
}
|
|
70
|
-
model {
|
|
71
|
-
person user1
|
|
72
|
-
person user2 {
|
|
73
|
-
-> user1 {
|
|
74
|
-
title 'calls'
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
user1 -> user2 'responds to' {
|
|
78
|
-
title 'some description'
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
`;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const valid_04_Scope = "\nspecification {\n element person\n element component\n}\nmodel {\n person user\n component system {\n component subsystem {\n -> backend\n }\n backend = component {\n api = component 'API'\n }\n user -> api\n }\n}\n";
|
|
2
|
-
export declare const invalid_04_DuplicateNameInScope = "\nspecification {\n element person\n element component\n}\nmodel {\n person user\n component system {\n component subsystem {\n }\n backend1 = component {\n api = component 'API 1'\n }\n backend2 = component {\n api = component 'API 2'\n }\n user -> api\n }\n}\n";
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export const valid_04_Scope = `
|
|
2
|
-
specification {
|
|
3
|
-
element person
|
|
4
|
-
element component
|
|
5
|
-
}
|
|
6
|
-
model {
|
|
7
|
-
person user
|
|
8
|
-
component system {
|
|
9
|
-
component subsystem {
|
|
10
|
-
-> backend
|
|
11
|
-
}
|
|
12
|
-
backend = component {
|
|
13
|
-
api = component 'API'
|
|
14
|
-
}
|
|
15
|
-
user -> api
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
export const invalid_04_DuplicateNameInScope = `
|
|
20
|
-
specification {
|
|
21
|
-
element person
|
|
22
|
-
element component
|
|
23
|
-
}
|
|
24
|
-
model {
|
|
25
|
-
person user
|
|
26
|
-
component system {
|
|
27
|
-
component subsystem {
|
|
28
|
-
}
|
|
29
|
-
backend1 = component {
|
|
30
|
-
api = component 'API 1'
|
|
31
|
-
}
|
|
32
|
-
backend2 = component {
|
|
33
|
-
api = component 'API 2'
|
|
34
|
-
}
|
|
35
|
-
user -> api
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const valid_05_StrictElementRef = "\nspecification {\n element component\n}\nmodel {\n component system {\n component sub1 {\n component sub2\n }\n }\n extend system {\n }\n extend system.sub1 {\n }\n extend system.sub1.sub2 {\n }\n}\n";
|
|
2
|
-
export declare const invalid_05_StrictElementRefScope = "\nspecification {\n element component\n}\nmodel {\n component system {\n component sub1 {\n component sub2\n }\n }\n extend sub1 {\n }\n}\n";
|
|
3
|
-
export declare const invalid_05_StrictElementChildRefScope = "\nspecification {\n element component\n}\nmodel {\n component system {\n component sub1 {\n component sub2\n }\n }\n extend system.sub2 {\n }\n}\n";
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export const valid_05_StrictElementRef = `
|
|
2
|
-
specification {
|
|
3
|
-
element component
|
|
4
|
-
}
|
|
5
|
-
model {
|
|
6
|
-
component system {
|
|
7
|
-
component sub1 {
|
|
8
|
-
component sub2
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
extend system {
|
|
12
|
-
}
|
|
13
|
-
extend system.sub1 {
|
|
14
|
-
}
|
|
15
|
-
extend system.sub1.sub2 {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
export const invalid_05_StrictElementRefScope = `
|
|
20
|
-
specification {
|
|
21
|
-
element component
|
|
22
|
-
}
|
|
23
|
-
model {
|
|
24
|
-
component system {
|
|
25
|
-
component sub1 {
|
|
26
|
-
component sub2
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
extend sub1 {
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
export const invalid_05_StrictElementChildRefScope = `
|
|
34
|
-
specification {
|
|
35
|
-
element component
|
|
36
|
-
}
|
|
37
|
-
model {
|
|
38
|
-
component system {
|
|
39
|
-
component sub1 {
|
|
40
|
-
component sub2
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
extend system.sub2 {
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
`;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const valid_06_ElementRef = "\nspecification {\n element component\n}\nmodel {\n component user\n component system {\n component sub1 {\n component sub2\n }\n }\n user -> sub1.sub2\n component system2 {\n it -> system.sub2\n }\n}\n";
|
|
2
|
-
export declare const invalid_06_ElementRef = "\nspecification {\n element component\n}\nmodel {\n component user\n component system {\n component sub1 {\n component sub2\n }\n }\n user -> sub2.sub1\n}\n";
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export const valid_06_ElementRef = `
|
|
2
|
-
specification {
|
|
3
|
-
element component
|
|
4
|
-
}
|
|
5
|
-
model {
|
|
6
|
-
component user
|
|
7
|
-
component system {
|
|
8
|
-
component sub1 {
|
|
9
|
-
component sub2
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
user -> sub1.sub2
|
|
13
|
-
component system2 {
|
|
14
|
-
it -> system.sub2
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
18
|
-
export const invalid_06_ElementRef = `
|
|
19
|
-
specification {
|
|
20
|
-
element component
|
|
21
|
-
}
|
|
22
|
-
model {
|
|
23
|
-
component user
|
|
24
|
-
component system {
|
|
25
|
-
component sub1 {
|
|
26
|
-
component sub2
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
user -> sub2.sub1
|
|
30
|
-
}
|
|
31
|
-
`;
|
|
32
|
-
// export const invalid_06_ElementRefScope = `
|
|
33
|
-
// specification {
|
|
34
|
-
// element component
|
|
35
|
-
// }
|
|
36
|
-
// model {
|
|
37
|
-
// component system {
|
|
38
|
-
// component sub1 {
|
|
39
|
-
// component sub2
|
|
40
|
-
// }
|
|
41
|
-
// }
|
|
42
|
-
// extends sub1 {
|
|
43
|
-
// }
|
|
44
|
-
// }
|
|
45
|
-
// `
|
|
46
|
-
// export const invalid_06_ElementChildRefScope = `
|
|
47
|
-
// specification {
|
|
48
|
-
// element component
|
|
49
|
-
// }
|
|
50
|
-
// model {
|
|
51
|
-
// component system {
|
|
52
|
-
// component sub1 {
|
|
53
|
-
// component sub2
|
|
54
|
-
// }
|
|
55
|
-
// }
|
|
56
|
-
// extends system.sub2 {
|
|
57
|
-
// }
|
|
58
|
-
// }
|
|
59
|
-
// `
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const valid_07_View: string;
|
|
2
|
-
export declare const valid_07_ViewOf: string;
|
|
3
|
-
export declare const valid_07_ViewRules: string;
|
|
4
|
-
export declare const invalid_07_ViewRules_Inambiqutes: string;
|
|
5
|
-
export declare const valid_07_ViewRules_IncludeScopeOf: string;
|
|
6
|
-
export declare const valid_07_ViewProperties: string;
|
|
7
|
-
export declare const valid_07_ViewRules_Relations: string;
|
|
8
|
-
export declare const valid_07_ViewStyleRules: string;
|
|
9
|
-
export declare const invalid_07_ViewStyleRules: string;
|
|
10
|
-
export declare const valid_07_ViewLayoutRules: string;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
const model = `
|
|
2
|
-
specification {
|
|
3
|
-
element component
|
|
4
|
-
}
|
|
5
|
-
model {
|
|
6
|
-
component user
|
|
7
|
-
component system {
|
|
8
|
-
component backend {
|
|
9
|
-
component model
|
|
10
|
-
component api
|
|
11
|
-
}
|
|
12
|
-
component auth {
|
|
13
|
-
component api
|
|
14
|
-
}
|
|
15
|
-
component frontend
|
|
16
|
-
}
|
|
17
|
-
component infra {
|
|
18
|
-
component database
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
backend.model -> infra.database
|
|
22
|
-
backend.api -> backend.model
|
|
23
|
-
auth.api -> backend.api
|
|
24
|
-
frontend -> auth.api
|
|
25
|
-
frontend -> backend.api
|
|
26
|
-
user -> frontend
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
export const valid_07_View = model +
|
|
30
|
-
`
|
|
31
|
-
views {
|
|
32
|
-
view index {
|
|
33
|
-
include *
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
37
|
-
export const valid_07_ViewOf = model +
|
|
38
|
-
`
|
|
39
|
-
views {
|
|
40
|
-
view index of system.backend {
|
|
41
|
-
include *
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
`;
|
|
45
|
-
export const valid_07_ViewRules = model +
|
|
46
|
-
`
|
|
47
|
-
views {
|
|
48
|
-
view {
|
|
49
|
-
include *,
|
|
50
|
-
infra.*,
|
|
51
|
-
backend.*
|
|
52
|
-
exclude frontend
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
// Two api: in backend and auth
|
|
57
|
-
export const invalid_07_ViewRules_Inambiqutes = model +
|
|
58
|
-
`
|
|
59
|
-
views {
|
|
60
|
-
view of system {
|
|
61
|
-
include api
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
export const valid_07_ViewRules_IncludeScopeOf = model +
|
|
66
|
-
`
|
|
67
|
-
views {
|
|
68
|
-
view of system.backend {
|
|
69
|
-
include api, auth.api
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
`;
|
|
73
|
-
export const valid_07_ViewProperties = model +
|
|
74
|
-
`
|
|
75
|
-
views {
|
|
76
|
-
view {
|
|
77
|
-
title 'User view'
|
|
78
|
-
description "
|
|
79
|
-
View description
|
|
80
|
-
"
|
|
81
|
-
include *
|
|
82
|
-
exclude -> user
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
`;
|
|
86
|
-
export const valid_07_ViewRules_Relations = model +
|
|
87
|
-
`
|
|
88
|
-
views {
|
|
89
|
-
view {
|
|
90
|
-
include
|
|
91
|
-
-> backend,
|
|
92
|
-
-> backend.*,
|
|
93
|
-
-> backend ->,
|
|
94
|
-
-> backend.* ->,
|
|
95
|
-
backend ->,
|
|
96
|
-
backend.* ->
|
|
97
|
-
exclude
|
|
98
|
-
* -> infra,
|
|
99
|
-
* -> infra.*,
|
|
100
|
-
* -> *
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
`;
|
|
104
|
-
export const valid_07_ViewStyleRules = model +
|
|
105
|
-
`
|
|
106
|
-
views {
|
|
107
|
-
view {
|
|
108
|
-
include *
|
|
109
|
-
style * {
|
|
110
|
-
color: secondary
|
|
111
|
-
}
|
|
112
|
-
style backend, infra {
|
|
113
|
-
color: muted
|
|
114
|
-
}
|
|
115
|
-
exclude -> frontend
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
`;
|
|
119
|
-
export const invalid_07_ViewStyleRules = model +
|
|
120
|
-
`
|
|
121
|
-
views {
|
|
122
|
-
view {
|
|
123
|
-
include *
|
|
124
|
-
style backend, {
|
|
125
|
-
color muted
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
`;
|
|
130
|
-
export const valid_07_ViewLayoutRules = model +
|
|
131
|
-
`
|
|
132
|
-
views {
|
|
133
|
-
view {
|
|
134
|
-
include *
|
|
135
|
-
style * {
|
|
136
|
-
color: secondary
|
|
137
|
-
}
|
|
138
|
-
autoLayout BottomTop
|
|
139
|
-
exclude -> frontend
|
|
140
|
-
}
|
|
141
|
-
view {
|
|
142
|
-
autoLayout LeftRight
|
|
143
|
-
include *
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const valid_08_Structurizr: string;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const model = `
|
|
2
|
-
specification {
|
|
3
|
-
element person
|
|
4
|
-
element group
|
|
5
|
-
element softwareSystem
|
|
6
|
-
element container
|
|
7
|
-
element component
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
export const valid_08_Structurizr = model +
|
|
11
|
-
`
|
|
12
|
-
model {
|
|
13
|
-
u = person "User"
|
|
14
|
-
s = softwareSystem "Software System" {
|
|
15
|
-
webapp = container "Web Application" "" "Spring Boot"
|
|
16
|
-
database = container "Database" "" "Relational database schema"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
u -> webapp "Uses"
|
|
20
|
-
webapp -> database "Reads from and writes to"
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './01-Specification';
|
|
2
|
-
export * from './02-Model';
|
|
3
|
-
export * from './03-ModelRelation';
|
|
4
|
-
export * from './04-Scope';
|
|
5
|
-
export * from './05-StrictElementRef';
|
|
6
|
-
export * from './06-ElementRef';
|
|
7
|
-
export * from './07-Views';
|
|
8
|
-
export * from './08-Structurizr';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './01-Specification';
|
|
2
|
-
export * from './02-Model';
|
|
3
|
-
export * from './03-ModelRelation';
|
|
4
|
-
export * from './04-Scope';
|
|
5
|
-
export * from './05-StrictElementRef';
|
|
6
|
-
export * from './06-ElementRef';
|
|
7
|
-
export * from './07-Views';
|
|
8
|
-
export * from './08-Structurizr';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { expect, test } from 'vitest';
|
|
2
|
-
import { createTestServices } from '../test';
|
|
3
|
-
const document1 = `
|
|
4
|
-
specification {
|
|
5
|
-
element component
|
|
6
|
-
}
|
|
7
|
-
model {
|
|
8
|
-
component system {
|
|
9
|
-
sub = component {
|
|
10
|
-
component sub1
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
15
|
-
const document2 = `
|
|
16
|
-
model {
|
|
17
|
-
extend system.sub {
|
|
18
|
-
component sub2 {
|
|
19
|
-
-> sub1
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
const document3 = `
|
|
25
|
-
model {
|
|
26
|
-
system.sub1 -> system.sub2
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
test('parser smoke: ExtendsElement Scope', async () => {
|
|
30
|
-
const { parse, validateAll } = createTestServices();
|
|
31
|
-
await parse(document1);
|
|
32
|
-
await parse(document2);
|
|
33
|
-
await parse(document3);
|
|
34
|
-
const { errors } = await validateAll();
|
|
35
|
-
expect(errors).toEqual([]);
|
|
36
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { toPairs } from 'rambdax';
|
|
2
|
-
import { describe, vi, it } from 'vitest';
|
|
3
|
-
import { createTestServices } from '../test';
|
|
4
|
-
import * as testfiles from './parser-smoke';
|
|
5
|
-
vi.mock('../logger', () => ({
|
|
6
|
-
logger: {
|
|
7
|
-
log: vi.fn(),
|
|
8
|
-
error: vi.fn(),
|
|
9
|
-
warn: vi.fn(),
|
|
10
|
-
info: vi.fn(),
|
|
11
|
-
debug: vi.fn()
|
|
12
|
-
}
|
|
13
|
-
}));
|
|
14
|
-
describe('parser smoke', () => {
|
|
15
|
-
toPairs(testfiles).forEach(([name, document]) => {
|
|
16
|
-
it.concurrent(name, async ({ expect }) => {
|
|
17
|
-
const { validate } = createTestServices();
|
|
18
|
-
const { diagnostics } = await validate(document);
|
|
19
|
-
const errors = diagnostics.map(d => d.message);
|
|
20
|
-
if (name.startsWith('invalid_')) {
|
|
21
|
-
expect(errors).not.toEqual([]);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
expect(errors).toEqual([]);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { createTestServices } from '../test';
|
|
3
|
-
import { keys } from 'rambdax';
|
|
4
|
-
describe('LikeC4ModelBuilder', () => {
|
|
5
|
-
it('builds model', async () => {
|
|
6
|
-
const { validate, buildModel } = createTestServices();
|
|
7
|
-
const { diagnostics } = await validate(`
|
|
8
|
-
specification {
|
|
9
|
-
element component
|
|
10
|
-
element user {
|
|
11
|
-
style {
|
|
12
|
-
shape: person
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
tag deprecated
|
|
16
|
-
}
|
|
17
|
-
model {
|
|
18
|
-
user client {
|
|
19
|
-
-> frontend
|
|
20
|
-
}
|
|
21
|
-
component system {
|
|
22
|
-
backend = component 'Backend' {
|
|
23
|
-
technology 'NodeJS'
|
|
24
|
-
|
|
25
|
-
style {
|
|
26
|
-
color secondary
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
component frontend {
|
|
30
|
-
#deprecated
|
|
31
|
-
description 'Frontend description'
|
|
32
|
-
|
|
33
|
-
style {
|
|
34
|
-
color: muted
|
|
35
|
-
shape: browser
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
-> backend 'requests'
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
`);
|
|
43
|
-
expect(diagnostics).toHaveLength(0);
|
|
44
|
-
const model = await buildModel();
|
|
45
|
-
expect(model).toBeDefined();
|
|
46
|
-
expect(model.elements).toMatchObject({
|
|
47
|
-
client: {
|
|
48
|
-
kind: 'user',
|
|
49
|
-
shape: 'person'
|
|
50
|
-
},
|
|
51
|
-
'system.backend': {
|
|
52
|
-
color: 'secondary',
|
|
53
|
-
title: 'Backend',
|
|
54
|
-
technology: 'NodeJS'
|
|
55
|
-
},
|
|
56
|
-
'system.frontend': {
|
|
57
|
-
color: 'muted',
|
|
58
|
-
shape: 'browser',
|
|
59
|
-
description: 'Frontend description'
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
expect(model.elements['client']).not.toHaveProperty('color');
|
|
63
|
-
expect(model.elements['system']).not.toHaveProperty('color');
|
|
64
|
-
expect(model.elements['system']).not.toHaveProperty('shape');
|
|
65
|
-
expect(model.elements['system.backend']).toHaveProperty('color', 'secondary');
|
|
66
|
-
expect(model.elements['system.backend']).not.toHaveProperty('description');
|
|
67
|
-
expect(model).toMatchSnapshot();
|
|
68
|
-
});
|
|
69
|
-
it('builds model with extend', async () => {
|
|
70
|
-
const { parse, validateAll, buildModel } = createTestServices();
|
|
71
|
-
await parse(`
|
|
72
|
-
specification {
|
|
73
|
-
element component
|
|
74
|
-
element user
|
|
75
|
-
tag deprecated
|
|
76
|
-
}
|
|
77
|
-
model {
|
|
78
|
-
user client
|
|
79
|
-
component system {
|
|
80
|
-
backend = component
|
|
81
|
-
component frontend
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
`);
|
|
85
|
-
await parse(`
|
|
86
|
-
model {
|
|
87
|
-
extend system.backend {
|
|
88
|
-
component api
|
|
89
|
-
}
|
|
90
|
-
system.frontend -> api 'requests'
|
|
91
|
-
client -> system.frontend {
|
|
92
|
-
title 'opens'
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
views {
|
|
96
|
-
view index {
|
|
97
|
-
title 'Index'
|
|
98
|
-
include *
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
view v1 of api {
|
|
102
|
-
include *
|
|
103
|
-
autoLayout LeftRight
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
view of system.frontend {
|
|
107
|
-
include *
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
`);
|
|
111
|
-
const { errors } = await validateAll();
|
|
112
|
-
expect(errors).toEqual([]);
|
|
113
|
-
const model = await buildModel();
|
|
114
|
-
expect(model).toBeDefined();
|
|
115
|
-
expect(model.elements).toMatchObject({
|
|
116
|
-
client: {
|
|
117
|
-
kind: 'user'
|
|
118
|
-
},
|
|
119
|
-
'system.backend.api': {
|
|
120
|
-
kind: 'component'
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
expect(keys(model.relations)).toHaveLength(2);
|
|
124
|
-
expect(keys(model.views)).toHaveLength(3);
|
|
125
|
-
expect(model.views).toMatchObject({
|
|
126
|
-
index: {
|
|
127
|
-
id: 'index',
|
|
128
|
-
title: 'Index',
|
|
129
|
-
autoLayout: 'TB'
|
|
130
|
-
},
|
|
131
|
-
v1: {
|
|
132
|
-
id: 'v1',
|
|
133
|
-
viewOf: 'system.backend.api',
|
|
134
|
-
title: 'api',
|
|
135
|
-
autoLayout: 'LR'
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
expect(model.views['index']).not.toHaveProperty('viewOf');
|
|
139
|
-
expect(model).toMatchSnapshot();
|
|
140
|
-
});
|
|
141
|
-
});
|
package/dist/protocol.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Fqn, LikeC4Model, RelationID, ViewID } from '@likec4/core/types';
|
|
2
|
-
import type { Location } from 'vscode-languageserver-protocol';
|
|
3
|
-
import { NotificationType, RequestType0, RequestType } from 'vscode-languageserver-protocol';
|
|
4
|
-
export declare const onDidChangeLikeC4Model: NotificationType<unknown>;
|
|
5
|
-
export declare const fetchLikeC4Model: RequestType0<{
|
|
6
|
-
model: LikeC4Model | null;
|
|
7
|
-
}, void>;
|
|
8
|
-
export declare const buildDocuments: RequestType<string[], void, void>;
|
|
9
|
-
export declare const locateElement: RequestType<{
|
|
10
|
-
element: Fqn;
|
|
11
|
-
property: string | null;
|
|
12
|
-
}, {
|
|
13
|
-
location: Location | null;
|
|
14
|
-
}, void>;
|
|
15
|
-
export declare const locateRelation: RequestType<{
|
|
16
|
-
id: RelationID;
|
|
17
|
-
}, Location | null, void>;
|
|
18
|
-
export declare const locateView: RequestType<{
|
|
19
|
-
id: ViewID;
|
|
20
|
-
}, Location | null, void>;
|
|
21
|
-
export declare const Rpc: {
|
|
22
|
-
readonly onDidChangeModel: NotificationType<unknown>;
|
|
23
|
-
readonly fetchModel: RequestType0<{
|
|
24
|
-
model: LikeC4Model | null;
|
|
25
|
-
}, void>;
|
|
26
|
-
readonly buildDocuments: RequestType<string[], void, void>;
|
|
27
|
-
readonly locateElement: RequestType<{
|
|
28
|
-
element: Fqn;
|
|
29
|
-
property: string | null;
|
|
30
|
-
}, {
|
|
31
|
-
location: Location | null;
|
|
32
|
-
}, void>;
|
|
33
|
-
readonly locateRelation: RequestType<{
|
|
34
|
-
id: RelationID;
|
|
35
|
-
}, Location | null, void>;
|
|
36
|
-
readonly locateView: RequestType<{
|
|
37
|
-
id: ViewID;
|
|
38
|
-
}, Location | null, void>;
|
|
39
|
-
};
|
package/dist/protocol.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { NotificationType, RequestType0, RequestType } from 'vscode-languageserver-protocol';
|
|
2
|
-
//#region From server
|
|
3
|
-
export const onDidChangeLikeC4Model = new NotificationType('likec4/onDidChangeModel');
|
|
4
|
-
//#endregion
|
|
5
|
-
//#region To server
|
|
6
|
-
export const fetchLikeC4Model = new RequestType0('likec4/fetchModel');
|
|
7
|
-
export const buildDocuments = new RequestType('likec4/buildDocuments');
|
|
8
|
-
export const locateElement = new RequestType('likec4/locateElement');
|
|
9
|
-
export const locateRelation = new RequestType('likec4/locateRelation');
|
|
10
|
-
export const locateView = new RequestType('likec4/locateView');
|
|
11
|
-
//#endregion
|
|
12
|
-
export const Rpc = {
|
|
13
|
-
onDidChangeModel: onDidChangeLikeC4Model,
|
|
14
|
-
fetchModel: fetchLikeC4Model,
|
|
15
|
-
buildDocuments,
|
|
16
|
-
locateElement,
|
|
17
|
-
locateRelation,
|
|
18
|
-
locateView
|
|
19
|
-
};
|
package/dist/test/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './testServices';
|
package/dist/test/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './testServices';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { LikeC4LangiumDocument } from '../ast';
|
|
2
|
-
export declare function createTestServices(): {
|
|
3
|
-
services: import("../module").LikeC4Services;
|
|
4
|
-
parse: (input: string, uri?: string) => Promise<LikeC4LangiumDocument>;
|
|
5
|
-
validate: (input: string | LikeC4LangiumDocument) => Promise<{
|
|
6
|
-
document: LikeC4LangiumDocument;
|
|
7
|
-
diagnostics: import("vscode-languageserver-types").Diagnostic[];
|
|
8
|
-
errors: string[];
|
|
9
|
-
}>;
|
|
10
|
-
validateAll: () => Promise<{
|
|
11
|
-
diagnostics: import("vscode-languageserver-types").Diagnostic[];
|
|
12
|
-
errors: string[];
|
|
13
|
-
}>;
|
|
14
|
-
buildModel: () => Promise<import("@likec4/core/types").LikeC4Model>;
|
|
15
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { createLanguageServices } from '../module';
|
|
2
|
-
import { EmptyFileSystem } from 'langium';
|
|
3
|
-
import { URI } from 'vscode-uri';
|
|
4
|
-
export function createTestServices() {
|
|
5
|
-
const services = createLanguageServices(EmptyFileSystem).likec4;
|
|
6
|
-
const metaData = services.LanguageMetaData;
|
|
7
|
-
const langiumDocuments = services.shared.workspace.LangiumDocuments;
|
|
8
|
-
const documentBuilder = services.shared.workspace.DocumentBuilder;
|
|
9
|
-
const modelBuilder = services.likec4.ModelBuilder;
|
|
10
|
-
const initPromise = services.shared.workspace.WorkspaceManager.initializeWorkspace([]);
|
|
11
|
-
let documentIndex = 1;
|
|
12
|
-
const parse = async (input, uri) => {
|
|
13
|
-
await initPromise;
|
|
14
|
-
uri = uri ?? `${documentIndex++}${metaData.fileExtensions[0]}`;
|
|
15
|
-
const document = services.shared.workspace.LangiumDocumentFactory.fromString(input, URI.file(uri));
|
|
16
|
-
langiumDocuments.addDocument(document);
|
|
17
|
-
await documentBuilder.build([document], { validationChecks: 'none' });
|
|
18
|
-
return document;
|
|
19
|
-
};
|
|
20
|
-
const validate = async (input) => {
|
|
21
|
-
await initPromise;
|
|
22
|
-
const document = typeof input === 'string' ? await parse(input) : input;
|
|
23
|
-
await documentBuilder.build([document], { validationChecks: 'all' });
|
|
24
|
-
const diagnostics = document.diagnostics ?? [];
|
|
25
|
-
const errors = diagnostics.map(d => d.message);
|
|
26
|
-
return {
|
|
27
|
-
document,
|
|
28
|
-
diagnostics,
|
|
29
|
-
errors
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
const validateAll = async () => {
|
|
33
|
-
await initPromise;
|
|
34
|
-
const docs = langiumDocuments.all.toArray();
|
|
35
|
-
await documentBuilder.build(docs, { validationChecks: 'all' });
|
|
36
|
-
const diagnostics = docs.flatMap(doc => doc.diagnostics ?? []);
|
|
37
|
-
const errors = diagnostics.map(d => d.message);
|
|
38
|
-
return {
|
|
39
|
-
diagnostics,
|
|
40
|
-
errors
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
const buildModel = async () => {
|
|
44
|
-
await validateAll();
|
|
45
|
-
const model = modelBuilder.buildModel();
|
|
46
|
-
if (!model)
|
|
47
|
-
throw new Error('No model found');
|
|
48
|
-
return model;
|
|
49
|
-
};
|
|
50
|
-
return {
|
|
51
|
-
services,
|
|
52
|
-
parse,
|
|
53
|
-
validate,
|
|
54
|
-
validateAll,
|
|
55
|
-
buildModel
|
|
56
|
-
};
|
|
57
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { createTestServices } from '../test';
|
|
3
|
-
describe('elementChecks', () => {
|
|
4
|
-
it('should report duplicate element names', async () => {
|
|
5
|
-
const { validate } = createTestServices();
|
|
6
|
-
const { diagnostics } = await validate(`
|
|
7
|
-
specification {
|
|
8
|
-
element component
|
|
9
|
-
}
|
|
10
|
-
model {
|
|
11
|
-
component c1
|
|
12
|
-
component c2
|
|
13
|
-
component c1
|
|
14
|
-
}
|
|
15
|
-
`);
|
|
16
|
-
expect(diagnostics).toHaveLength(2);
|
|
17
|
-
for (const diagnostic of diagnostics) {
|
|
18
|
-
expect(diagnostic.severity, 'diagnostic severity').toBe(1);
|
|
19
|
-
expect(diagnostic.message, 'diagnostic message').toBe('Duplicate element name c1');
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
it('should report duplicate element names in extendElement', async () => {
|
|
23
|
-
const { parse, validateAll } = createTestServices();
|
|
24
|
-
await parse(`
|
|
25
|
-
specification {
|
|
26
|
-
element component
|
|
27
|
-
}
|
|
28
|
-
model {
|
|
29
|
-
component c1 {
|
|
30
|
-
component c2 {
|
|
31
|
-
component c3
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
`);
|
|
36
|
-
await parse(`
|
|
37
|
-
model {
|
|
38
|
-
extend c1.c2 {
|
|
39
|
-
component c3
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
`);
|
|
43
|
-
const { diagnostics } = await validateAll();
|
|
44
|
-
expect(diagnostics).toHaveLength(2);
|
|
45
|
-
for (const diagnostic of diagnostics) {
|
|
46
|
-
expect(diagnostic.severity, 'diagnostic severity').toBe(1);
|
|
47
|
-
expect(diagnostic.message, 'diagnostic message').toBe('Duplicate element name c3 (c1.c2.c3)');
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
it('should not report duplicate element names in nested', async () => {
|
|
51
|
-
const { validate } = createTestServices();
|
|
52
|
-
const { errors } = await validate(`
|
|
53
|
-
specification {
|
|
54
|
-
element component
|
|
55
|
-
}
|
|
56
|
-
model {
|
|
57
|
-
component c1
|
|
58
|
-
component c2 {
|
|
59
|
-
component c1
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
`);
|
|
63
|
-
expect(errors).toEqual([]);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { createTestServices } from '../test';
|
|
3
|
-
describe('relationChecks', () => {
|
|
4
|
-
it('should not report invalid relations', async () => {
|
|
5
|
-
const { validate } = createTestServices();
|
|
6
|
-
const { errors } = await validate(`
|
|
7
|
-
specification {
|
|
8
|
-
element component
|
|
9
|
-
}
|
|
10
|
-
model {
|
|
11
|
-
component c1 {
|
|
12
|
-
component c2 {
|
|
13
|
-
-> c3
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
component c3 {
|
|
17
|
-
this -> c1
|
|
18
|
-
}
|
|
19
|
-
c3 -> c2
|
|
20
|
-
}
|
|
21
|
-
`);
|
|
22
|
-
expect(errors).toEqual([]);
|
|
23
|
-
});
|
|
24
|
-
it('should report invalid relation: parent -> child', async () => {
|
|
25
|
-
const { validate } = createTestServices();
|
|
26
|
-
const { errors } = await validate(`
|
|
27
|
-
specification {
|
|
28
|
-
element component
|
|
29
|
-
}
|
|
30
|
-
model {
|
|
31
|
-
component c1 {
|
|
32
|
-
component c2 {
|
|
33
|
-
component c3
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
c1 -> c3
|
|
37
|
-
}
|
|
38
|
-
`);
|
|
39
|
-
expect(errors).toEqual(['Invalid relation (same hierarchy)']);
|
|
40
|
-
});
|
|
41
|
-
it('should report invalid relation: -> nested child', async () => {
|
|
42
|
-
const { validate } = createTestServices();
|
|
43
|
-
const { errors } = await validate(`
|
|
44
|
-
specification {
|
|
45
|
-
element component
|
|
46
|
-
}
|
|
47
|
-
model {
|
|
48
|
-
component c1 {
|
|
49
|
-
component c2 {
|
|
50
|
-
component c3
|
|
51
|
-
}
|
|
52
|
-
-> c3
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
`);
|
|
56
|
-
expect(errors).toEqual(['Invalid relation (same hierarchy)']);
|
|
57
|
-
});
|
|
58
|
-
it('should report invalid relation: child -> parent', async () => {
|
|
59
|
-
const { validate } = createTestServices();
|
|
60
|
-
const { errors } = await validate(`
|
|
61
|
-
specification {
|
|
62
|
-
element component
|
|
63
|
-
}
|
|
64
|
-
model {
|
|
65
|
-
component c1 {
|
|
66
|
-
component c2 {
|
|
67
|
-
component c3
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
c3 -> c2
|
|
71
|
-
}
|
|
72
|
-
`);
|
|
73
|
-
expect(errors).toEqual(['Invalid relation (same hierarchy)']);
|
|
74
|
-
});
|
|
75
|
-
it('should report invalid relation: nested child -> parent', async () => {
|
|
76
|
-
const { validate } = createTestServices();
|
|
77
|
-
const { errors } = await validate(`
|
|
78
|
-
specification {
|
|
79
|
-
element component
|
|
80
|
-
}
|
|
81
|
-
model {
|
|
82
|
-
component c1 {
|
|
83
|
-
component c2 {
|
|
84
|
-
component c3 {
|
|
85
|
-
-> c1
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
`);
|
|
91
|
-
expect(errors).toEqual(['Invalid relation (same hierarchy)']);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { expect, test } from 'vitest';
|
|
2
|
-
import { createTestServices } from '../test';
|
|
3
|
-
const { validate } = createTestServices();
|
|
4
|
-
test('elementKindChecks', async () => {
|
|
5
|
-
const { diagnostics } = await validate(`
|
|
6
|
-
specification {
|
|
7
|
-
element component
|
|
8
|
-
element user
|
|
9
|
-
element component
|
|
10
|
-
}
|
|
11
|
-
`);
|
|
12
|
-
expect(diagnostics).toHaveLength(2);
|
|
13
|
-
for (const diagnostic of diagnostics) {
|
|
14
|
-
expect(diagnostic.severity, 'diagnostic severity').toBe(1);
|
|
15
|
-
expect(diagnostic.message, 'diagnostic message').toBe("Duplicate element kind 'component'");
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
test('tagChecks', async () => {
|
|
19
|
-
const { diagnostics } = await validate(`
|
|
20
|
-
specification {
|
|
21
|
-
tag tag1
|
|
22
|
-
tag tag2
|
|
23
|
-
tag tag1
|
|
24
|
-
}
|
|
25
|
-
`);
|
|
26
|
-
expect(diagnostics).toHaveLength(2);
|
|
27
|
-
for (const diagnostic of diagnostics) {
|
|
28
|
-
expect(diagnostic.severity, 'diagnostic severity').toBe(1);
|
|
29
|
-
expect(diagnostic.message, 'diagnostic message').toBe("Duplicate tag 'tag1'");
|
|
30
|
-
}
|
|
31
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { createTestServices } from '../test';
|
|
3
|
-
describe('viewChecks', () => {
|
|
4
|
-
it('should report duplicate view names', async () => {
|
|
5
|
-
const { validate } = createTestServices();
|
|
6
|
-
const { diagnostics } = await validate(`
|
|
7
|
-
views {
|
|
8
|
-
view v1 {
|
|
9
|
-
}
|
|
10
|
-
view v1 {
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
`);
|
|
14
|
-
expect(diagnostics).toHaveLength(2);
|
|
15
|
-
for (const diagnostic of diagnostics) {
|
|
16
|
-
expect(diagnostic.severity, 'diagnostic severity').toBe(1);
|
|
17
|
-
expect(diagnostic.message, 'diagnostic message').toBe("Duplicate view 'v1'");
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
});
|