google / google-java-format

Reformats Java source code to comply with Google Java Style.
Other
5.59k stars 855 forks source link

organize imports doesnt work for Eclipse Oxygen.3a Release (4.7.3a) #289

Open leByteBuster opened 6 years ago

leByteBuster commented 6 years ago

I'm trying to setup google-java-format plugin for eclipse and for intellij so my team can work with different IDEs. However, though it works well for Intellij it doesnt for the mentioned eclipse version. It formats the code but imports arent touched at all.

leByteBuster commented 6 years ago

Just tried the same with Eclipse Neon. Same Problem - imports arent organized. I'm using version 1.6. Is there something missing in the documentation maybe? It only says to

Drop it into the Eclipse drop-ins folder to activate the plugin.

leByteBuster commented 6 years ago

Okay. As described here: https://github.com/google/google-java-format you only have to activate the plugin. For intellij it says you have to load a xml config file also. So i wondered if this is needed for eclipse too. So i tried to load the config file from https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml As it seems it works. So i dont know if the google formatter should work without doing this because for me it didnt.

jakub-bochenski commented 6 years ago

Just a guess, but maybe it's because formatting happens in https://github.com/google/google-java-format/blob/d109789d7e078a3e81803683727096412f463ba8/core/src/main/java/com/google/googlejavaformat/java/ImportOrderer.java while the plugin may be using just the https://github.com/google/google-java-format/blob/4ae067aef19d0882c5a61f514ea40fa88e9b7067/core/src/main/java/com/google/googlejavaformat/java/SnippetFormatter.java

jakub-bochenski commented 6 years ago

After a quick look I'm quite convinced that the SnippetFormatter that Eclipse plugin is using just doesn't organize imports.

youngm commented 5 years ago

To fix my problem with eclipse import organization I had to manually:

alanamircruz commented 4 years ago

For me worked only by removing all packages from the "Organize Imports" section (after adding the google java format plugin -1.6 only, January 2020- and the google style guide xml for eclipse). Hope it works for you.

image

PD: The only missing part is the line or groups as mentioned in comment above, but order and priority seems ok