Java Code Arrangement issues (2017.1.3)
I explicitly order members, constructors and methods (by visibility/scope, then by name), per the following rules:

However, this does not work as expected. Given this file (grouped and ordered for ease of viewing):
public class ArrangementTest {
private interface IFruit1 {}
public interface IFruit2 {}
private enum Fruits1 {}
public enum Fruits2 {}
private static class APineapple {}
private static class XPineapple {}
private ArrangementTest(final int a) {}
public ArrangementTest(final String a) {}
private void bOrange() {}
private void aOrange() {}
void bApple() {}
void aApple() {}
protected void bBanana() {}
protected void aBanana() {}
public void bCherry() {}
public void aCherry() {}
}
the above rules format it as this (grouped for ease of viewing):
public class ArrangementTest {
public ArrangementTest(final String a) {}
private ArrangementTest(final int a) {}
public void bCherry() {}
public void aCherry() {}
protected void bBanana() {}
protected void aBanana() {}
void bApple() {}
void aApple() {}
private void bOrange() {}
private void aOrange() {}
public interface IFruit1 {}
public enum Fruits2 {}
private interface IFruit2 {}
private enum Fruits1 {}
private static class APineapple {}
private static class XPineapple {}
}
It is clearly sorting by scope/visibility, but does not appear to be sorting by name within each scope/visibility.
I also assumed the 7th rule above would list everything not already listed (e.g.: inner classes, enums, interfaces) by scope/visibility, then name, which is not the case. I also tried setting the last rule to use "not", such as below, with the same ordering affect.

What I was expecting from the above rules (with either option for the 7th rule) was this:
public class ArrangementTest {
public ArrangementTest(final String a) {}
private ArrangementTest(final int a) {}
public void aCherry() {}
public void bCherry() {}
protected void aBanana() {}
protected void bBanana() {}
void aApple() {}
void bApple() {}
private void aOrange() {}
private void bOrange() {}
public enum Fruits2 {}
public interface IFruit1 {}
private static class APineapple {}
private enum Fruits1 {}
private interface IFruit2 {}
private static class XPineapple {}
}
This certainly seems like a bug. Any advice on either issue?
Please sign in to leave a comment.
Please file an issue at https://youtrack.jetbrains.com/issues/IDEA with the sample code and your profile attached.
Done, thanks for the quick response.
https://youtrack.jetbrains.com/issue/IDEA-173712