From 5ca7339356d608fd80b3d20236d435ccedd89a5f Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 4 Aug 2023 17:36:57 +0200 Subject: [PATCH] Java: don't insert unnecessary space in string templates when formatting (IDEA-321466) GitOrigin-RevId: 196fa8dfc94555bf9554fb830aad1aa1dd0dcbf3 --- .../psi/formatter/java/JavaSpacePropertyProcessor.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java index 8054e7cbc957..89856c413f8d 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java @@ -1958,6 +1958,9 @@ public final class JavaSpacePropertyProcessor extends JavaElementVisitor { if (type1 == JavaTokenType.GTGT && type2 != JavaTokenType.GT && type2 != JavaTokenType.EQ) return true; if (type1 != JavaTokenType.GT && type2 == JavaTokenType.GTGT) return true; + // Because 21 Preview is not the highest language level. + if (ElementType.STRING_TEMPLATE_FRAGMENTS.contains(type1) || ElementType.STRING_TEMPLATE_FRAGMENTS.contains(type2)) return true; + Pair key = pair(type1, type2); Boolean result = ourTokenStickingMatrix.get(key);