Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bryanschofield
Copy link

@bryanschofield bryanschofield commented Feb 6, 2018

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 new aosp-java-format
enables AOSP options.

Internally this is achieved by giving the SnippetFormatter the ability
to accept JavaFormatterOptions.

This addresses: #179

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`.
@googlebot
Copy link

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.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@bryanschofield
Copy link
Author

go go googlebot

@googlebot
Copy link

CLAs look good, thanks!

Copy link
Contributor

@Stephan202 Stephan202 left a 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;
Copy link
Contributor

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
Copy link
Contributor

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();
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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.

@bryanschofield
Copy link
Author

Thanks for the quick feedback! @Stephan202

@aaime
Copy link

aaime commented May 1, 2018

Hi, we just switched our open source project(s) to Google AOSP and a release with this PR merged would be awesome :-)

@ava1ar
Copy link

ava1ar commented Oct 11, 2018

Any help needed to make this merged?

@Stephan202
Copy link
Contributor

The branch currently has conflicts.

  • @bryanschofield do you think you can resolve them?
  • Any feedback from the Google team on whether this change is viable would be appreciated.

(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.)

Stephan202 added a commit to PicnicSupermarket/google-java-format that referenced this pull request Jan 27, 2019
An alternative approach would be to pass in the formatter; see
google#251.
@cushon cushon added the Eclipse label Feb 3, 2023
@brunoborges
Copy link

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants