Skip to content

Commit

Permalink
Complete previous commit with else case
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Sep 20, 2024
1 parent cf0af1b commit 1202c57
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8438,6 +8438,33 @@ protected LeafMapping createLeafMapping(AbstractCodeFragment leaf1, AbstractCode
nestedCreations2.remove(minIndex);
}
}
else {
for(ObjectCreation nestedCreation2 : nestedCreations2) {
int[] editDistance = new int[nestedCreations1.size()];
int[] argumentIntersections = new int[nestedCreations1.size()];
int index = 0;
for(ObjectCreation nestedCreation1 : nestedCreations1) {
int argumentIntersection = nestedCreation1.argumentIntersection(nestedCreation2).size();
argumentIntersections[index] = argumentIntersection;
int d = StringDistance.editDistance(nestedCreation1.actualString(), nestedCreation2.actualString());
editDistance[index] = d;
index++;
}
int minIndex = 0;
int minValue = editDistance[0];
int maxArgumentIntersection = argumentIntersections[0];
for(int i=0; i<editDistance.length; i++) {
if(editDistance[i] < minValue && argumentIntersections[i] > maxArgumentIntersection) {
minValue = editDistance[i];
maxArgumentIntersection = argumentIntersections[i];
minIndex = i;
}
}
LeafMapping newMapping = new LeafMapping(nestedCreations1.get(minIndex).asLeafExpression(), nestedCreation2.asLeafExpression(), container1, container2);
mapping.addSubExpressionMapping(newMapping);
nestedCreations1.remove(minIndex);
}
}
}
}
return mapping;
Expand Down

0 comments on commit 1202c57

Please sign in to comment.