aserg-ufmg / RefDiff

A tool to mine refactorings in the commit history of git repositories.
MIT License
148 stars 44 forks source link

Extract and Move Method in Rename Method refactoring #19

Open osmarleandro opened 3 years ago

osmarleandro commented 3 years ago

Summary

In the source code present in osmarleandro/RefactoringMiner@38b41e6 commit, I applied a single Rename Method refactoring to isParameter() method in the VariableDeclaration class. RefDiff yields four instances of Extract and Move Method refactoring.

Code example

Diff fragment between the commit osmarleandro/RefactoringMiner@38b41e6 and their parent.

@@ -115,7 +115,7 @@ public class VariableDeclaration implements LocationInfoProvider, VariableDeclar
                return scope;
        }

-       public boolean isParameter() {
+       public boolean isParameter_RENAMED() {
                return isParameter;
        }

@@ -40,7 +40,7 @@ public class ChangeVariableTypeRefactoring implements Refactoring {
        }

        public RefactoringType getRefactoringType() {
-               if(originalVariable.isParameter() && changedTypeVariable.isParameter())
+               if(originalVariable.isParameter_RENAMED() && changedTypeVariable.isParameter_RENAMED())

@@ -51,11 +51,11 @@ public class MergeVariableRefactoring implements Refactoring {

        private boolean allVariablesAreParameters() {
                for(VariableDeclaration declaration : mergedVariables) {
-                       if(!declaration.isParameter()) {
+                       if(!declaration.isParameter_RENAMED()) {
                                return false;
                        }
                }
-               return newVariable.isParameter();
+               return newVariable.isParameter_RENAMED();

@@ -34,9 +34,9 @@ public class RenameVariableRefactoring implements Refactoring {
        }

        public RefactoringType getRefactoringType() {
-               if(originalVariable.isParameter() && renamedVariable.isParameter())
+               if(originalVariable.isParameter_RENAMED() && renamedVariable.isParameter_RENAMED())
                        return RefactoringType.RENAME_PARAMETER;
-               if(!originalVariable.isParameter() && renamedVariable.isParameter())
+               if(!originalVariable.isParameter_RENAMED() && renamedVariable.isParameter_RENAMED())

@@ -51,11 +51,11 @@ public class SplitVariableRefactoring implements Refactoring {

        private boolean allVariablesAreParameters() {
                for(VariableDeclaration declaration : splitVariables) {
-                       if(!declaration.isParameter()) {
+                       if(!declaration.isParameter_RENAMED()) {
                                return false;
                        }
                }
-               return oldVariable.isParameter();
+               return oldVariable.isParameter_RENAMED();
        }

Environment details

RefDiff 2.0

Steps to reproduce

  1. Run RefDiff and give as input the commit osmarleandro/RefactoringMiner@38b41e6.

Actual results

EXTRACT_MOVE    {Method allVariablesAreParameters() at src/gr/uom/java/xmi/diff/SplitVariableRefactoring.java:52}   {Method isParameter_RENAMED() at src/gr/uom/java/xmi/decomposition/VariableDeclaration.java:118})
EXTRACT_MOVE    {Method getRefactoringType() at src/gr/uom/java/xmi/diff/RenameVariableRefactoring.java:36} {Method isParameter_RENAMED() at src/gr/uom/java/xmi/decomposition/VariableDeclaration.java:118})
EXTRACT_MOVE    {Method allVariablesAreParameters() at src/gr/uom/java/xmi/diff/MergeVariableRefactoring.java:52}   {Method isParameter_RENAMED() at src/gr/uom/java/xmi/decomposition/VariableDeclaration.java:118})
EXTRACT_MOVE    {Method getRefactoringType() at src/gr/uom/java/xmi/diff/ChangeVariableTypeRefactoring.java:42} {Method isParameter_RENAMED() at src/gr/uom/java/xmi/decomposition/VariableDeclaration.java:118})

Expected results

A single instance of the Rename Method refactoring applied to isParameter() method in the VariableDeclaration class.