Skip to content

Commit 674d638

Browse files
committed
ASTDiff: Fixes tsantalis#986
1 parent 1076d54 commit 674d638

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/org/refactoringminer/astDiff/matchers/wrappers/RefactoringMatcher.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package org.refactoringminer.astDiff.matchers.wrappers;
22

33
import com.github.gumtreediff.tree.Tree;
4-
import gr.uom.java.xmi.LocationInfo;
5-
import gr.uom.java.xmi.UMLAnnotation;
6-
import gr.uom.java.xmi.UMLClass;
7-
import gr.uom.java.xmi.VariableDeclarationContainer;
4+
import gr.uom.java.xmi.*;
85
import gr.uom.java.xmi.decomposition.*;
96
import gr.uom.java.xmi.diff.*;
107
import gr.uom.java.xmi.diff.MoveCodeRefactoring.Type;
@@ -311,6 +308,9 @@ else if (refactoring instanceof RenameAttributeRefactoring) {
311308
for (AbstractCodeMapping reference : renameAttributeRefactoring.getReferences()) {
312309
List<LeafMapping> subExpressionMappings = reference.getSubExpressionMappings();
313310
for (LeafMapping subExpressionMapping : subExpressionMappings) {
311+
if (belongToDifferentFiles(subExpressionMapping.getFragment1(), renameAttributeRefactoring.getOriginalAttribute()) ||
312+
belongToDifferentFiles(subExpressionMapping.getFragment2(), renameAttributeRefactoring.getRenamedAttribute()))
313+
continue;
314314
Tree srcSimpleName = TreeUtilFunctions.findByLocationInfo(srcTree, subExpressionMapping.getFragment1().getLocationInfo(), Constants.SIMPLE_NAME);
315315
Tree dstSimpleName = TreeUtilFunctions.findByLocationInfo(dstTree, subExpressionMapping.getFragment2().getLocationInfo(), Constants.SIMPLE_NAME);
316316
if (srcSimpleName != null && dstSimpleName != null)
@@ -332,6 +332,10 @@ else if (refactoring instanceof InvertConditionRefactoring) {
332332

333333
}
334334

335+
private boolean belongToDifferentFiles(LocationInfoProvider lp1, LocationInfoProvider lp2) {
336+
return !lp1.getLocationInfo().getFilePath().equals(lp2.getLocationInfo().getFilePath());
337+
}
338+
335339
private static boolean multipleInstancesWithSameDescription(List<Refactoring> refactoringList, Refactoring refactoring) {
336340
int count = 0;
337341
for (Refactoring r : refactoringList) {

0 commit comments

Comments
 (0)