Skip to content

Commit abb8bd5

Browse files
authored
Merge pull request #336 from domaframework/feature/sql-format-support-remove-trailing-spaces
Remove Trailing Spaces
2 parents 66bed16 + 58904fa commit abb8bd5

33 files changed

+33
-37
lines changed

src/main/kotlin/org/domaframework/doma/intellij/formatter/processor/SqlPostProcessor.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ import com.intellij.psi.impl.source.codeStyle.PostFormatProcessor
2323
import org.domaframework.doma.intellij.common.util.StringUtil
2424

2525
abstract class SqlPostProcessor : PostFormatProcessor {
26-
companion object {
27-
private const val FILE_END_PADDING = " ${StringUtil.LINE_SEPARATE}"
28-
}
29-
3026
private val trailingSpacesRegex = Regex(" +(\r?\n)")
3127

3228
override fun processElement(
@@ -55,5 +51,5 @@ abstract class SqlPostProcessor : PostFormatProcessor {
5551
isEndSpace: Boolean,
5652
): String =
5753
text.trimEnd() +
58-
if (isEndSpace) FILE_END_PADDING else ""
54+
if (isEndSpace) StringUtil.LINE_SEPARATE else ""
5955
}

src/test/testData/sql/formatter/CreateTable_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ CREATE TABLE departments
33
id INT PRIMARY KEY
44
, name VARCHAR(100)
55
, loc INT NOT NULL
6-
)
6+
)

src/test/testData/sql/formatter/CreateView_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ AS
55
, lastname
66
, hiredate
77
FROM employee
8-
WHERE salary > 50000
8+
WHERE salary > 50000

src/test/testData/sql/formatter/DeleteReturning_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ DELETE FROM x
55
WHERE id > /* id */101
66
AND div = 't' )
77
RETURNING id
8-
, name
8+
, name

src/test/testData/sql/formatter/Delete_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ DELETE FROM x
22
WHERE id IN ( SELECT id
33
FROM x2
44
WHERE id > /* id */101
5-
AND div = 't' )
5+
AND div = 't' )

src/test/testData/sql/formatter/InsertConflictNothing_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ INSERT INTO employee
44
VALUES ( /* employees.id */0
55
, /* employees.name */'name' )
66
ON CONFLICT (username) ON CONSTRAINT
7-
DO NOTHING
7+
DO NOTHING

src/test/testData/sql/formatter/InsertConflictUpdateWithOutTable_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ INSERT INTO users
66
ON CONFLICT ON CONSTRAINT
77
DO UPDATE
88
SET email = EXCLUDED.email
9-
, created_at = CURRENT_TIMESTAMP
9+
, created_at = CURRENT_TIMESTAMP

src/test/testData/sql/formatter/InsertConflictUpdate_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ DO UPDATE
1313
WHERE employees.name IS DISTINCT FROM EXCLUDED.name
1414
RETURNING id
1515
, manager_id
16-
, name
16+
, name

src/test/testData/sql/formatter/InsertReturning_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ INSERT INTO /*# tableName */
1818
, 1
1919
, /* @maxDateTime() */'9999-12-31' )
2020
RETURNING x1
21-
, x2
21+
, x2

src/test/testData/sql/formatter/InsertWithBindVariable_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ INSERT INTO /*# tableName */
1616
, /* @userId() */1
1717
, x6
1818
, 1
19-
, /* @maxDateTime() */'9999-12-31' )
19+
, /* @maxDateTime() */'9999-12-31' )

0 commit comments

Comments
 (0)