Skip to content

Commit c925226

Browse files
cirrasfourls
authored andcommitted
Simplify InterfaceTypeNodeImpl::findFirstAttributeList implementation
This collapsed implementation eliminates unreachable lines. Sadly, there's still an unreachable branch.
1 parent 64f762f commit c925226

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

delphi-frontend/src/main/java/au/com/integradev/delphi/antlr/ast/node/InterfaceTypeNodeImpl.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,12 @@ private AttributeListNode findFirstAttributeList() {
8484
}
8585

8686
if (child instanceof VisibilitySectionNode) {
87-
return findFirstAttributeList((VisibilitySectionNode) child);
88-
}
89-
}
90-
return null;
91-
}
92-
93-
private AttributeListNode findFirstAttributeList(VisibilitySectionNode visibilitySection) {
94-
for (DelphiNode child : visibilitySection.getChildren()) {
95-
if (child instanceof RoutineDeclarationNode) {
96-
return ((RoutineDeclarationNode) child).getRoutineHeading().getAttributeList();
97-
}
98-
99-
if (child instanceof PropertyNode) {
100-
return ((PropertyNode) child).getAttributeList();
87+
DelphiNode declaration = child.getChild(0);
88+
if (declaration instanceof RoutineDeclarationNode) {
89+
return ((RoutineDeclarationNode) declaration).getRoutineHeading().getAttributeList();
90+
} else if (declaration instanceof PropertyNode) {
91+
return ((PropertyNode) declaration).getAttributeList();
92+
}
10193
}
10294
}
10395
return null;

0 commit comments

Comments
 (0)