Skip to content

Commit

Permalink
Issue sevntu-checkstyle#464: Simplify check for illegal token
Browse files Browse the repository at this point in the history
  • Loading branch information
kariem committed Oct 21, 2018
1 parent 4a30256 commit be8be03
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,11 @@ public void visitToken(DetailAST enumDef) {
* {@code false otherwise}
*/
private boolean isIllegalTokenAfterComma(DetailAST lastComma, DetailAST nextAst) {
boolean illegalToken = false;

final int nextAstType = nextAst.getType();

if (nextAstType == TokenTypes.SEMI) {
if (nextAst.getLineNo() == lastComma.getLineNo()) {
// semi on the same line as last comma
illegalToken = true;
}
}
else if (nextAstType == TokenTypes.ENUM_CONSTANT_DEF) {
// next enum constant on the same line after comma
illegalToken = true;
}
return illegalToken;
// semi on the same line as last comma, or followed by enum constant
return (nextAstType == TokenTypes.SEMI && nextAst.getLineNo() == lastComma.getLineNo())
|| nextAstType == TokenTypes.ENUM_CONSTANT_DEF;
}

/**
Expand Down

0 comments on commit be8be03

Please sign in to comment.