You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the code is currently not supported by palantir-java-format, I tried to mute the problem by adding the // spotless:off and // spotless:on comments to disable evaluation of the code as showed above.
Expected result
The source code between // spotless:off and // spotless:on should be ignored by spotless and the evaluation should succeed.
Actual result
The spotless evaluation fails in the same way as if the comments were not added, i.e.
mvn spotless:apply
[...]
Unable to format file [path to Example.java]: com.palantir.javaformat.java.FormatterException: error: expected token: 'when'; generated - instead -> [Help 1]
... It implements this under the hood with PipeStepPair, which has an In step and an Out step. The In step is the very first step which gets applied, Out is the last step, and all the other formatting steps go in between them. The In step finds matching off/on pairs, and stores the text between them. The intermediate steps like google-java-format or whatever do their work, and at the end the Out step finds the off/on pairs again, which may have moved. Then it replaces those pairs with whatever was stored by the In step.
palantir-java-format
does not currently all Java 21 additions (see palantir/palantir-java-format#952). In an attempt to work around this problem, I tried to use spotless:off and spotless:on. The example below compiles using JDK 21 as it is supported by JEP 441 : Pattern Matching for switch:Since the code is currently not supported by
palantir-java-format
, I tried to mute the problem by adding the// spotless:off
and// spotless:on
comments to disable evaluation of the code as showed above.Expected result
The source code between
// spotless:off
and// spotless:on
should be ignored by spotless and the evaluation should succeed.Actual result
The spotless evaluation fails in the same way as if the comments were not added, i.e.
References
Maven config:
Maven:
The text was updated successfully, but these errors were encountered: