Skip to content

Commit a489938

Browse files
committed
rebase with master
1 parent 63377a6 commit a489938

File tree

1 file changed

+8
-0
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen

1 file changed

+8
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeFormatter.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ object CodeFormatter {
8989
}
9090
new CodeAndComment(code.result().trim(), map)
9191
}
92+
93+
def stripExtraNewLinesAndComments(input: String): String = {
94+
val commentReg =
95+
("""([ |\t]*?\/\*[\s|\S]*?\*\/[ |\t]*?)|""" + // strip /*comment*/
96+
"""([ |\t]*?\/\/[\s\S]*?\n)""").r // strip //comment
97+
val codeWithoutComment = commentReg.replaceAllIn(input, "")
98+
codeWithoutComment.replaceAll("""\n\s*\n""", "\n") // strip ExtraNewLines
99+
}
92100
}
93101

94102
private class CodeFormatter {

0 commit comments

Comments
 (0)