Skip to content

Commit

Permalink
fix: if multiple nodes don't have a name (should not happen, just a s…
Browse files Browse the repository at this point in the history
…afeguard), don't report errors
  • Loading branch information
lars-reimann committed Sep 21, 2023
1 parent 33ed9b1 commit ce59c33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/language/ast/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ import { stream } from 'langium';

export const annotationCallsOrEmpty = function (node: SdsAnnotatedObject | undefined): SdsAnnotationCall[] {
if (!node) {
/* c8 ignore next 2 */
return [];
}

if (isSdsDeclaration(node)) {
return node?.annotationCallList?.annotationCalls ?? node?.annotationCalls ?? [];
} else {
/* c8 ignore next 2 */
return node?.annotationCalls ?? [];
}
};
Expand Down
6 changes: 5 additions & 1 deletion src/language/validation/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,11 @@ const namesMustBeUnique = (
const knownNames = new Set<string>();

for (const node of nodes) {
const name = node.name ?? '';
const name = node.name;
if (!name) {
continue;
}

if (knownNames.has(name)) {
accept('error', createMessage(name), {
node,
Expand Down

0 comments on commit ce59c33

Please sign in to comment.