-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add JAVAPKG_STYLE to supplant JAVADOC_STYLE, don’t bind by default #115
Conversation
Hi, Would it be possible to rebase your PR and include a little update to the README.txt file (next to the JAVADOC_STYLE), plus a test against a java file with a package name ? If a remember correctly, we have a test somewhere with every file extension type with / without header to take the input, format it and compare to the expected output. Thanks :-) |
OK, will have a look at that |
@@ -0,0 +1,16 @@ | |||
|
|||
/*- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just see the dash and your comment (#109 (comment)).
My concern is that in Java it is really not common to have this.
Why the dash ? Which IDE reformat a header based on this "hook" ?
I wonder if we shouldn't have instead 2 different header styles because /*-
is not really common amongst Java devs and I am pretty sure people would like the standard one, which is just /*
/*-
is not really common amongst java devs, as I explain in PR #115. If you really want this style perhaps I would suggest 2 styles: one standard without the dash (JAVAPKG_STYLE
), and another one with the dash (JAVAPKG_DASH_STYLE
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Tue, 16 Aug 2016, Mathieu Carbou wrote:
/*-
is not really common amongst Java devs and I am pretty sure
people would like the standard one, which is just/*
Really?
I don’t insist on it, it’s just best practice and to avoid some
tools complaning, but I’ll drop the hyphen-minus from the format.
bye,
//mirabilos
tarent solutions GmbH
Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/
Tel: +49 228 54881-393 • Fax: +49 228 54881-235
HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The /*- .. */
is supposed to indicate that it shouldn't be reformatted:
http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141999.html#350
I have a rough idea wrt. the testcases, but it’s a bit complicated; will look at it later, got to go now. |
Hi Matthew,
+/*-
The `/*- .. */` is supposed to indicate that it shouldn't be reformatted:
http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141999.html#350
thanks **a lot** for this reference. I only knew it from C indent(1), and
people in the Java™ world have been telling me all the time it does not
apply to them — now I have a reference I can throw at them that it indeed
does apply, from a very high-up place even.
In C, indent works like this:
- `/* … */` (inline and blocks) are reformatted
- Blocks with `/*-` and `/**` are _not_ reformatted,
but we tend towards `/*-` for licence information.
In other languages, blocks with `/**` or (.NET) `/***` are used for in-code
documentation, so these varied practices mix very well.
|
Christopher Tubbs dixit:
`SLASHSTAR_STYLE` should be default for `*.java`
/* will be auto-reformatted, which is not desired for
licence headers, so /*- should be used for them.
The current default `/**` for Java isn't just "not preferred". It is
outright incorrect.
Agreed.
|
Like It seems Oracle provided a helpful example of a valid Java comment block which also matches syntax for affecting the behavior of the However, other formatting tools use other conventions for restricting reformatting, and don't respect the dash. Oracle could also have provided an example of how to do it with Eclipse instead (although, Eclipse, more helpfully also has a flag to avoid formatting the "header comment"): // @formatter:off
/*
* Here is a block comment with some very special
* formatting that I want indent(1) to ignore.
*
* one
* two
* three
*/
// @formatter:on |
I'll merge the PR. |
How about adding an option or another style to have the copyright BEFORE the package? Docs say it should be after, but provides no reference as to why. An existing project that I'm cleaning up has it before. As I've seen in many others, and in the Oracle source files. Also see reference: I'll try with adding my own style, but seems this should be configurable? |
Hello, |
Thanks for responding! Which two? But I wasn't getting that result by default with Is it due to the inline definition of the license used in the project? I need
I used this custom template and have the result I'm after:
|
Antony Stubbs dixit:
How about adding an option or another style to have the copyright
BEFORE the package?
No, that will cause errors or at least unnecessary warnings
elsewhere. The package line has to come first.
bye,
//mirabilos
--
Infrastrukturexperte • tarent solutions GmbH
Am Dickobskreuz 10, D-53121 Bonn • http://www.tarent.de/
Telephon +49 228 54881-393 • Fax: +49 228 54881-235
HRB AG Bonn 5168 • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
|
@astubbs You probably just want |
That's odd because that's the style Oracle among many others use. Do you have any reference for that? (as per my Oracle linked example above, to show one example).
Ah I see. Yeah that looks like it. The only other thing is I like the |
Closes: #38