-
Notifications
You must be signed in to change notification settings - Fork 864
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
This adds an AOSP formatter to the Eclipse plugin. #251
base: master
Are you sure you want to change the base?
Conversation
by creating two different Eclipse Java Formatter implementations that are selectable in the _Java Code Style > Formatter_ preferences. The `google-java-format` acts just the same. A new `aosp-java-format` enables AOSP options. Internally this is achieved by giving the SnippetFormatter the ability to accept `JavaFormatterOptions`.
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
go go googlebot |
CLAs look good, thanks! |
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.
We could definitely use this within our team! 👍
import com.google.googlejavaformat.FormattingError; | ||
import com.google.googlejavaformat.Newlines; | ||
import com.google.googlejavaformat.Op; | ||
import com.google.googlejavaformat.OpsBuilder; |
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.
It seems the imports were reordered according to Eclipse's default ordering, instead of retaining the order specified by the style guide.
// TODO(cushon): this is only safe because the modifier ordering doesn't | ||
// affect whitespace, | ||
// and doesn't change the replacements that are output. This is not true | ||
// in general for |
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.
Since you reformatted the code, maybe manually fix this section?
* #createSnippetFormatter()} such that the indentation size corresponds with the indent level of | ||
* the format options used to create the snippet formatter. | ||
*/ | ||
protected abstract int indentationSize(); |
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.
🤔 maybe SnippetFormatter#indentationSize()
can be made public
instead? That does mean a modification to its public API, but since this caller could use it, maybe so can others.
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 can make it public, though I tend to prefer more restrictive access until a need arises. That said, I'll make change if you prefer. Please advise.
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.
Well, it seems a need arose ;).
But in all seriousness: I'm not a maintainer of this project, so my advice carries little weight. Let's see what the maintainers say.
Thanks for the quick feedback! @Stephan202 |
Hi, we just switched our open source project(s) to Google AOSP and a release with this PR merged would be awesome :-) |
Any help needed to make this merged? |
The branch currently has conflicts.
(GJF is a tremendous time saver; it'd be great to see this tool adopted as widely as possible. Changes such as these definitely help achieve that.) |
An alternative approach would be to pass in the formatter; see google#251.
Any update on this? |
This is achieved by creating two different Eclipse Java Formatter implementations
that are selectable in the Java Code Style > Formatter preferences.
The
google-java-format
acts just the same. A newaosp-java-format
enables AOSP options.
Internally this is achieved by giving the SnippetFormatter the ability
to accept
JavaFormatterOptions
.This addresses: #179