Inline front-end indentation
I noticed that when I inline implement the interface in the class itself, i.e. not inside a method,
Runnable r = new Runnable() {
@Override
public void run() {
// do something
}
};
and then press CTRL+ SHIFT+ F(auto-correct indentation), eclipse discards methods just like:
Runnable r = new Runnable() {
@Override
public void run() {
// do something
}
};
Has anyone else encountered this?
Depends on your eclipse settings. You can change the default formatting by clicking: window> preferences> java> code style> formatter.
Uncheck "Align fields in columns" from the first Formatter tab
In eclipse preferences go to the formatting page (Window-> Preferences, Java-> Code Style-> Formatter). Edit the "Profile" formatting. Click the Blank Lines tab and change the Before First Declaration value from 1 to 0.
FYI, this will change the formatting for ALL classes, not just anonymous ones. It would be nice if it was more grainy, but it is.