Skip to content

Commit

Permalink
Issue checkstyle#3839: Added special checks for LITERAL_CASE to detec…
Browse files Browse the repository at this point in the history
…t related empty blocks
  • Loading branch information
voidfist committed Mar 4, 2017
1 parent cac09c4 commit 472efcd
Showing 1 changed file with 15 additions and 2 deletions.
Expand Up @@ -138,8 +138,8 @@ public int[] getRequiredTokens() {

@Override
public void visitToken(DetailAST ast) {
final DetailAST slistToken = ast.findFirstToken(TokenTypes.SLIST);
final DetailAST leftCurly;
DetailAST slistToken = ast.findFirstToken(TokenTypes.SLIST);
DetailAST leftCurly;

if (slistToken == null) {
leftCurly = ast.findFirstToken(TokenTypes.LCURLY);
Expand All @@ -148,6 +148,19 @@ public void visitToken(DetailAST ast) {
leftCurly = slistToken;
}

// special check for TokenTypes.LITERAL_CASE
if(leftCurly == null && ast.getType() == TokenTypes.LITERAL_CASE)
{
slistToken = ast.getParent().findFirstToken(TokenTypes.SLIST);

if(slistToken == null){
leftCurly = ast.getParent().findFirstToken(TokenTypes.LCURLY);
}
else{
leftCurly = slistToken;
}
}

if (leftCurly != null) {
if (option == BlockOption.STMT) {
final boolean emptyBlock;
Expand Down

0 comments on commit 472efcd

Please sign in to comment.