JnRouvignac / AutoRefactor

Eclipse plugin to automatically refactor Java code bases
Other
176 stars 37 forks source link

(DD) WorkWithNullCheckedExpressionFirstRefactoring - wrong refactoring #299

Closed cal101 closed 7 years ago

cal101 commented 7 years ago
class R {
    Object findSymbol(Object... e) {
        return 1;
    }

    /* delta-debug:start */
    Object q(Object l, Object q) {
        Object result;
        if (q == null) {
-            return findSymbol();
+            return result;
        } else {
            ;
            {
                {
                    result = l;
                }
            }
        }
-        return result;
+        return findSymbol();
    }
    /* delta-debug:end */
}
Fabrice-TIERCELIN commented 7 years ago

I have clarified your change. What formatting you need? You can do Ctrl+A Ctrl+Shift+F to format one file or Right-click on src/main/java -> Source -> Format. I don't know if you want to format and refactor at the same time. I think it would be a bad idea.

cal101 commented 7 years ago

@Fabrice-TIERCELIN I am using the AutoRefactor plugin from the command line (https://github.com/cal101/AutoRefactor). I added support for delta debugging https://www.st.cs.uni-saarland.de/dd/. This reduces test cases but that does destroy formatting. Everything is done from the command line withoud the eclipse GUI involved. What I need is some CODE snippet how to call the eclipse API to do formatting.