Skip to content

Commit a039d18

Browse files
committed
Reverted some changes
1 parent 9c7ff14 commit a039d18

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ private class CodeFormatter {
5959
private var indentLevel = 0
6060
private var indentString = ""
6161
private var currentLine = 1
62-
private var extraIndentSize = 0
6362

6463
// Tracks the level of indentation in multi-line comment blocks.
6564
private var inCommentBlock = false
@@ -81,7 +80,6 @@ private class CodeFormatter {
8180
// Handle multi-line comments
8281
inCommentBlock = true
8382
indentLevelOutsideCommentBlock = indentLevel
84-
extraIndentSize = 1
8583
} else if (line.startsWith("//")) {
8684
// Handle single line comments
8785
newIndentLevel = indentLevel
@@ -91,26 +89,22 @@ private class CodeFormatter {
9189
if (line.endsWith("*/")) {
9290
inCommentBlock = false
9391
newIndentLevel = indentLevelOutsideCommentBlock
94-
extraIndentSize = 0
9592
}
9693
}
9794

9895
// Lines starting with '}' should be de-indented even if they contain '{' after;
9996
// in addition, lines ending with ':' are typically labels
100-
val thisLineIndent =
101-
if (line.isEmpty) {
102-
""
103-
} else if (line.startsWith("}") || line.startsWith(")") || line.endsWith(":")) {
104-
" " * (indentSize * (indentLevel - 1))
105-
} else {
106-
indentString
107-
}
108-
code.append(f"/* ${currentLine}%03d */${if (!line.isEmpty) " " else ""}")
97+
val thisLineIndent = if (line.startsWith("}") || line.startsWith(")") || line.endsWith(":")) {
98+
" " * (indentSize * (indentLevel - 1))
99+
} else {
100+
indentString
101+
}
102+
code.append(f"/* ${currentLine}%03d */ ")
109103
code.append(thisLineIndent)
110104
code.append(line)
111105
code.append("\n")
112106
indentLevel = newIndentLevel
113-
indentString = " " * (indentSize * newIndentLevel + extraIndentSize)
107+
indentString = " " * (indentSize * newIndentLevel)
114108
currentLine += 1
115109
}
116110

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeFormatterSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ class CodeFormatterSuite extends SparkFunSuite {
140140
}{
141141
"""
142142
|/* 001 */ /* This is a comment about
143-
|/* 002 */ class A {
144-
|/* 003 */ class body; ...*/
143+
|/* 002 */ class A {
144+
|/* 003 */ class body; ...*/
145145
|/* 004 */ class A {
146146
|/* 005 */ class body;
147147
|/* 006 */ }

0 commit comments

Comments
 (0)