[josm-dev] Source code formatting template?
geoj at quantentunnel.de
Wed Aug 27 09:11:20 BST 2008
Frederik Ramm wrote:
> Would you be able to supply such a style sheet that approximately
> matches the current formatting (as far as this is at all discernible)?
Of course they are not all discernible - I would be surprised if not. I
checked a small randomly chosen file set and compared the differences:
1. Indentation: space vs. tab
The files I checked use mostly tabs for indentation - at least for the
first two or three levels. Afterwards I found more often spaces (mixed
indentation). Fully space-only indented files were rare in my file
2. Maximum line length:
A large number of files do contain very lengthy lines, mostly for
defining strings with display messages. Other files use a maximum line
length of ap. 100-140 characters (which is my favorite setting, too).
Files with a max. line length of 80 characters are very rare.
Additionally I made some test with a formatter derived from the default
Eclipse formatter. The major differences were:
1. JavaDoc sections: the formatter compacts this sections and removes
line breaks and alignment spaces which is unfamiliar at a first glance,
but IMHO it is not bad as it shows how the JavaDoc comment will look
like in the generated HTML-JavaDoc.
2. Spaces before and after operations: = < > + - * /
> It is vital that no part of JOSM *requires* Eclipse but as far as I
> understand you're just talking about something that helps you format
> code, right?
Exactly. It only changes indentation, whitespaces, linebreaks and comments.
> If possible I'd like to avoid emitting ^Ms, and also I dislike tab
> indentation because every editor handles them a bit differently so
> they're bound to cause trouble.
Using tabs for indentation are only a problem as long as you mix them
with spaces (in one file). If you have a tab-only respectively
space-only indented file it makes no difference. AFAIK, the default Java
style is indentation by spaces, the Eclipse default uses tabs (but that
can be changed easily).
More information about the josm-dev