Community
Participate
Working Groups
You should be able to customize the formatter to use a custom header and footer and to remove old headers and footers. I use this to put the license description along with some file information (such as file name and package and encoding) in the header. Whenever I format a new file, it should insert the header. Whenever i format a file that already has a header, it should remove that header in preference to my header. The header configuration should be on its own tab with the options to add some number of blank line (enter in a spinner or text field) after the header and before the footer.
From my point of view, this has nothing to do with code formatting. Code formatters should not change the source code. They should simply rearrange it.
Actually I disagree. You should see how Jalopy uses headers. It allows you to do really cool things such as attach license notes and make SURE they stay there. Headers are not part of the "source" per se. They are merely .. well .. headers. Things that are standard and developers shouldnt be messing with them.
In Eclipse, headers can be handled by setting the type comment in the template section. It is not because Jalopy is handling headers that all code formatters have to do the same thing.
That only works if you create a new type using the new -> class approach. That does NOT work if the class was created outside of eclipse or by another user using a different template (such as a new junior developer who doesnt have that information). In addition, the templates are only applied at generation time so that if a user accidentally makes a mistake and changes them, you will never know. Finally, headers can be embedded with variables such as $fileName$ $package$ (those 2 are for jalopy) that change if you move or rename the file. With a code formatter these are automatically updated. Overall if you want to implement consistent headers and footers, templates are the way to go.
I mean templates in the code formatter.
*** Bug 49898 has been marked as a duplicate of this bug. ***
The code formatter doesn't change the code (add or remove tokens). This should be addressed by a separate tool. Close as WONTFIX