Skip to content

Commit c7c4bec

Browse files
committed
refactor: minor change
1 parent 4a3cf56 commit c7c4bec

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/language/validation/other/modules.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ValidationAcceptor } from 'langium';
22
import { isSdsDeclaration, isSdsPipeline, isSdsSegment, SdsDeclaration, SdsModule } from '../../generated/ast.js';
33
import { isInPipelineFile, isInStubFile } from '../../helpers/fileExtensions.js';
4+
import { getModuleMembers } from '../../helpers/nodeProperties.js';
45

56
export const CODE_MODULE_FORBIDDEN_IN_PIPELINE_FILE = 'module/forbidden-in-pipeline-file';
67
export const CODE_MODULE_FORBIDDEN_IN_STUB_FILE = 'module/forbidden-in-stub-file';
@@ -43,10 +44,10 @@ export const declarationIsAllowedInStubFile = (declaration: SdsDeclaration): boo
4344

4445
export const moduleWithDeclarationsMustStatePackage = (node: SdsModule, accept: ValidationAcceptor): void => {
4546
if (!node.name) {
46-
const declarations = node.members.filter(isSdsDeclaration);
47-
if (declarations.length > 0) {
47+
const members = getModuleMembers(node);
48+
if (members.length > 0) {
4849
accept('error', 'A module with declarations must state its package.', {
49-
node: declarations[0],
50+
node: members[0],
5051
property: 'name',
5152
code: CODE_MODULE_MISSING_PACKAGE,
5253
});

0 commit comments

Comments
 (0)