Skip to content

Commit dc60c79

Browse files
committed
fix validator registration, fix tests
1 parent 7e28534 commit dc60c79

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/language/ContextMapperDslModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function createContextMapperDslServices (context: DefaultSharedModuleCont
7272
ContextMapperDslModule
7373
)
7474
shared.ServiceRegistry.register(ContextMapperDsl)
75-
registerValidationChecks(ContextMapperDsl.validation.ValidationRegistry)
75+
registerValidationChecks(ContextMapperDsl.validation.ValidationRegistry, ContextMapperDsl.validation.ContextMapperDslValidator)
7676
if (!context.connection) {
7777
// We don't run inside a language server
7878
// Therefore, initialize the configuration provider instantly

src/language/ContextMapperDslValidator.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { AstNode, ValidationRegistry } from 'langium'
1+
import { AstNode, type ValidationChecks, ValidationRegistry } from 'langium'
22
import { ContextMappingModelValidator } from './validation/ContextMappingModelValidator.js'
33
import { ValueValidator } from './validation/ValueValidator.js'
44
import { AbstractContextMapperValidator } from './validation/AbstractContextMapperValidator.js'
5+
import type { ContextMapperDslAstType } from './generated/ast.js'
56

67
const validators: AbstractContextMapperValidator<AstNode>[] = [
78
new ContextMappingModelValidator(),
@@ -11,10 +12,13 @@ const validators: AbstractContextMapperValidator<AstNode>[] = [
1112
/**
1213
* Register custom validation checks.
1314
*/
14-
export function registerValidationChecks (registry: ValidationRegistry) {
15+
export function registerValidationChecks (registry: ValidationRegistry, validator: ContextMapperDslValidator) {
16+
const validatorChecks: ValidationChecks<ContextMapperDslAstType>[] = []
1517
for (const validator of validators) {
16-
registry.register(validator.getChecks, validator)
18+
validatorChecks.push(validator.getChecks())
1719
}
20+
const checks: ValidationChecks<ContextMapperDslAstType> = Object.assign({}, ...validatorChecks)
21+
registry.register(checks, validator)
1822
}
1923

2024
export class ContextMapperDslValidator {

test/semnantictokens/BoundedContextSemanticTokens.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('BoundedContext semantic token test', () => {
6161
const tokens = extractSemanticTokens(result, expectedNumberOfTokens)
6262

6363
assertSemanticToken(tokens[2], 1, 6, 4, semanticTokenProvider.tokenTypes.keyword, 0)
64-
assertSemanticToken(tokens[3], 0, 7, 9, semanticTokenProvider.tokenTypes.property, 0)
64+
assertSemanticToken(tokens[3], 0, 7, 9, semanticTokenProvider.tokenTypes.enumMember, 0)
6565

6666
assertSemanticToken(tokens[4], 1, 6, 24, semanticTokenProvider.tokenTypes.keyword, 0)
6767
assertSemanticToken(tokens[5], 0, 27, 6, semanticTokenProvider.tokenTypes.string, 0)
@@ -77,10 +77,10 @@ describe('BoundedContext semantic token test', () => {
7777
assertSemanticToken(tokens[12], 0, 24, 6, semanticTokenProvider.tokenTypes.string, 0)
7878

7979
assertSemanticToken(tokens[13], 1, 6, 14, semanticTokenProvider.tokenTypes.keyword, 0)
80-
assertSemanticToken(tokens[14], 0, 17, 8, semanticTokenProvider.tokenTypes.property, 0)
80+
assertSemanticToken(tokens[14], 0, 17, 8, semanticTokenProvider.tokenTypes.enumMember, 0)
8181

8282
assertSemanticToken(tokens[15], 1, 6, 9, semanticTokenProvider.tokenTypes.keyword, 0)
83-
assertSemanticToken(tokens[16], 0, 10, 7, semanticTokenProvider.tokenTypes.property, 0)
83+
assertSemanticToken(tokens[16], 0, 10, 7, semanticTokenProvider.tokenTypes.enumMember, 0)
8484
})
8585
})
8686

0 commit comments

Comments
 (0)