Community
Participate
Working Groups
Currently, when generating a constructor, it is inserted after the last member. In the common case where a class already has methods, this will be after the last method. It should be possible to insert the constructor between the fields and the method, where it belongs, according to the Java Coding Conventions. References: http://www.oracle.com/technetwork/java/codeconventions-150003.pdf, section 3.1.1, p1.
Are you referring to - Source > Generate Constructor using Fields... - Source > Generate Constructors from Superclass... ? Both these commands are completely agnostic to ordering, they just insert their stuff at the current cursor location (and thus don't stop you from having it at your desired location). Do you observe s.t. different?
(In reply to Stephan Herrmann from comment #1) > Are you referring to > - Source > Generate Constructor using Fields... > - Source > Generate Constructors from Superclass... > ? Yes, exactly. When I click on “Source > Generate Constructor using Fields...”, a large dialog opens. Below the checkbox-list of fields, there is a combobox where I can select the “Insertion point”. I was referring to that.
(In reply to Roland Illig from comment #2) > (In reply to Stephan Herrmann from comment #1) > > Are you referring to > > - Source > Generate Constructor using Fields... > > - Source > Generate Constructors from Superclass... > > ? > > Yes, exactly. > > When I click on “Source > Generate Constructor using Fields...”, a large > dialog opens. Below the checkbox-list of fields, there is a combobox where I > can select the “Insertion point”. I was referring to that. Thanks. So this combo is initialized with s.t. like "after foo()" describing the current cursor position, which makes this the default behavior. The combo also offers "first member" and "last member", the latter selecting the behavior you describe. => You seem to be requesting another fixed option here. Which one would it be? - "After last field" - "First method" ? I.e., what happens if fields and methods are happily mixed in a file? Other question: should this option distinguish constructors from regular methods? Should the option, e.g., read: "Last constructor"?
(In reply to Stephan Herrmann from comment #3) > => You seem to be requesting another fixed option here. Which one would it > be? > - "After last field" > - "First method" > ? > > I.e., what happens if fields and methods are happily mixed in a file? I prefer the choice “After last field”. > should this option distinguish constructors from regular methods? When there are constructors, the new constructor should be inserted below the existing ones. > Should the option, e.g., read: "Last constructor"? When I generate a constructor, it is mostly because no other constructor exists. Therefore this wording could be confusing. Same for “Before first method” when the methods don’t exist yet.