From ebe5f16545846a5a7b678fc7d9092f80bc8a37ae Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Tue, 17 Jul 2018 10:46:44 +0200 Subject: [PATCH] refactor: Use modern foreach loop (#2231) * refactor: Code inspection: Use modern foreach loop * Fix imports --- .../visitor/java/JavaReflectionTreeBuilder.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/spoon/support/visitor/java/JavaReflectionTreeBuilder.java b/src/main/java/spoon/support/visitor/java/JavaReflectionTreeBuilder.java index c9c8fad50c1..12e1b1f5f8d 100644 --- a/src/main/java/spoon/support/visitor/java/JavaReflectionTreeBuilder.java +++ b/src/main/java/spoon/support/visitor/java/JavaReflectionTreeBuilder.java @@ -63,7 +63,6 @@ import java.util.ArrayDeque; import java.util.Arrays; import java.util.Deque; -import java.util.Iterator; /** * Builds Spoon model from class file using the reflection api. The Spoon model @@ -332,9 +331,8 @@ public void visitParameter(RtParameter parameter) { @Override public void visitTypeParameter(TypeVariable parameter) { GenericDeclaration genericDeclaration = parameter.getGenericDeclaration(); - Iterator contextIterator = contexts.iterator(); - while (contextIterator.hasNext()) { - CtTypeParameter typeParameter = contextIterator.next().getTypeParameter(genericDeclaration, parameter.getName()); + for (RuntimeBuilderContext context : contexts) { + CtTypeParameter typeParameter = context.getTypeParameter(genericDeclaration, parameter.getName()); if (typeParameter != null) { contexts.peek().addFormalType(typeParameter.clone()); return; @@ -380,9 +378,8 @@ public void visitTypeParameterReference(CtRole ro } GenericDeclaration genericDeclaration = parameter.getGenericDeclaration(); - Iterator contextIterator = contexts.iterator(); - while (contextIterator.hasNext()) { - CtTypeParameter typeParameter = contextIterator.next().getTypeParameter(genericDeclaration, parameter.getName()); + for (RuntimeBuilderContext context : contexts) { + CtTypeParameter typeParameter = context.getTypeParameter(genericDeclaration, parameter.getName()); if (typeParameter != null) { contexts.peek().addTypeReference(role, typeParameter.getReference()); return;