@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);
     }
   }
 }
Пример #2
0
  @Override
  public Boolean visit(final SwitchEntryStmt n1, final Node arg) {
    final SwitchEntryStmt n2 = (SwitchEntryStmt) arg;

    if (!nodeEquals(n1.getLabel(), n2.getLabel())) {
      return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getStmts(), n2.getStmts())) {
      return Boolean.FALSE;
    }

    return Boolean.TRUE;
  }
 @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);
 }