Skip to content

Eclipse plugin produces different result as standalone formatter version #119

Closed

Description

@davido

I'm testing the plugin, by installing it and selecting the google-java-formatter: [1].
Trying it on this file in Gerrit Code Review, produces completely different result, as release
version 1.2 of google java-formatter: [2]. What I was doing, is Ctrl-A followed by Ctrl+Shift+F.

If I run this command:

$ google-java-format -i gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/edit/ChangeEditIT.java

where the reported version is:

$ google-java-format --version
google-java-format: Version 1.2

then I get the commited version again (no diff).

Eclipse version:

Version: Neon.1a Release (4.6.1)
Build id: 20161007-1200

google-java-formatter is built from: 760a13c

Activity

  1. sormuras commented on Feb 9, 2017

    @sormuras
    Contributor

    Just guessing, the max line length is set to 80 and somehow that setting is applied to the formatted source.

  2. sormuras commented on Feb 9, 2017

    @sormuras
    Contributor

    And/or Gerrit Code Review does not honor the custom formatter implementation.

    What happens, if you open ChangeEditIT.java in an editor and press just Ctrl+Shift+F?

  3. cushon commented on Feb 9, 2017

    @cushon
    Collaborator

    That output wasn't produced by google-java-format. It looks like the built-in eclipse formatter.

    The plugin worked for me with 4.6.2.

  4. davido commented on Feb 9, 2017

    @davido
    Author

    And/or Gerrit Code Review does not honor the custom formatter implementation.

    What do you mean exactly here? It's just a workspace that I opened in Eclipse and replaced the formatter.

    What happens, if you open ChangeEditIT.java in an editor and press just Ctrl+Shift+F?

    I can try it later today.

    Can it be some issues in my workspace then? Of course the next attempt is to upgrade my Eclipse to 4.6.2.

    How can I track it down, whether the gjf is used from within the plugin or not?

  5. davido commented on Feb 9, 2017

    @davido
    Author

    Upgrade to Eclipse 4.6.2 didn't help either. Ctrl-Shift-F, without preceding Ctrl-A doesn't format with gjf.

    I have an impression, that gjf only works in the Preferences->Java-Code Style=>Formatter, but not in the editor.

    So I went ahead, and broke the plugin code with this diff, to confirm my impression: [1]. After building new version and deploying this plugin, I only get exception in the Eclipse log windows, when I enter the setting dialog for Formatter: [2]. However, when I left the Formatter setting dialog ang go back to my file, and press Ctrl+Shift+F I do not get the exception in opened log windows. That confirms that outside the Formatter settings, the plugin still doesn't have any effect.

    My environment:

    eclipse.buildId=4.6.2.M20161124-1400
    java.version=1.8.0_111
    java.vendor=Oracle Corporation
    BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
    Framework arguments:  -product org.eclipse.epp.package.jee.product
    Command-line arguments:  -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product
    

    I created fresh workspace, open gerrit, opened a file and pressed Ctrl-Shift-F.

  6. sormuras commented on Feb 9, 2017

    @sormuras
    Contributor

    Hm, platform-dependent ... Eclipse bug? Did test on Windows.

    Did you try w/o Ctrl+A too? You did. Mh. Running out of clues here.

  7. sormuras commented on Feb 9, 2017

    @sormuras
    Contributor

    Can you please prepend -debug and -consolelog in eclipse.ini? Maybe then you see a swallowed exception when you close the Preferences->Java-Code Style=>Formatter window. Or when pressing Ctrl-Shift-F.

  8. sormuras commented on Feb 9, 2017

    @sormuras
    Contributor

    Erm, what exactly do you mean with open gerrit in:

    I created fresh workspace, open gerrit, opened a file and pressed Ctrl-Shift-F.

    The project named "gerrit" or another addon/plugin?

    Does "gerrit" use the default text editor?
    What happens, if you "File -> Open File..." an simple .java file and try to format this?

  9. davido commented on Feb 9, 2017

    @davido
    Author

    Oh, sorry for the noise. It was project specific formatting setting for Gerrit project: [1].

  10. sormuras commented on Feb 9, 2017

    @sormuras
    Contributor

    😉

  11. davido commented on Feb 9, 2017

    @davido
    Author

    Here is the fix for the problem above: [1].

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions