Adding too many fields into a class it becomes a mess like this:
private static final int UNAVAILABLE = -1;
private static final int EXTERNAL_BUFFER_SIZE = 4000 * 4;
private static final int SKIP_INACCURACY_SIZE = 1200;
private Thread thread = null;
private Object dataSource;
private AudioInputStream audioInputStream;
private AudioInputStream encodedAudioInputStream;
private int encodedAudioLength = -1;
private AudioFileFormat audioFileFormat;
private SourceDataLine sourceDataLine;
I want Eclipse to reformat the code and make it better to read so I modified default formatter and have achieved this:
private static final int UNAVAILABLE = -1;
private static final int EXTERNAL_BUFFER_SIZE = 4000 * 4;
private static final int SKIP_INACCURACY_SIZE = 1200;
private Thread thread = null;
private Object dataSource;
private AudioInputStream audioInputStream;
private AudioInputStream encodedAudioInputStream;
private int encodedAudioLength = -1;
private AudioFileFormat audioFileFormat;
private SourceDataLine sourceDataLine;
But it's still messy and I can't find how to modify the editor further to achieve this (you can see the difference in static)
(Found this piece of code here and I think it can be even more improved to create and an empty column for final):
Image of the Editor in Eclipse:
How can I do this?
2 Answers 2
The upside is that you can customize the way you want.
The downside is that it would be re-inventing the wheel if someone already had done it.
1 Comment
When I run into formatting issues like this my first reaction is "is this class doing too much?".
Through repeated application of the Single Responsibility Principle you should be able to trim down the number of fields to a readable number - and such that no special formatting is required.
javafxtag is misleading here, since it would not matter, if the code containsObjectProperty<Color>orList<BigInteger>.int final x=3; final int y=3;. Should modifiers be reordered? But for a real formatter, one would have to dive into git.eclipse.org/c/jdt/eclipse.jdt.core.git/tree/… etc. I tried it, but ... not the slightest chance of getting anywhere there.