Make formatter wrap at function argument rather than qualifier dot [message #1068060] |
Thu, 11 July 2013 17:05  |
Eclipse User |
|
|
|
Hello.
I'd like to format the following class with a maximum line length of 80 characters:
import javax.swing.JLabel;
import javax.swing.JTextField;
public class FormatterTest {
public static void main(String[] args) {
JTextField imagesDirectorySecondPartField = new JTextField();
JLabel imagesDirectorySecondPartLabel = new JLabel();
imagesDirectorySecondPartLabel.setFont(imagesDirectorySecondPartField.getFont());
}
}
When I format it, the last statement gets formatted like this:
imagesDirectorySecondPartLabel.setFont(imagesDirectorySecondPartField
.getFont());
But I want it to format like this:
imagesDirectorySecondPartLabel.setFont(
imagesDirectorySecondPartField.getFont());
In other words, I don't want the formatter to wrap at function qualifier dots; I want it to wrap at arguments.
How do I make the formatter do this?
I'm using Eclipse IDE for Java Developers version Juno Service Release 2.
Thanks!
|
|
|
|
Re: Make formatter wrap at function argument rather than qualifier dot [message #1083254 is a reply to message #1069616] |
Fri, 09 August 2013 13:58  |
Eclipse User |
|
|
|
That does not work.
Making the choices you suggested (and not checking "Force split ..."), it does not wrap the line; it is left longer than 80 characters:
imagesDirectorySecondPartLabel.setFont(imagesDirectorySecondPartField.getFont());
And since you're suggesting I choose a wrap policy of "Wrap all elements, every element on a new line" for "Function Calls" > Arguments > "Settings for arguments", here's another example, this time with two arguments, that better shows that I don't want each argument to be on its own line:
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JLabel;
public class FormatterTest2 {
public static void main(String[] args) {
String textPropertyName = "text";
PropertyChangeListener textChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
// IGNORED
}
};
JLabel imagesDirectorySecondPartLabel = new JLabel();
imagesDirectorySecondPartLabel.addPropertyChangeListener(textPropertyName.toString(), textChangeListener);
}
}
With your suggestion, the last statement gets formatted like this:
imagesDirectorySecondPartLabel.addPropertyChangeListener(
textPropertyName.toString(),
textChangeListener);
but I want it to be formatted like this:
imagesDirectorySecondPartLabel.addPropertyChangeListener(
textPropertyName.toString(), textChangeListener);
|
|
|
Powered by
FUDForum. Page generated in 0.23646 seconds