@@ -722,6 +722,10 @@ else if(invocationCoveringTheEntireStatement1.arguments().contains(methodInvocat
722722 Set <String > castExpressions2 = convertToStringSet (statement2 .getCastExpressions ());
723723 removeCommonElements (castExpressions1 , castExpressions2 );
724724
725+ Set <String > textBlocks1 = convertToStringSet (statement1 .getTextBlocks ());
726+ Set <String > textBlocks2 = convertToStringSet (statement2 .getTextBlocks ());
727+ removeCommonElements (textBlocks1 , textBlocks2 );
728+
725729 //perform type replacements
726730 findReplacements (types1 , types2 , replacementInfo , ReplacementType .TYPE , container1 , container2 , classDiff );
727731
@@ -971,6 +975,25 @@ else if(methodInvocations1.contains(s1) && variables2.contains(s2)) {
971975 findReplacements (parenthesizedExpressions1 , parenthesizedExpressions2 , replacementInfo , ReplacementType .PARENTHESIZED_EXPRESSION , container1 , container2 , classDiff );
972976
973977 //perform literal replacements
978+ if (textBlocks1 .size () == textBlocks2 .size ()) {
979+ Iterator <String > it1 = textBlocks1 .iterator ();
980+ Iterator <String > it2 = textBlocks2 .iterator ();
981+ while (it1 .hasNext () && it2 .hasNext ()) {
982+ String s1 = it1 .next ();
983+ String s2 = it2 .next ();
984+ String strippedText1 = Arrays .stream (s1 .split ("\\ R" ))
985+ .map (String ::stripLeading )
986+ .collect (Collectors .joining ("\n " ));
987+ String strippedText2 = Arrays .stream (s2 .split ("\\ R" ))
988+ .map (String ::stripLeading )
989+ .collect (Collectors .joining ("\n " ));
990+ if (strippedText1 .equals (strippedText2 )) {
991+ Replacement replacement = new Replacement (s1 , s2 , ReplacementType .TEXT_BLOCK );
992+ replacementInfo .addReplacement (replacement );
993+ replacementInfo .setArgumentizedString1 (ReplacementUtil .performReplacement (replacementInfo .getArgumentizedString1 (), replacementInfo .getArgumentizedString2 (), replacement .getBefore (), replacement .getAfter ()));
994+ }
995+ }
996+ }
974997 findReplacements (stringLiterals1 , stringLiterals2 , replacementInfo , ReplacementType .STRING_LITERAL , container1 , container2 , classDiff );
975998 findReplacements (charLiterals1 , charLiterals2 , replacementInfo , ReplacementType .CHAR_LITERAL , container1 , container2 , classDiff );
976999 findReplacements (numberLiterals1 , numberLiterals2 , replacementInfo , ReplacementType .NUMBER_LITERAL , container1 , container2 , classDiff );
0 commit comments