This is an automated email from the ASF dual-hosted git repository.

vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/master by this push:
     new 3456136  Keep backslash when autoformatting <<...\n" +>>
3456136 is described below

commit 345613689899de1ea7915f95260665305e8c0316
Author: Vladimir Sitnikov <[email protected]>
AuthorDate: Wed Dec 8 21:33:34 2021 +0300

    Keep backslash when autoformatting <<...\n" +>>
    
    We do not have multiline string literals in Java yet, so
    the code convention is that \n should be at the end of the line,
    in other words, the newline inside the literal should be paired
    with a newline outside of the literal.
    
    Java's Matcher#replaceAll treats \ in the replacement a special way, so
    literal \ in the replacement string should be coded as \\\\   ¯\_(ツ)_/¯
---
 build.gradle.kts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build.gradle.kts b/build.gradle.kts
index 267aa49..cf40a12 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -539,7 +539,7 @@ allprojects {
                     indentWithSpaces(2)
                     replaceRegex("@Override should not be on its own line", 
"(@Override)\\s{2,}", "\$1 ")
                     replaceRegex("@Test should not be on its own line", 
"(@Test)\\s{2,}", "\$1 ")
-                    replaceRegex("Newline in string should be at end of line", 
"""\\n" *\+""", "\\n\"\n  +")
+                    replaceRegex("Newline in string should be at end of line", 
"""\\n" *\+""", "\\\\n\"\n  +")
                     replaceRegex("require message for requireNonNull", 
"""(?<!#)requireNonNull\(\s*(\w+)\s*(?:,\s*"(?!\1")\w+"\s*)?\)""", 
"requireNonNull($1, \"$1\")")
                     // (?-m) disables multiline, so $ matches the very end of 
the file rather than end of line
                     replaceRegex("Remove '// End file.java' trailer", 
"(?-m)\n// End [^\n]+\\.\\w+\\s*$", "")

Reply via email to