Skip to content

Commit

Permalink
Fix for issue #778
Browse files Browse the repository at this point in the history
apache/cassandra@cb56d9f
File: src/java/org/apache/cassandra/repair/messages/RepairOption.java
Lines: R135-140

hazelcast/hazelcast@30c4ae0
File: hazelcast/src/main/java/com/hazelcast/internal/monitors/HealthMonitor.java
Lines: L49

apache/flink@bac21bf
File: flink-staging/flink-streaming/flink-streaming-core/src/main/java/org/apache/flink/streaming/api/datastream/DataStream.java
Lines: R702
  • Loading branch information
tsantalis committed Sep 17, 2024
1 parent 3b50468 commit a0033c1
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions src/main/java/gr/uom/java/xmi/diff/UMLJavadocDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ private boolean processModifiedTags(UMLTagElement tagBefore, UMLTagElement tagAf
List<UMLDocElement> deletedDocElements = new ArrayList<UMLDocElement>(fragmentsBefore);
List<UMLDocElement> addedDocElements = new ArrayList<UMLDocElement>(fragmentsAfter);
if(fragmentsBefore.size() <= fragmentsAfter.size()) {
int updates = 0;
for(UMLDocElement docElement : fragmentsBefore) {
if(fragmentsAfter.contains(docElement)) {
List<Integer> matchingIndices = findAllMatchingIndices(fragmentsAfter, docElement);
Expand All @@ -352,23 +351,23 @@ private boolean processModifiedTags(UMLTagElement tagBefore, UMLTagElement tagAf
UMLDocElement after1 = fragmentsBefore.get(beforeIndex+1);
UMLDocElement before2 = fragmentsAfter.get(index-1);
UMLDocElement after2 = fragmentsAfter.get(index+1);
if(before1.equals(before2) && after1.equals(after2) && !alreadyMatchedDocElement(docElement, fragmentsAfter.get(index))) {
if(before1.equals(before2) && after1.equals(after2) && !alreadyMatchedDocElement(docElement, fragmentsAfter.get(index)) &&
!alreadyMatchedDocElement(fragmentsBefore.get(beforeIndex), docElement)) {
matchFound = true;
Pair<UMLDocElement, UMLDocElement> pair = Pair.of(fragmentsBefore.get(beforeIndex), fragmentsAfter.get(index));
commonDocElements.add(pair);
List<Integer> indices1 = findAllMatchingIndices(deletedDocElements, docElement);
List<Integer> indices2 = findAllMatchingIndices(addedDocElements, docElement);
int beforeIndexToRemove = beforeMatchingIndices.indexOf(beforeIndex);
if(beforeIndexToRemove >= indices1.size()) {
beforeIndexToRemove = beforeIndexToRemove - updates;
beforeIndexToRemove = indices1.size()-1;
}
deletedDocElements.remove((int)indices1.get(beforeIndexToRemove));
int afterIndexToRemove = matchingIndices.indexOf(index);
if(afterIndexToRemove >= indices2.size()) {
afterIndexToRemove = afterIndexToRemove - updates;
afterIndexToRemove = indices2.size()-1;
}
addedDocElements.remove((int)indices2.get(afterIndexToRemove));
updates++;
break;
}
}
Expand All @@ -394,7 +393,6 @@ private boolean processModifiedTags(UMLTagElement tagBefore, UMLTagElement tagAf
}
}
else {
int updates = 0;
for(UMLDocElement docElement : fragmentsAfter) {
if(fragmentsBefore.contains(docElement)) {
List<Integer> matchingIndices = findAllMatchingIndices(fragmentsBefore, docElement);
Expand All @@ -409,23 +407,55 @@ private boolean processModifiedTags(UMLTagElement tagBefore, UMLTagElement tagAf
UMLDocElement after1 = fragmentsBefore.get(index+1);
UMLDocElement before2 = fragmentsAfter.get(afterIndex-1);
UMLDocElement after2 = fragmentsAfter.get(afterIndex+1);
if(before1.equals(before2) && after1.equals(after2) && !alreadyMatchedDocElement(fragmentsBefore.get(index), docElement)) {
if(before1.equals(before2) && after1.equals(after2) && !alreadyMatchedDocElement(fragmentsBefore.get(index), docElement) &&
!alreadyMatchedDocElement(docElement, fragmentsAfter.get(afterIndex))) {
matchFound = true;
Pair<UMLDocElement, UMLDocElement> pair = Pair.of(fragmentsBefore.get(index), fragmentsAfter.get(afterIndex));
commonDocElements.add(pair);
List<Integer> indices1 = findAllMatchingIndices(deletedDocElements, docElement);
List<Integer> indices2 = findAllMatchingIndices(addedDocElements, docElement);
int beforeIndexToRemove = matchingIndices.indexOf(index);
if(beforeIndexToRemove >= indices1.size()) {
beforeIndexToRemove = beforeIndexToRemove - updates;
beforeIndexToRemove = indices1.size()-1;
}
deletedDocElements.remove((int)indices1.get(beforeIndexToRemove));
int afterIndexToRemove = afterMatchingIndices.indexOf(afterIndex);
if(afterIndexToRemove >= indices2.size()) {
afterIndexToRemove = afterIndexToRemove - updates;
afterIndexToRemove = indices2.size()-1;
}
addedDocElements.remove((int)indices2.get(afterIndexToRemove));
break;
}
}
}
if(matchFound) {
break;
}
//match HTML tags if the doc elements after them are identical and unique
for(Integer afterIndex : afterMatchingIndices) {
if(afterIndex > 0 && afterIndex < fragmentsAfter.size()-1) {
UMLDocElement after1 = fragmentsBefore.get(index+1);
List<Integer> after1MatchingIndices = findAllMatchingIndices(fragmentsBefore, after1);
UMLDocElement after2 = fragmentsAfter.get(afterIndex+1);
List<Integer> after2MatchingIndices = findAllMatchingIndices(fragmentsAfter, after2);
if(after1.equals(after2) && !alreadyMatchedDocElement(fragmentsBefore.get(index), docElement) &&
!alreadyMatchedDocElement(docElement, fragmentsAfter.get(afterIndex)) &&
after1MatchingIndices.size() == 1 && after2MatchingIndices.size() == 1) {
matchFound = true;
Pair<UMLDocElement, UMLDocElement> pair = Pair.of(fragmentsBefore.get(index), fragmentsAfter.get(afterIndex));
commonDocElements.add(pair);
List<Integer> indices1 = findAllMatchingIndices(deletedDocElements, docElement);
List<Integer> indices2 = findAllMatchingIndices(addedDocElements, docElement);
int beforeIndexToRemove = matchingIndices.indexOf(index);
if(beforeIndexToRemove >= indices1.size()) {
beforeIndexToRemove = indices1.size()-1;
}
deletedDocElements.remove((int)indices1.get(beforeIndexToRemove));
int afterIndexToRemove = afterMatchingIndices.indexOf(afterIndex);
if(afterIndexToRemove >= indices2.size()) {
afterIndexToRemove = indices2.size()-1;
}
addedDocElements.remove((int)indices2.get(afterIndexToRemove));
updates++;
break;
}
}
Expand Down

0 comments on commit a0033c1

Please sign in to comment.