Skip to content

Commit

Permalink
Trivial refactoring: use enhanced for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellansun committed Jan 18, 2025
1 parent 5f23e6d commit 56b3fc0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -3591,19 +3591,18 @@ public List<Expression> visitArrayInitializer(final ArrayInitializerContext ctx)
return Collections.emptyList();
}

ClassNode elementType = ctx.getNodeMetaData(ELEMENT_TYPE);
final ClassNode elementType = ctx.getNodeMetaData(ELEMENT_TYPE);
try {
visitingArrayInitializerCount += 1;
var initExpressions = new ArrayList<Expression>();
for (int i = 0; i < ctx.getChildCount(); i += 1) {
var c = ctx.getChild(i);
for (var c : ctx.children) {
if (c instanceof ArrayInitializerContext) {
var arrayInitializer = (ArrayInitializerContext) c;
ClassNode subType = elementType.getComponentType();
//if (subType == null) produce closure or throw exception
arrayInitializer.putNodeMetaData(ELEMENT_TYPE, subType);
var arrayExpression = configureAST(new ArrayExpression(subType,
this.visitArrayInitializer(arrayInitializer)), arrayInitializer);
this.visitArrayInitializer(arrayInitializer)), arrayInitializer);
arrayExpression.setType(elementType);
initExpressions.add(arrayExpression);
} else if (c instanceof VariableInitializerContext) {
Expand Down

0 comments on commit 56b3fc0

Please sign in to comment.