Fixed bug where for-each statements caused a NPE when checking special case for for statements with empty iterator clauses in ParenPadCheck.
This commit is contained in:
parent
9bcd88cf20
commit
fee0ec8258
|
|
@ -103,8 +103,10 @@ public class ParenPadCheck
|
|||
{
|
||||
boolean followsEmptyForIterator = false;
|
||||
final DetailAST parent = aAST.getParent();
|
||||
//Only traditional for statements are examined, not for-each statements
|
||||
if ((parent != null)
|
||||
&& (parent.getType() == TokenTypes.LITERAL_FOR))
|
||||
&& (parent.getType() == TokenTypes.LITERAL_FOR)
|
||||
&& (parent.findFirstToken(TokenTypes.FOR_EACH_CLAUSE) == null))
|
||||
{
|
||||
final DetailAST forIterator =
|
||||
parent.findFirstToken(TokenTypes.FOR_ITERATOR);
|
||||
|
|
@ -122,8 +124,10 @@ public class ParenPadCheck
|
|||
{
|
||||
boolean preceedsEmptyForInintializer = false;
|
||||
final DetailAST parent = aAST.getParent();
|
||||
//Only traditional for statements are examined, not for-each statements
|
||||
if ((parent != null)
|
||||
&& (parent.getType() == TokenTypes.LITERAL_FOR))
|
||||
&& (parent.getType() == TokenTypes.LITERAL_FOR)
|
||||
&& (parent.findFirstToken(TokenTypes.FOR_EACH_CLAUSE) == null))
|
||||
{
|
||||
final DetailAST forIterator =
|
||||
parent.findFirstToken(TokenTypes.FOR_INIT);
|
||||
|
|
|
|||
|
|
@ -229,5 +229,8 @@ class SpecialCasesInForLoop
|
|||
for ( ; i < 5; i++ ) {
|
||||
// ^ whitespace
|
||||
}
|
||||
for (int anInt : getSomeInts()) {
|
||||
//Should be ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ public class ParenPadCheckTest
|
|||
"178:14: '(' is not followed by whitespace.",
|
||||
"178:36: ')' is not preceded with whitespace.",
|
||||
"222:14: '(' is not followed by whitespace.",
|
||||
"232:14: '(' is not followed by whitespace.",
|
||||
"232:39: ')' is not preceded with whitespace.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputWhitespace.java"), expected);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue