Bug 238829 - 'Sort Members..' clean-up does not respect indentation while moving static methods
Summary: 'Sort Members..' clean-up does not respect indentation while moving static me...
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2008-06-27 13:42 EDT by Frederic Fusier CLA
Modified: 2020-01-26 16:20 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2008-06-27 13:42:14 EDT
Using build I20080624-0800.

Consider the following CU:

public class X {
	public static final int POOL_SIZE = 25;
	String[] strings;

private X() {
	this.strings = new String[POOL_SIZE];
}

public static X newInstance() {
	return new X();
}

public synchronized String foo() {
	return "";
}
public synchronized void bar() {
}
public void reset() {
}
}

I want to clean-up this CU by sorting members using the default 'Members Sort Order' and without sorting fields, enum constants, etc. Then I get the following output:

public class X {
	public static final int POOL_SIZE = 25;
	public static X newInstance() {
    	return new X();
    }

String[] strings;

private X() {
	this.strings = new String[POOL_SIZE];
}

public synchronized void bar() {
}
public synchronized String foo() {
	return "";
}
public void reset() {
}
}

Note that the indentation of the moved static method is really weird and that the indentation of the field has been removed.

This is really annoying as this prevents us to apply a general JDT/Core code clean-up we wanted to make before restarting 3.5 dvpt in HEAD... :-(
Comment 1 Martin Aeschlimann CLA 2008-06-30 04:59:13 EDT
What are your formatter settings? I wasn't able to reproduce this. I always get:

package p;
public class X {
        public static final int POOL_SIZE = 25;
        public static X newInstance() {
                return new X();
        }

String[] strings;
...


Note: Because of bug 238943, the sort member operation uses the formatter settings from the workspace, not the project.

The code that implements 'sort members' is in JDT/Core (org.eclipse.jdt.internal.core.SortElementsOperation)

This code decides to replace a field with a method, so the method will get the same indent as the field.


Comment 2 Olivier Thomann CLA 2009-07-22 09:26:47 EDT
Could this be related to bug 238943?
Comment 3 Eclipse Genie CLA 2020-01-26 16:20:10 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.