diff --git a/pom.xml b/pom.xml
index f2f90c966..9eb1da0fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -914,7 +914,7 @@
.*.checks.whitespace.ParenPadCheck8695
.*.checks.whitespace.SeparatorWrapCheck10093
.*.checks.whitespace.TypecastParenPadCheck8788
- .*.checks.whitespace.WhitespaceAfterCheck9090
+ .*.checks.whitespace.WhitespaceAfterCheck8690
.*.checks.whitespace.WhitespaceAroundCheck9698
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheck.java
index d91a73d92..586a771f6 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheck.java
@@ -102,22 +102,32 @@ public class WhitespaceAfterCheck
&& (charAfter == ';' || charAfter == ')')) {
return;
}
- if (!Character.isWhitespace(charAfter)) {
- //empty FOR_ITERATOR?
- if (targetAST.getType() == TokenTypes.SEMI) {
- final DetailAST sibling =
- targetAST.getNextSibling();
- if (sibling != null
- && sibling.getType() == TokenTypes.FOR_ITERATOR
- && sibling.getChildCount() == 0) {
- return;
- }
- }
+ if (!Character.isWhitespace(charAfter) && !isEmptyForIterator(targetAST)) {
+
log(targetAST.getLineNo(),
- targetAST.getColumnNo() + targetAST.getText().length(),
- WS_NOT_FOLLOWED,
- message);
+ targetAST.getColumnNo() + targetAST.getText().length(),
+ WS_NOT_FOLLOWED,
+ message);
}
}
}
+
+ /**
+ * check for empty FOR_ITERATOR
+ * @param targetAST Ast token
+ * @return true if iterator is empty
+ */
+ private boolean isEmptyForIterator(DetailAST targetAST) {
+
+ if (targetAST.getType() == TokenTypes.SEMI) {
+ final DetailAST sibling =
+ targetAST.getNextSibling();
+ if (sibling != null
+ && sibling.getType() == TokenTypes.FOR_ITERATOR
+ && sibling.getChildCount() == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
}