Example #1
0
  protected void compareImpExt(
      ASTClassOrInterfaceDeclaration at,
      ASTClassOrInterfaceDeclaration bt,
      String addMsg,
      String chgMsg,
      String delMsg,
      Class extImpCls,
      Relatorio.TipoDeclaracao tipoElemento) {
    Map aMap = getExtImpMap(at, extImpCls);
    Map bMap = getExtImpMap(bt, extImpCls);

    /*
     * Compara as implementacoes de interface
     */

    // Nesse caso uma mudanca em 2 ou mais declaracoes de heranca iriam
    // contar
    // mais de uma vez, logo eu coloco um return para garantir que só será
    // contada uma vez

    // tr.Ace.log("aMap", aMap);
    // tr.Ace.log("bMap", bMap);

    // I don't like this special case, but it is better than two separate
    // "add" and "remove" messages.

    if (aMap.size() == 1 && bMap.size() == 1) {
      String aName = (String) aMap.keySet().iterator().next();
      String bName = (String) bMap.keySet().iterator().next();

      if (aName.equals(bName)) {
        // tr.Ace.log("no change");
      } else {
        ASTClassOrInterfaceType a = (ASTClassOrInterfaceType) aMap.get(aName);
        ASTClassOrInterfaceType b = (ASTClassOrInterfaceType) bMap.get(bName);

        addChanged(chgMsg, new Object[] {aName, bName}, a, b, tipoElemento);

        return;
      }
    } else {
      List typeNames = new ArrayList();
      typeNames.addAll(aMap.keySet());
      typeNames.addAll(bMap.keySet());

      dubaj.tr.Ace.log("typeNames", typeNames);

      Iterator tit = typeNames.iterator();
      while (tit.hasNext()) {
        String typeName = (String) tit.next();

        ASTClassOrInterfaceType aType = (ASTClassOrInterfaceType) aMap.get(typeName);
        ASTClassOrInterfaceType bType = (ASTClassOrInterfaceType) bMap.get(typeName);

        if (aType == null) {
          addChanged(addMsg, new Object[] {typeName}, at, bType, tipoElemento);

          return;
        } else if (bType == null) {
          addChanged(delMsg, new Object[] {typeName}, aType, bt, tipoElemento);

          return;

        } else {
          // tr.Ace.log("no change");
        }
      }
    }
  }