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

Fix: Correctly support Intellij 193+ #51

Merged
merged 20 commits into from
Nov 19, 2019
Merged

Fix: Correctly support Intellij 193+ #51

merged 20 commits into from
Nov 19, 2019

Conversation

dansanduleac
Copy link
Contributor

@dansanduleac dansanduleac commented Oct 22, 2019

Before this PR

Loading CodeStyleManager programmatically in a way that is not (really) supported in IntelliJ builds 193 and up.
It kind of works, but keeps throwing a lot of errors.

After this PR

==COMMIT_MSG==
Get rid of constant error in new Intellij 193 by replacing CodeStyleManager via a plugin.xml-declared service override, rather than programmatically using internal APIs.
==COMMIT_MSG==

Got the idea here: google/google-java-format#404 (comment)

Fixes #50

Possible downsides?

  • not entirely sure this works on previous versions, need to double check works at least on 191.5849.21
  • feels weird to have to reference the intellij default Impl class directly, but don't know how to refer to the original default as defined in IntelliJ's META-INF/LangExtensions.xml

@dansanduleac dansanduleac requested a review from ferozco October 22, 2019 20:54
@dansanduleac
Copy link
Contributor Author

dansanduleac commented Oct 22, 2019

I think there might be a better way of hooking into CodeStyleManager than replacing it...

The impl seems to have logic that delegates to an ExternalFormatProcessor, although this logic has only existed since 191.4212.41:

@dansanduleac
Copy link
Contributor Author

Update: ExternalFormatProcessor doesn't always get called, which means we can't use it to provide the same functionality, sadly. For instance, it gets called when reformatting a snippet via Command+Shift+ENTER, but not when reformatting a selected chunk / the whole file via Command+Alt+L.

Copy link
Contributor

@CRogers CRogers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved modulo manual testing

@iamdanfox
Copy link
Contributor

Smoke-tested and was still able to format files on my IntelliJ!

IntelliJ IDEA 2019.2.1 (Community Edition)
Build #IC-192.6262.58, built on August 20, 2019
Runtime version: 11.0.3+12-b304.39 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.6
GC: ParNew, ConcurrentMarkSweep
Memory: 1933M
Cores: 12
Registry: 
Non-Bundled Plugins: EclipseCodeFormatter, org.intellij.scala, palantir-java-format

@bulldozer-bot bulldozer-bot bot merged commit a950f9f into develop Nov 19, 2019
@bulldozer-bot bulldozer-bot bot deleted the ds/idea-error branch November 19, 2019 15:48
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.

IDEA plugin keeps breaking on 193.4099+
3 participants