@Override
 public void visit(MethodDeclaration methodDeclaration, Object arg) {
   if (methodDeclaration.getBody() != null) {
     for (Statement statement : methodDeclaration.getBody().getStmts()) {
       // check for starting a block statement
       if (statement instanceof SwitchStmt) {
         SwitchStmt switchStmt = (SwitchStmt) statement;
         for (SwitchEntryStmt switchEntryStmt : switchStmt.getEntries()) {
           reportExcessiveIndentation(switchEntryStmt.getStmts());
         }
       } else if (statement instanceof IfStmt) {
         Statement currentIf = statement;
         do {
           reportExcessiveIndentation(((IfStmt) currentIf).getThenStmt());
           currentIf = ((IfStmt) currentIf).getElseStmt();
         } while (currentIf instanceof IfStmt);
       } else if (statement instanceof WhileStmt) {
         reportExcessiveIndentation(((WhileStmt) statement).getBody());
       } else if (statement instanceof ForeachStmt) {
         reportExcessiveIndentation(((ForeachStmt) statement).getBody());
       } else if (statement instanceof ForStmt) {
         reportExcessiveIndentation(((ForStmt) statement).getBody());
       } else if (statement instanceof DoStmt) {
         reportExcessiveIndentation(((DoStmt) statement).getBody());
       }
     }
   }
   super.visit(methodDeclaration, arg);
 }
Example #2
0
 public void visit(SwitchStmt n, Object arg) {
   n.getSelector().accept(this, arg);
   if (n.getEntries() != null) {
     for (SwitchEntryStmt e : n.getEntries()) {
       e.accept(this, arg);
     }
   }
 }
 @Override
 public void visit(final SwitchStmt n, final A arg) {
   visitComment(n.getComment(), arg);
   n.getSelector().accept(this, arg);
   if (n.getEntries() != null) {
     for (final SwitchEntryStmt e : n.getEntries()) {
       e.accept(this, arg);
     }
   }
 }
Example #4
0
 public void visit(SwitchEntryStmt n, Object arg) {
   if (n.getLabel() != null) {
     n.getLabel().accept(this, arg);
   } else {
   }
   if (n.getStmts() != null) {
     for (Statement s : n.getStmts()) {
       s.accept(this, arg);
     }
   }
 }
 @Override
 public void visit(final SwitchEntryStmt n, final A arg) {
   visitComment(n.getComment(), arg);
   if (n.getLabel() != null) {
     n.getLabel().accept(this, arg);
   }
   if (n.getStmts() != null) {
     for (final Statement s : n.getStmts()) {
       s.accept(this, arg);
     }
   }
 }