Menu

#118 MoreUnit uses wrong indentation when participating in a rename-refactoring

Version 3.0.2
closed-wont-fix
None
5
2015-01-21
2013-09-11
No

To reproduce create a class Foo with a method bar() and a correponding test with testBar(). After renaming the method to 'baz', the test class looks like this:

public class FooTest {

  @Test
    public void testBaz() {

    }
}

The code formatter is configured to indent with two spaces.

Discussion

  • Vera Henneberger

    I can confirm that something is going wrong with the intendation but I am not sure if we will find a way to fix this. All we do is to start a rename change (which just "gives" the new test method name and the rename is handled by eclipse itself).

     
    • Anonymous

      Anonymous - 2013-10-11

      Sorry for the delay. From reading your comment this looks like a bug in JDT (or LTK).
      Or do you think the way the RenameMethodChange is implemented can cause the malfunction?
      I briefly searched the JDT bugzilla but couldn't find an open bug related to renaming and formatting/indentation.
      If you approve, I would open a bug against JDT.

       
  • Vera Henneberger

    • assigned_to: Vera Henneberger
     
  • Vera Henneberger

    Hi Rüdiger,
    sorry for the late answer.
    Yes I think this problem is caused by JDT.
    All we do is creating a change (which contains old method and the new method name). So we don't have a possibility to configure the intendation.

    As a workaround I thought about programmtically reformat the code of the method but haven't had time yet to take a deeper look. (There is still a open bug about move refactorings but the JDT team said they are too busy and I should write a patch...)

     
    • Anonymous

      Anonymous - 2013-10-28

      Just out of curiosity, coiuld you post the JDT bug URL if you have it handy?

      If you take the reformat workaround route, you may want to consider to only fix the indentation (the code that gets executed with Ctrl+I) instead of reformatting the method. This way yoo don't accidentially change manually formatted code passages.
      I know quite a few projects/teams that manually fromat code here and there, where the formatter just isn't flexible enough. Just my thoughts.

      Note that if you consider this, the JavaIndenter and related classes are internal unfortunately (see IndentAction#indent() to get an idea). Not sure though if the formatter code is public.

       
  • Vera Henneberger

    Take a look at https://sourceforge.net/p/moreunit/feature-requests/53/
    This issue contains a link to the bug URL.
    Perhaps you are interested in creating those high quality patches for JDT :-)

     
  • Nicolas Demengel

    • status: open --> closed-wont-fix
     

Log in to post a comment.