diff --git a/src/main/java/gr/uom/java/xmi/decomposition/VariableReplacementAnalysis.java b/src/main/java/gr/uom/java/xmi/decomposition/VariableReplacementAnalysis.java index ed4268a046..8ea44c4e7d 100644 --- a/src/main/java/gr/uom/java/xmi/decomposition/VariableReplacementAnalysis.java +++ b/src/main/java/gr/uom/java/xmi/decomposition/VariableReplacementAnalysis.java @@ -1791,9 +1791,21 @@ else if(!PrefixSuffixUtils.normalize(replacement.getBefore()).equals(PrefixSuffi candidate.setOriginalVariableDeclaration(v1.getKey()); if(v2 != null) candidate.setRenamedVariableDeclaration(v2.getKey()); - if(!existsConflictingExtractVariableRefactoring(candidate)) { + ExtractVariableRefactoring conflictingExtractVariableRefactoring = existsConflictingExtractVariableRefactoring(candidate); + if(conflictingExtractVariableRefactoring == null) { this.candidateAttributeRenames.add(candidate); } + else { + for(LeafMapping mapping : conflictingExtractVariableRefactoring.getSubExpressionMappings()) { + if(mapping.getFragment1().getString().equals(replacement.getBefore()) && + !mapping.getFragment1().getString().equals(mapping.getFragment2().getString())) { + CandidateAttributeRefactoring newCandidate = new CandidateAttributeRefactoring( + replacement.getBefore(), mapping.getFragment2().getString(), operation1, operation2, + replacementOccurrenceMap.get(replacement)); + this.candidateAttributeRenames.add(newCandidate); + } + } + } } } } @@ -2869,16 +2881,16 @@ private boolean existsConflictingParameterRenameInOperationDiff(SplitVariableRef return false; } - private boolean existsConflictingExtractVariableRefactoring(CandidateAttributeRefactoring ref) { + private ExtractVariableRefactoring existsConflictingExtractVariableRefactoring(CandidateAttributeRefactoring ref) { for(Refactoring refactoring : refactorings) { if(refactoring instanceof ExtractVariableRefactoring) { ExtractVariableRefactoring extractVariableRef = (ExtractVariableRefactoring)refactoring; if(extractVariableRef.getVariableDeclaration().equals(ref.getRenamedVariableDeclaration())) { - return true; + return extractVariableRef; } } } - return false; + return null; } private boolean existsConflictingExtractVariableRefactoring(RenameVariableRefactoring ref) { diff --git a/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java b/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java index 6aa2f4db91..7974c770ab 100644 --- a/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java +++ b/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java @@ -1557,6 +1557,14 @@ private boolean inconsistentAttributeRename(Replacement pattern, Map allVariables1 = mapper.getContainer1().getAllVariables(); List allVariables2 = mapper.getContainer2().getAllVariables(); @@ -1567,9 +1575,15 @@ private boolean inconsistentAttributeRename(Replacement pattern, Map