Skip to content

Commit 84ea159

Browse files
committed
Improve matching of multi-line comments with differences in empty lines
JabRef/jabref-koppor#716 org.jabref.gui.openoffice.OOBibBase (#976)
1 parent f2dce48 commit 84ea159

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/main/java/gr/uom/java/xmi/UMLComment.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public String toString() {
102102
return sb.toString();
103103
}
104104

105+
public boolean equalTextIgnoringEmptyLines(UMLComment other) {
106+
String text1 = this.getText().replaceAll("(?m)^\\s+$", "").replaceAll("(?m)^\\n", "").replaceAll("(\\r?\\n)$", "");
107+
String text2 = other.getText().replaceAll("(?m)^\\s+$", "").replaceAll("(?m)^\\n", "").replaceAll("(\\r?\\n)$", "");
108+
return text1.equals(text2) || text1.equals(text2 + "*") || text2.equals(text1 + "*");
109+
}
110+
105111
public boolean isCommentedCode() {
106112
if(locationInfo.getCodeElementType().equals(CodeElementType.LINE_COMMENT)) {
107113
String text = getText();

src/main/java/gr/uom/java/xmi/diff/UMLCommentListDiff.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ public static List<Integer> findAllMatchingIndices(List<UMLComment> fragments, U
449449
if(comment.getText().equals(element.getText())) {
450450
matchingIndices.add(i);
451451
}
452+
else if(comment.equalTextIgnoringEmptyLines(element)) {
453+
matchingIndices.add(i);
454+
}
452455
}
453456
return matchingIndices;
454457
}

0 commit comments

Comments
 (0)