diff --git a/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java b/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java index f54d875081..134bf8eab8 100644 --- a/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java +++ b/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java @@ -1209,7 +1209,7 @@ public void inferClassRenameBasedOnReferencesInStringLiterals() throws Refactori if(!r.getBefore().contains("{\n") && !r.getAfter().contains("{\n")) { String matchingClassNameBefore = matches(r.getBefore(), removedClassNames, mapping.getFragment1()); String matchingClassNameAfter = matches(r.getAfter(), addedClassNames, mapping.getFragment2()); - if(matchingClassNameBefore != null && matchingClassNameAfter != null && !r.getAfter().contains(matchingClassNameBefore) && !r.getBefore().contains(matchingClassNameAfter)) { + if(condition(matchingClassNameBefore, matchingClassNameAfter, r)) { Pair pair = Pair.of(matchingClassNameBefore, matchingClassNameAfter); if(countMap.containsKey(pair)) { countMap.put(pair, countMap.get(pair) + 1); @@ -1244,6 +1244,18 @@ public void inferClassRenameBasedOnReferencesInStringLiterals() throws Refactori addedClasses.removeAll(addedClassesToBeRemoved); } + private static boolean condition(String matchingClassNameBefore, String matchingClassNameAfter, Replacement r) { + if(matchingClassNameBefore != null && matchingClassNameAfter != null) { + if(matchingClassNameBefore.contains(matchingClassNameAfter) || matchingClassNameAfter.contains(matchingClassNameBefore)) { + return true; + } + else { + return !r.getAfter().contains(matchingClassNameBefore) && !r.getBefore().contains(matchingClassNameAfter); + } + } + return false; + } + private static boolean conflictingPair(Pair currentPair, Set> allPairs) { for(Pair pair : allPairs) { if(!pair.equals(currentPair)) {