Fixed the mapping of statements in commit
jgit/df3469f6ad81dccb314bf2d5021a3cec2b184985
org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
L -- R
@@ -407,10 +407,17 @@ public class UMLOperationBodyMapper implements Comparable<UMLOperationBodyMapper
}
if(alreadyMatched1(parent1) && alreadyMatched2(parent2) &&
!parent1.getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK) &&
- !parent2.getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK) &&
- parent1.getString().equals(parent2.getString())) {
+ !parent2.getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK)) {
+ if(parent1.getString().equals(parent2.getString())) {
break;
}
+ else if(parent2.getStatements().size() > 0 && containsMapping(parent1.getParent(), parent2.getStatements().get(0))) {
+ break;
+ }
+ else if(parent1.getStatements().size() > 0 && containsMapping(parent1.getStatements().get(0), parent2.getParent())) {
+ break;
+ }
+ }
if(!alreadyMatched1(parent1) || !alreadyMatched2(parent2)) {
int indexOfChildInParent1 = parent1.getStatements().indexOf(child1);
int indexOfChildInParent2 = parent2.getStatements().indexOf(child2);
@@ -7461,6 +7468,17 @@ public class UMLOperationBodyMapper implements Comparable<UMLOperationBodyMapper
return false;
}
+ private boolean containsMapping(AbstractCodeFragment fragment1, AbstractCodeFragment fragment2) {
+ if(fragment1 != null && fragment2 != null) {
+ for(AbstractCodeMapping mapping : this.mappings) {
+ if(mapping.getFragment1().equals(fragment1) && mapping.getFragment2().equals(fragment2)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
public boolean containsParentMapping(AbstractCodeMapping mapping) {
CompositeStatementObject parent1 = mapping.getFragment1().getParent();
CompositeStatementObject parent2 = mapping.getFragment2().getParent();
