@likec4/language-server 0.6.1 → 0.6.2
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/package.json +5 -5
- package/contrib/likec4.monarch.ts +0 -31
- package/contrib/likec4.tmLanguage.json +0 -73
- 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/ast.d.ts +0 -73
- package/dist/ast.js +0 -133
- package/dist/builtin.d.ts +0 -4
- package/dist/builtin.js +0 -8
- package/dist/elementRef.d.ts +0 -6
- package/dist/elementRef.js +0 -39
- package/dist/generated/ast.d.ts +0 -359
- package/dist/generated/ast.js +0 -376
- package/dist/generated/grammar.d.ts +0 -6
- package/dist/generated/grammar.js +0 -2542
- package/dist/generated/module.d.ts +0 -9
- package/dist/generated/module.js +0 -26
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -14
- package/dist/logger.d.ts +0 -8
- package/dist/logger.js +0 -20
- package/dist/lsp/DocumentSymbolProvider.d.ts +0 -21
- package/dist/lsp/DocumentSymbolProvider.js +0 -149
- package/dist/lsp/HoverProvider.d.ts +0 -8
- package/dist/lsp/HoverProvider.js +0 -54
- package/dist/lsp/SemanticTokenProvider.d.ts +0 -6
- package/dist/lsp/SemanticTokenProvider.js +0 -221
- package/dist/lsp/index.d.ts +0 -3
- package/dist/lsp/index.js +0 -3
- package/dist/model/fqn-index.d.ts +0 -17
- package/dist/model/fqn-index.js +0 -138
- package/dist/model/index.d.ts +0 -3
- package/dist/model/index.js +0 -3
- package/dist/model/model-builder.d.ts +0 -26
- package/dist/model/model-builder.js +0 -332
- package/dist/model/model-builder.spec.d.ts +0 -1
- package/dist/model/model-builder.spec.js +0 -141
- package/dist/model/model-locator.d.ts +0 -16
- package/dist/model/model-locator.js +0 -108
- package/dist/module.d.ts +0 -18
- package/dist/module.js +0 -61
- package/dist/protocol.d.ts +0 -39
- package/dist/protocol.js +0 -19
- package/dist/references/index.d.ts +0 -2
- package/dist/references/index.js +0 -2
- package/dist/references/scope-computation.d.ts +0 -10
- package/dist/references/scope-computation.js +0 -76
- package/dist/references/scope-provider.d.ts +0 -15
- package/dist/references/scope-provider.js +0 -110
- package/dist/registerProtocolHandlers.d.ts +0 -2
- package/dist/registerProtocolHandlers.js +0 -64
- package/dist/shared/CodeLensProvider.d.ts +0 -8
- package/dist/shared/CodeLensProvider.js +0 -35
- package/dist/shared/WorkspaceManager.d.ts +0 -13
- package/dist/shared/WorkspaceManager.js +0 -19
- package/dist/shared/index.d.ts +0 -2
- package/dist/shared/index.js +0 -2
- 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/utils.d.ts +0 -2
- package/dist/utils.js +0 -7
- package/dist/validation/element.d.ts +0 -5
- package/dist/validation/element.js +0 -20
- package/dist/validation/element.spec.d.ts +0 -1
- package/dist/validation/element.spec.js +0 -65
- package/dist/validation/index.d.ts +0 -2
- package/dist/validation/index.js +0 -22
- package/dist/validation/relation.d.ts +0 -4
- package/dist/validation/relation.js +0 -53
- package/dist/validation/relation.spec.d.ts +0 -1
- package/dist/validation/relation.spec.js +0 -93
- package/dist/validation/specification.d.ts +0 -5
- package/dist/validation/specification.js +0 -33
- package/dist/validation/specification.spec.d.ts +0 -1
- package/dist/validation/specification.spec.js +0 -31
- package/dist/validation/view.d.ts +0 -4
- package/dist/validation/view.js +0 -20
- package/dist/validation/view.spec.d.ts +0 -1
- package/dist/validation/view.spec.js +0 -20
|
@@ -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
|
-
}
|
package/dist/utils.d.ts
DELETED
package/dist/utils.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export function failExpectedNever(arg) {
|
|
2
|
-
throw new Error(`Unexpected value: ${JSON.stringify(arg)}`);
|
|
3
|
-
}
|
|
4
|
-
export function ignoreNeverInRuntime(arg) {
|
|
5
|
-
console.warn(`Unexpected and ignored value: ${JSON.stringify(arg)}`);
|
|
6
|
-
// throw new Error(`Unexpected value: ${arg}`);
|
|
7
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const elementChecks = (services) => {
|
|
2
|
-
const fqnIndex = services.likec4.FqnIndex;
|
|
3
|
-
return (el, accept) => {
|
|
4
|
-
const fqn = fqnIndex.get(el);
|
|
5
|
-
if (!fqn) {
|
|
6
|
-
accept('error', 'Not indexed', {
|
|
7
|
-
node: el,
|
|
8
|
-
property: 'name'
|
|
9
|
-
});
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const withSameFqn = fqnIndex.byFqn(fqn);
|
|
13
|
-
if (withSameFqn.length > 1) {
|
|
14
|
-
accept('error', `Duplicate element name ${el.name !== fqn ? el.name + ' (' + fqn + ')' : el.name}`, {
|
|
15
|
-
node: el,
|
|
16
|
-
property: 'name'
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
};
|
|
@@ -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
|
-
});
|
package/dist/validation/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { elementChecks } from './element';
|
|
2
|
-
import { relationChecks } from './relation';
|
|
3
|
-
import { elementKindChecks, tagChecks } from './specification';
|
|
4
|
-
import { viewChecks } from './view';
|
|
5
|
-
export function registerValidationChecks(services) {
|
|
6
|
-
const registry = services.validation.ValidationRegistry;
|
|
7
|
-
// const checks: ValidationChecks = {
|
|
8
|
-
// Element: validator.checkElementNameDuplicates,
|
|
9
|
-
// Tag: validator.checkTagDuplicates,
|
|
10
|
-
// ElementKind: elementKindChecks(services),
|
|
11
|
-
// ElementStyleProperty: validator.checkElementStyleProperty,
|
|
12
|
-
// View: validator.checkViewNameDuplicates,
|
|
13
|
-
// ColorStyleProperty: validator.checkColorStyleProperty,
|
|
14
|
-
// }
|
|
15
|
-
registry.register({
|
|
16
|
-
ElementView: viewChecks(services),
|
|
17
|
-
Element: elementChecks(services),
|
|
18
|
-
ElementKind: elementKindChecks(services),
|
|
19
|
-
Relation: relationChecks(services),
|
|
20
|
-
Tag: tagChecks(services)
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { resolveRelationPoints } from '../ast';
|
|
2
|
-
import { isSameHierarchy } from '@likec4/core/utils';
|
|
3
|
-
export const relationChecks = (services) => {
|
|
4
|
-
const fqnIndex = services.likec4.FqnIndex;
|
|
5
|
-
return (el, accept) => {
|
|
6
|
-
try {
|
|
7
|
-
const coupling = resolveRelationPoints(el);
|
|
8
|
-
const target = fqnIndex.get(coupling.target);
|
|
9
|
-
if (!target) {
|
|
10
|
-
return accept('error', 'Invalid target', {
|
|
11
|
-
node: el,
|
|
12
|
-
property: 'target'
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
const source = fqnIndex.get(coupling.source);
|
|
16
|
-
if (!source) {
|
|
17
|
-
return accept('error', 'Invalid source', {
|
|
18
|
-
node: el
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
if (isSameHierarchy(source, target)) {
|
|
22
|
-
return accept('error', 'Invalid relation (same hierarchy)', {
|
|
23
|
-
node: el
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
catch (e) {
|
|
28
|
-
if (e instanceof Error) {
|
|
29
|
-
return accept('error', e.message, {
|
|
30
|
-
node: el
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
accept('error', 'Invalid relation', {
|
|
34
|
-
node: el
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
// const fqn = fqnIndex.get(el)
|
|
38
|
-
// if (!fqn) {
|
|
39
|
-
// accept('error', 'Not indexed', {
|
|
40
|
-
// node: el,
|
|
41
|
-
// property: 'name',
|
|
42
|
-
// })
|
|
43
|
-
// return
|
|
44
|
-
// }
|
|
45
|
-
// const withSameFqn = fqnIndex.byFqn(fqn)
|
|
46
|
-
// if (withSameFqn.length > 1) {
|
|
47
|
-
// accept('error', `Duplicate element name ${el.name !== fqn ? el.name +' (' + fqn + ')' : el.name}`, {
|
|
48
|
-
// node: el,
|
|
49
|
-
// property: 'name',
|
|
50
|
-
// })
|
|
51
|
-
// }
|
|
52
|
-
};
|
|
53
|
-
};
|
|
@@ -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,5 +0,0 @@
|
|
|
1
|
-
import type { ValidationCheck } from 'langium';
|
|
2
|
-
import { ast } from '../ast';
|
|
3
|
-
import type { LikeC4Services } from '../module';
|
|
4
|
-
export declare const elementKindChecks: (services: LikeC4Services) => ValidationCheck<ast.ElementKind>;
|
|
5
|
-
export declare const tagChecks: (services: LikeC4Services) => ValidationCheck<ast.Tag>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ast } from '../ast';
|
|
2
|
-
export const elementKindChecks = (services) => {
|
|
3
|
-
const index = services.shared.workspace.IndexManager;
|
|
4
|
-
return (node, accept) => {
|
|
5
|
-
const sameKinds = index
|
|
6
|
-
.allElements(ast.ElementKind)
|
|
7
|
-
.filter(n => n.name === node.name)
|
|
8
|
-
.limit(2)
|
|
9
|
-
.count();
|
|
10
|
-
if (sameKinds > 1) {
|
|
11
|
-
accept('error', `Duplicate element kind '${node.name}'`, {
|
|
12
|
-
node: node,
|
|
13
|
-
property: 'name'
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export const tagChecks = (services) => {
|
|
19
|
-
const index = services.shared.workspace.IndexManager;
|
|
20
|
-
return (node, accept) => {
|
|
21
|
-
const sameKinds = index
|
|
22
|
-
.allElements(ast.Tag)
|
|
23
|
-
.filter(n => n.name === node.name)
|
|
24
|
-
.limit(2)
|
|
25
|
-
.count();
|
|
26
|
-
if (sameKinds > 1) {
|
|
27
|
-
accept('error', `Duplicate tag '${node.name}'`, {
|
|
28
|
-
node: node,
|
|
29
|
-
property: 'name'
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
};
|
|
@@ -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
|
-
});
|
package/dist/validation/view.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ast } from '../ast';
|
|
2
|
-
export const viewChecks = (services) => {
|
|
3
|
-
const index = services.shared.workspace.IndexManager;
|
|
4
|
-
return (el, accept) => {
|
|
5
|
-
if (!el.name) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const anotherViews = index
|
|
9
|
-
.allElements(ast.View)
|
|
10
|
-
.filter(n => n.name === el.name)
|
|
11
|
-
.limit(2)
|
|
12
|
-
.count();
|
|
13
|
-
if (anotherViews > 1) {
|
|
14
|
-
accept('error', `Duplicate view '${el.name}'`, {
|
|
15
|
-
node: el,
|
|
16
|
-
property: 'name'
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
};
|
|
@@ -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
|
-
});
|