EclipseCodeFormatter
EclipseCodeFormatter copied to clipboard
Missing space before instanceof operator
What steps will reproduce the issue?
Format the following code.
if (a.get() instanceof B st) {
}
What is the expected result?
Nothing should change.
What happens instead?
The space before instanceof is removed in IntelliJ using the Eclipse Code Formatter, i.e. the output is
if (a.get()instanceof B st) {
}
With Eclipse 2020-06 this does not happen. As far as I can tell no setting in Eclipse or IntelliJ has influence on the output.
Without the st at the end, the formatting is correct.
Paste information about IDE and OS (it can be copied from Help | About dialog).
Tested on Arch Linux and Windows.
IntelliJ IDEA 2022.1.2 (Ultimate Edition) Build #IU-221.5787.30, built on May 31, 2022 Licensed to CQSE GmbH / David Baum You have a perpetual fallback license for this version. Subscription is active until August 17, 2023. Runtime version: 11.0.15+10-b2043.56 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Linux 5.18.1-arch1-1 GC: G1 Young Generation, G1 Old Generation Memory: 8092M
Cores: 16 Registry: debugger.watches.in.variables=false
Non-Bundled Plugins: org.turbanov.run.configuration.as.action (1.4.5) com.intellij.plugins.watcher (221.5787.13) tirke.cupPlugin (1.4) org.jetbrains.idea.grammar (2021.1.2) com.google.bamboo.id (1.6.3-203) com.dubreuia (2.3.0) com.teamscale.ide.intellij (8.0.0) Key Promoter X (2022.1.2) com.majera.intellij.codereview.gitlab (2022.2.1.221) EclipseCodeFormatter (22.0.203.000.0-Eclipse_2021-09) intellij.prettierJS (221.5787.15) com.intellij.plugins.html.instantEditing (221.5787.15) Pythonid (221.5787.30) izhangzhihao.rainbow.brackets (6.23)
Kotlin: 221-1.6.21-release-337-IJ5787.30 Current Desktop: KDE
Eclipse: Eclipse DSL Tools (includes Incubating components) Version: 2020-06 (4.16.0) Build id: 20200615-1200
Stacktrace
2022-06-07 23:52:17,998 [43951408] FINE - k.f.p.EclipseCodeStyleManager_IJ_2016_3plus - format Example.java 0 146
2022-06-07 23:52:17,998 [43951408] FINE - k.f.p.EclipseCodeFormatter - #format 0-146
2022-06-07 23:52:17,998 [43951408] FINE - k.f.p.EclipseCodeFormatter - #formatWhenEditorIsOpen Example.java
2022-06-07 23:52:17,999 [43951409] FINE - k.f.a.EclipseJavaFormatterAdapter - #formatInternal
2022-06-07 23:52:17,999 [43951409] FINE - k.f.a.EclipseJavaFormatterAdapter - #starting to format by eclipse formatter
2022-06-07 23:52:18,001 [43951411] FINE - k.f.a.EclipseJavaFormatterAdapter - reformatting done
2022-06-07 23:52:18,002 [43951412] FINE - k.f.p.EclipseCodeFormatter - #formatWhenEditorIsOpen done
It can be also reproduced with a current Eclipse 2022-02 formatter profile. The problem only happens if parentheses are before instanceof.
Following code is formatted correctly:
if (a instanceof B st) { }
Did you find any solution to this ? @DanielWebelsiep
This bug has been fixed for Eclipse version 4.22 M1 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=574437). Therefore, updating the bundled Eclipse installation should fix this bug.