Ejemplo n.º 1
0
  public FDifference compareMethods(
      FDifference diff, MethodDescription leftMethod, MethodDescription rightMethod) {
    FDifference signDiff =
        basis.compareValues(
            "signature",
            leftMethod.getSignature().toString(),
            rightMethod.getSignature().toString(),
            leftMethod);
    FDifference descrDiff =
        basis.compareDescriptions(
            leftMethod.getName(),
            leftMethod.getSignature().getDescription(),
            rightMethod.getSignature().getDescription(),
            leftMethod);

    if (signDiff != null || descrDiff != null) {
      if (diff == null && signDiff != null) {
        diff = new FDifference(FDKind.ChangedElement, FDRating.Conflict);
      } else if (diff == null) {
        diff = new FDifference(FDKind.ChangedElement, FDRating.Info);
      }

      diff.addDifference(signDiff);
      diff.addDifference(descrDiff);
    }

    return diff;
  }
Ejemplo n.º 2
0
  private FDifference compareMethodLists(
      List<MethodDescription> leftMethods, List<MethodDescription> rightMethods, FDObject source) {
    FDifference diff = null;

    for (MethodDescription leftMethod : leftMethods) {
      MethodDescription rightMethod =
          (MethodDescription) basis.getFromList(rightMethods, leftMethod);
      if (rightMethod != null) {
        diff = compareMethods(diff, leftMethod, rightMethod);
      } else {
        // Deleted method
        FDifference delDiff = new FDifference(FDKind.DeletedElement, FDRating.Conflict);
        delDiff.setSource(leftMethod);
        delDiff.setDescription(
            "The method with signature '"
                + leftMethod.getSignature().toString()
                + "' was removed in version "
                + this.getRightVersion());
        if (diff == null) {
          diff = new FDifference(FDKind.ChangedElement, FDRating.Conflict);
        }
        diff.addDifference(delDiff);
      }
    }

    for (MethodDescription rightMethod : rightMethods) {
      MethodDescription leftMethod =
          (MethodDescription) basis.getFromList(leftMethods, rightMethod);
      if (leftMethod == null) {
        // New method
        FDifference addDiff = new FDifference(FDKind.CreatedElement, FDRating.Warning);
        addDiff.setSource(rightMethod);
        addDiff.setDescription(
            "The method with signature '"
                + rightMethod.getSignature().toString()
                + "' was added in version "
                + this.getRightVersion());
        if (diff == null) {
          diff = new FDifference(FDKind.ChangedElement, FDRating.Conflict);
        }
        diff.addDifference(addDiff);
      }
    }

    if (diff != null) {
      diff.setSource(source);
      diff.setDescription("Method signatures have changed in version " + this.getRightVersion());
    }
    return diff;
  }