Skip to content

Commit ed8eb4f

Browse files
committed
fix qodana findings
1 parent 95e0687 commit ed8eb4f

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

src/language/references/ContextMapperDslScopeComputation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export class ContextMapperDslScopeComputation extends DefaultScopeComputation {
88
Without imports, this behavior is wrong and therefore no nodes must be exported here.
99
*/
1010
override computeExportsForNode (
11-
parentNode: AstNode,
12-
document: LangiumDocument<AstNode>,
13-
children?: (root: AstNode) => Iterable<AstNode>,
14-
cancelToken?: CancellationToken
11+
_parentNode: AstNode,
12+
_document: LangiumDocument,
13+
_children?: (root: AstNode) => Iterable<AstNode>,
14+
_cancelToken?: CancellationToken
1515
): Promise<AstNodeDescription[]> {
1616
return Promise.resolve([])
1717
}

test/validation/ValidationHelper.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ describe('ValidationHelper tests', () => {
6464
expect(acceptor).toHaveBeenCalledTimes(1)
6565
})
6666

67+
test('enforceZeroOrOneCardinality with multiple keywords', () => {
68+
const node = {
69+
key: ['test', 'test2']
70+
} as TestNode
71+
72+
enforceZeroOrOneCardinality(node, 'key', acceptor, ['key', 'keyx'])
73+
74+
expect(acceptor).toHaveBeenCalledTimes(2)
75+
})
76+
6777
test('enforceZeroOrOneCardinalityOfListAttribute with no match', () => {
6878
const node: TestNode = {
6979
$cstNode: {
@@ -115,4 +125,32 @@ describe('ValidationHelper tests', () => {
115125

116126
expect(acceptor).toHaveBeenCalledTimes(1)
117127
})
128+
129+
test('enforceZeroOrOneCardinalityOfListAttribute with multiple keywords', () => {
130+
const node: TestNode = {
131+
$cstNode: {
132+
text: `
133+
Test Structurekey {
134+
key "test", "key"
135+
keyx "test2", "key2"
136+
}
137+
`
138+
},
139+
key: ['test', 'key', 'test2', 'key2']
140+
} as TestNode
141+
142+
enforceZeroOrOneCardinalityOfListAttribute(node, 'key', acceptor, ['key', 'keyx'])
143+
144+
expect(acceptor).toHaveBeenCalledTimes(2)
145+
})
146+
147+
test('enforceZeroOrOneCardinalityOfListAttribute with non-array', () => {
148+
const node = {
149+
key: 'abc'
150+
} as NonArrayNode
151+
152+
enforceZeroOrOneCardinalityOfListAttribute(node, 'key', acceptor)
153+
154+
expect(acceptor).toHaveBeenCalledTimes(1)
155+
})
118156
})

0 commit comments

Comments
 (0)