Community
Participate
Working Groups
Build ID: 3.4.2 Steps To Reproduce: 1. Enter a method that returns a type with a long name, such as one based on generics e.g. public synchronzied List<FantasticallyWonderfulContainer<FantasticallyWonderfulClass>> getMeTheFantasticContainer() 2. Use Source/Format to reformat the method declaration 3. The line will not break at any of the keywords (public synchronized etc.) or within the return type (e.g. before the "<" of the generic type) or before the name of the method. All of the points listed in 3 should be valid break points when line-breaking. This ensures that code formatted by Eclipse will meet coding standards, such as those enforced by CheckStyle More information:
Created attachment 159574 [details] Possible patch This simplest patch which easily fixes the problem. It only adds possible line break at the following positions of the method declaration: 1) after the modifiers 2) after the type parameters if any 3) after the return type 4) after the method name The proposed wrapping is not configurable and always indent the wrapped line at the same column than the method declaration start. E.g., the following snippet: public interface X { public List<SampleContainer<SampleClass>> getSampleContainer(); } would be formatted as follow with a max line width=40: public interface X { public List<SampleContainer<SampleClass>> getSampleContainer(); } Would this proposal address your needs or would you need the wrapping configurable through the formatter preferences?
Talking with Olivier about this, we decided to add a new preferences for this behavior to let user decide what kind of wrapping he/she wants around these new points of breakage in the method declaration... I'll be back soon with a new patch.
Created attachment 159906 [details] New proposed patch This patch adds a new formatter option to control the wrapping of the method declaration. Note that it also removes the break after the method name which looked a little bit weird after having made some tests...
Created attachment 159929 [details] New proposed patch + doc Same patch than the previous one + add an entry in the build notes...
(In reply to comment #4) > Created an attachment (id=159929) [details] > New proposed patch + doc > Released for 3.6M6 in HEAD stream.
Verified for 3.6M6 using build I20100305-1011