Project: JDT
Bug 10601 Refactor should obey formatting rules
Reported: 2002-03-01 13:07:07 | Status: resolved fixed

Refactoring operations should: a) attempt to preserve the original formatting as much as possible b) when new code is being generated, obey the formatting rules set in the preferences page. I have a specific example of Refactor disobeying the rules. There may be more: #1) ensure that your formatting rules are all set to default values. In particular, 'Compact assignment' should be turned off #2) enter the following class: package foo; public class Bar { int getX() { return 0; } void foo() { int y = 0; System.out.println(getX()); System.out.println(getX()); System.out.println(getX()); } } #3) format the class to verify that nothing changes #4) select one of the calls to "getX()" and choose 'Refactor'->'Extract local variable' #5) call the variable x (couldn't refactor have guessed this name?) and hit "Finish" #6) the resulting class looks like: package foo; public class Bar { int getX() { return 0; } void foo() { int y = 0; int x=getX(); System.out.println(x); System.out.println(x); System.out.println(x); } } Note that the "int x=getX();" statement is compacted, even though we turned this option off. #7) Reformat the class again: package foo; public class Bar { int getX() { return 0; } void foo() { int y = 0; int x = getX(); System.out.println(x); System.out.println(x); System.out.println(x); } } #8) IMHO, After a Format and Refactor, an additional Format should have no effect. (20020215 build)

Files changed in fix:
org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java