コード例 #1
0
 /**
  * This method returns all the modified methods represented by its first line number and its
  * declaring class. So, for example if a class had a modified method called m1, and its first line
  * is line 10 the set will contain the following element "class_name,10" -> name of the class
  * ","(comma) method's first line number
  *
  * @return
  */
 public Set<String> getSetOfLinesRelatedToModifiedMethods() {
   Set<String> lineNumbersOfModifiedMethods = new HashSet<String>();
   for (Pair<IMethod> pair : getModifiedMethods()) {
     int getLineNumberOfFirstLineOfMethod = getMethodStartLineNumber(pair.getSecond());
     lineNumbersOfModifiedMethods.add(
         getClassName(pair.getSecond().getDeclaringClass())
             + ","
             + getLineNumberOfFirstLineOfMethod);
   }
   return lineNumbersOfModifiedMethods;
 }
コード例 #2
0
  private void load() {

    classCorr = getClassCorrespondence();
    addedClasses.addAll(classCorr.getAddedClasses());
    for (IClass cls : classCorr.getAddedClasses()) {
      addedMethods.addAll(cls.getDeclaredMethods());
      for (IMethod method : cls.getDeclaredMethods()) {
        addToMethodMap(method);
      }
    }
    deletedClasses.addAll(classCorr.getDeletedClasses());
    for (IClass cls : classCorr.getDeletedClasses()) {
      for (IMethod method : cls.getDeclaredMethods()) {
        addToMethodMap(method);
      }
    }
    Collection<Pair<IClass>> matchedClasses = classCorr.getMatchedClassPairs();
    for (Pair<IClass> matchedCls : matchedClasses) {
      boolean isClsMod = false;
      MethodCorrespondence methodCorr =
          new MethodCorrespondence(matchedCls.getFirst(), matchedCls.getSecond());
      for (IMethod method : methodCorr.getAddedMethods()) {
        addedMethods.add(method);
        addToMethodMap(method);
        isClsMod = true;
      }
      for (IMethod method : methodCorr.getDeletedMethods()) {
        deletedMethods.add(method);
        addToMethodMap(method);
        isClsMod = true;
      }
      Collection<Pair<IMethod>> matchedMethods = methodCorr.getMatchedMethodPairs();
      for (Pair<IMethod> matchedMeth : matchedMethods) {
        IMethod method1 = matchedMeth.getFirst();
        IMethod method2 = matchedMeth.getSecond();
        CFGNodeCorrespondence nodeCorr = new CFGNodeCorrespondence(method1, method2);
        if (nodeCorr.isMethodModified()) {
          modifiedMethods.add(matchedMeth);
          isClsMod = true;
        }
        addToMethodMap(nodeCorr.getMethodOneInfo());
        addToMethodMap(nodeCorr.getMethodTwoInfo());
      }
      if (isClsMod) {
        modifiedClasses.add(matchedCls);
      } else {
        unmodifiedClasses.add(matchedCls);
      }
    }
  }