@@ -280,10 +280,16 @@ private void processRemainingComments(List<UMLComment> commentsBefore, List<UMLC
280280 List <Integer > matchingIndices = findAllMatchingIndices (commentsAfter , comment );
281281 List <Boolean > mappedParent = new ArrayList <Boolean >();
282282 List <Boolean > mappedPreviousStatement = new ArrayList <Boolean >();
283+ List <Boolean > identicalNextComment = new ArrayList <Boolean >();
283284 if (matchingIndices .size () > 1 ) {
284285 for (Integer index : matchingIndices ) {
285286 mappedParent .add (mappedParent (comment , commentsAfter .get (index )));
286287 mappedPreviousStatement .add (mappedPreviousStatement (comment , commentsAfter .get (index )));
288+ if (commentsBefore .indexOf (comment ) < commentsBefore .size () - 1 && index < commentsAfter .size () - 1 ) {
289+ UMLComment commentAfterLeft = commentsBefore .get (commentsBefore .indexOf (comment )+1 );
290+ UMLComment commentAfterRight = commentsAfter .get (index + 1 );
291+ identicalNextComment .add (commentAfterLeft .getFullText ().equals (commentAfterRight .getFullText ()));
292+ }
287293 }
288294 }
289295 int i = -1 ;
@@ -296,6 +302,9 @@ private void processRemainingComments(List<UMLComment> commentsBefore, List<UMLC
296302 if (mappedPreviousStatement .contains (true ) && mappedPreviousStatement .get (i ) == false ) {
297303 continue ;
298304 }
305+ if (identicalNextComment .contains (true ) && identicalNextComment .get (i ) == false ) {
306+ continue ;
307+ }
299308 Pair <UMLComment , UMLComment > pair = Pair .of (comment , commentsAfter .get (index ));
300309 commonComments .add (pair );
301310 deletedComments .remove (comment );
@@ -310,10 +319,16 @@ private void processRemainingComments(List<UMLComment> commentsBefore, List<UMLC
310319 List <Integer > matchingIndices = findAllMatchingIndices (commentsBefore , comment );
311320 List <Boolean > mappedParent = new ArrayList <Boolean >();
312321 List <Boolean > mappedPreviousStatement = new ArrayList <Boolean >();
322+ List <Boolean > identicalNextComment = new ArrayList <Boolean >();
313323 if (matchingIndices .size () > 1 ) {
314324 for (Integer index : matchingIndices ) {
315325 mappedParent .add (mappedParent (commentsBefore .get (index ), comment ));
316326 mappedPreviousStatement .add (mappedPreviousStatement (commentsBefore .get (index ), comment ));
327+ if (commentsAfter .indexOf (comment ) < commentsAfter .size () - 1 && index < commentsBefore .size () - 1 ) {
328+ UMLComment commentAfterLeft = commentsBefore .get (index + 1 );
329+ UMLComment commentAfterRight = commentsAfter .get (commentsAfter .indexOf (comment )+1 );
330+ identicalNextComment .add (commentAfterLeft .getFullText ().equals (commentAfterRight .getFullText ()));
331+ }
317332 }
318333 }
319334 int i = -1 ;
@@ -326,6 +341,9 @@ private void processRemainingComments(List<UMLComment> commentsBefore, List<UMLC
326341 if (mappedPreviousStatement .contains (true ) && mappedPreviousStatement .get (i ) == false ) {
327342 continue ;
328343 }
344+ if (identicalNextComment .contains (true ) && identicalNextComment .get (i ) == false ) {
345+ continue ;
346+ }
329347 Pair <UMLComment , UMLComment > pair = Pair .of (commentsBefore .get (index ), comment );
330348 commonComments .add (pair );
331349 deletedComments .remove (commentsBefore .get (index ));
0 commit comments