Skip to content

Commit

Permalink
Issue checkstyle#12345: fix NoWhitespaceAfterCheck false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
strkkk committed Nov 5, 2022
1 parent b1c4475 commit e708e25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -570,8 +570,11 @@ private static DetailAST getIdentLastToken(DetailAST ast) {
* @return dot preceding the left bracket
*/
private static DetailAST getPrecedingDot(DetailAST leftBracket) {
final DetailAST referencedClassDot =
leftBracket.getParent().findFirstToken(TokenTypes.DOT);
final DetailAST parent = leftBracket.getParent();
DetailAST referencedClassDot = null;
if (parent.getType() != TokenTypes.ASSIGN) {
referencedClassDot = parent.findFirstToken(TokenTypes.DOT);
}
final DetailAST referencedMemberDot = leftBracket.findFirstToken(TokenTypes.DOT);
return Optional.ofNullable(referencedMemberDot).orElse(referencedClassDot);

Expand Down
Expand Up @@ -307,4 +307,12 @@ Object foo() {

int someStuff8
[]; // violation

Object o;

void some() {
Object oo = new Object[4];
this.o = ((Object[]) oo)[1];
this.o = ((java.lang.Object[]) oo)[1];
}
}

0 comments on commit e708e25

Please sign in to comment.