Changeset 1972 for trunk/autoquest-core-tasktrees
- Timestamp:
- 06/18/15 16:43:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/utils/SimilarTasks.java
r1969 r1972 983 983 984 984 for (Delta delta : deltas) { 985 if (delta.getOriginal().getPosition() < originalIndexes[0]) { 986 originalStartUpdate += delta.getRevised().size(); 987 } 988 if (delta.getOriginal().getPosition() <= originalIndexes[1]) { 989 originalEndUpdate += delta.getRevised().size(); 990 } 991 if (delta.getRevised().getPosition() < revisedIndexes[0]) { 992 revisedStartUpdate += delta.getOriginal().size(); 993 } 994 if (delta.getRevised().getPosition() <= revisedIndexes[1]) { 995 revisedEndUpdate += delta.getOriginal().size(); 985 if (delta.getType() == Delta.TYPE.INSERT) { 986 // for insert deltas only the original indexes must be adapted 987 if (delta.getOriginal().getPosition() <= originalIndexes[0]) { 988 originalStartUpdate += delta.getRevised().size(); 989 } 990 if (delta.getOriginal().getPosition() <= originalIndexes[1]) { 991 originalEndUpdate += delta.getRevised().size(); 992 } 993 } 994 else if (delta.getType() == Delta.TYPE.DELETE) { 995 // for delete deltas only the revised indexes must be adapted 996 if (delta.getRevised().getPosition() <= revisedIndexes[0]) { 997 revisedStartUpdate += delta.getOriginal().size(); 998 } 999 if (delta.getRevised().getPosition() <= revisedIndexes[1]) { 1000 revisedEndUpdate += delta.getOriginal().size(); 1001 } 1002 } 1003 else if (delta.getType() == Delta.TYPE.CHANGE) { 1004 // for change deltas we adapt only the revision indexes. 1005 // If the revised variant is longer than the original, the indexes become smaller. 1006 // else, the other way around 1007 int lengthDiff = delta.getOriginal().size() - delta.getRevised().size(); 1008 1009 if (lengthDiff < 0) { 1010 // the revised variant is longer --> adapt indexes of original 1011 lengthDiff = 0 - lengthDiff; 1012 int start = delta.getOriginal().getPosition(); 1013 int end = start + delta.getOriginal().size() - 1; 1014 1015 if (end < originalIndexes[0]) { 1016 // delta is before indexes 1017 originalStartUpdate += lengthDiff; 1018 } 1019 if ((end <= originalIndexes[1]) || (start <= originalIndexes[1])) { 1020 // delta and indexes overlap 1021 originalEndUpdate += lengthDiff; 1022 } 1023 } 1024 else if (lengthDiff > 0) { 1025 // the original variant is longer --> adapt indexes of revised 1026 int start = delta.getRevised().getPosition(); 1027 int end = start + delta.getRevised().size() - 1; 1028 1029 if (end < revisedIndexes[0]) { 1030 // delta is before indexes 1031 revisedStartUpdate += lengthDiff; 1032 } 1033 if ((end <= revisedIndexes[1]) || (start <= revisedIndexes[1])) { 1034 // delta and indexes overlap 1035 revisedEndUpdate += lengthDiff; 1036 } 1037 } 996 1038 } 997 1039 }
Note: See TracChangeset
for help on using the changeset viewer.