Exemple #1
0
  public void compare(ASTClassOrInterfaceDeclaration at, ASTClassOrInterfaceDeclaration bt) {
    // SimpleNodeUtil.dump(at, "a");
    // SimpleNodeUtil.dump(bt, "b");

    if (at.isInterface() == bt.isInterface()) {
      dubaj.tr.Ace.log("no change in types");
    } else if (bt.isInterface()) {
      addChanged(
          TYPE_CHANGED_FROM_CLASS_TO_INTERFACE,
          null,
          at,
          bt,
          Relatorio.TipoDeclaracao.DeclaracaoClasse);
    } else {
      addChanged(
          TYPE_CHANGED_FROM_INTERFACE_TO_CLASS,
          null,
          at,
          bt,
          Relatorio.TipoDeclaracao.DeclaracaoClasse);
    }

    SimpleNode atParent = SimpleNodeUtil.getParent(at);
    SimpleNode btParent = SimpleNodeUtil.getParent(bt);

    if (compararAcessoMetodo(atParent, btParent, Relatorio.TipoDeclaracao.Classe)) {
      Relatorio.getMudancaClasse().incrementarMudancasClasse();
    }

    if (compararModificadorMetodo(
        atParent, btParent, VALID_TYPE_MODIFIERS, Relatorio.TipoDeclaracao.Classe)) {
      Relatorio.getMudancaClasse().incrementarMudancasClasse();
    }

    compareExtends(at, bt);
    compareImplements(at, bt);

    compareDeclarations(at, bt);
  }
Exemple #2
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);
    }
  }