From 51cd85c749613d0bb74abf1f11f43061d2376ae6 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 23 Mar 2024 21:49:39 +0100 Subject: [PATCH] Insight --- .../main/java/tech/picnic/errorprone/utils/SourceCode.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/error-prone-utils/src/main/java/tech/picnic/errorprone/utils/SourceCode.java b/error-prone-utils/src/main/java/tech/picnic/errorprone/utils/SourceCode.java index b9dc4e2958a..301a65dfbb2 100644 --- a/error-prone-utils/src/main/java/tech/picnic/errorprone/utils/SourceCode.java +++ b/error-prone-utils/src/main/java/tech/picnic/errorprone/utils/SourceCode.java @@ -77,6 +77,9 @@ public static String treeToString(Tree tree, VisitorState state) { * Constructs a multi-line string by joining the given source code lines, if they all represent * compile-time constants. * + * @implNote Lines are always joined with {@value #TEXT_BLOCK_LINE_SEPARATOR}, independent of the + * platform on which this method is executed. This ensures consistent line separation in case + * some of the lines are multi-line text blocks. * @param sourceLines The source code lines of interest. * @return A non-empty optional iff all source code lines represent compile-time constants. */ @@ -89,8 +92,7 @@ public static Optional joinConstantSourceCodeLines( for (ExpressionTree sourceLine : sourceLines) { if (!source.isEmpty()) { - // XXX: Review whether we can/should use `System.lineSeparator()` here. - source.append('\n'); + source.append(TEXT_BLOCK_DELIMITER); } String value = ASTHelpers.constValue(sourceLine, String.class);