Exemplo n.º 1
0
  protected void addDeclaration(SimpleNode decl, SimpleNode other, boolean added) {
    dubaj.tr.Ace.log("decl: " + decl);

    if (decl instanceof ASTClassOrInterfaceBodyDeclaration) {
      decl = TypeDeclarationUtil.getDeclaration((ASTClassOrInterfaceBodyDeclaration) decl);
    }

    if (decl instanceof ASTMethodDeclaration) {
      ASTMethodDeclaration method = (ASTMethodDeclaration) decl;
      String fullName = MethodUtil.getFullName(method);
      addDeclaration(
          added,
          METHOD_ADDED,
          METHOD_REMOVED,
          fullName,
          other,
          method,
          Relatorio.TipoDeclaracao.Metodo);
      if (added) {
        Relatorio.getMudancaClasse().incrementarMudancasMetodo(new MudancaMetodoAdicao(method));
      } else {
        Relatorio.getMudancaClasse().incrementarMudancasMetodo(new MudancaMetodoRemocao(method));
      }

    } else if (decl instanceof ASTFieldDeclaration) {
      ASTFieldDeclaration field = (ASTFieldDeclaration) decl;
      String names = FieldUtil.getNames(field);
      addDeclaration(
          added,
          FIELD_ADDED,
          FIELD_REMOVED,
          names,
          other,
          field,
          Relatorio.TipoDeclaracao.Atributo);

      if (added) {
        Relatorio.getMudancaClasse().incrementarMudancasAtributo();
      } else {
        Relatorio.getMudancaClasse().incrementarMudancasAtributo();
      }

    } else if (decl instanceof ASTConstructorDeclaration) {
      ASTConstructorDeclaration ctor = (ASTConstructorDeclaration) decl;
      String fullName = CtorUtil.getFullName(ctor);
      addDeclaration(
          added,
          CONSTRUCTOR_ADDED,
          CONSTRUCTOR_REMOVED,
          fullName,
          other,
          ctor,
          Relatorio.TipoDeclaracao.Construtor);
    } else if (decl instanceof ASTClassOrInterfaceDeclaration) {
      ASTClassOrInterfaceDeclaration coid = (ASTClassOrInterfaceDeclaration) decl;
      String name = ClassUtil.getName(coid).image;
      String addMsg = null;
      String remMsg = null;
      if (coid.isInterface()) {
        addMsg = INNER_INTERFACE_ADDED;
        remMsg = INNER_INTERFACE_REMOVED;
      } else {
        addMsg = INNER_CLASS_ADDED;
        remMsg = INNER_CLASS_REMOVED;
      }
      addDeclaration(
          added, addMsg, remMsg, name, other, coid, Relatorio.TipoDeclaracao.DeclaracaoClasse);
    } else if (decl == null) {
      // nothing.
    } else {
      dubaj.tr.Ace.stack(dubaj.tr.Ace.REVERSE, "WTF? decl: " + decl);
    }
  }