Skip to content

Commit b31e224

Browse files
committed
Fixing the override method
1 parent 914b9f2 commit b31e224

23 files changed

+44
-63
lines changed

src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlCustomSpacingBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ class SqlCustomSpacingBuilder {
103103
)
104104

105105
fun getSpacingColumnDefinition(child: SqlColumnBlock): Spacing? {
106-
val indentLen = child.createIndentLen()
106+
val indentLen = child.createBlockIndentLen()
107107
return Spacing.createSpacing(indentLen, indentLen, 0, false, 0, 0)
108108
}
109109

110110
fun getSpacingColumnDefinitionRaw(child: SqlColumnDefinitionRawGroupBlock): Spacing? {
111-
val indentLen = child.createIndentLen()
111+
val indentLen = child.createBlockIndentLen()
112112
return Spacing.createSpacing(indentLen, indentLen, 0, false, 0, 0)
113113
}
114114

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlBlock.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ open class SqlBlock(
454454
}
455455
}
456456

457+
open fun createBlockIndentLen(): Int = 0
458+
457459
open fun getBlock(child: ASTNode): SqlBlock {
458460
val lastGroup = blockBuilder.getLastGroupTopNodeIndexHistory()?.second
459461
return when (child.elementType) {

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlColumnBlock.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class SqlColumnBlock(
5151

5252
override fun buildChildren(): MutableList<AbstractBlock> = mutableListOf()
5353

54-
fun createIndentLen(): Int {
54+
override fun createBlockIndentLen(): Int {
5555
parentBlock?.let {
5656
val parentGroupDefinition = it.parentBlock as? SqlColumnDefinitionGroupBlock
5757
if (parentGroupDefinition == null) return 1

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlCommaBlock.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import com.intellij.formatting.SpacingBuilder
2121
import com.intellij.formatting.Wrap
2222
import com.intellij.lang.ASTNode
2323
import com.intellij.psi.formatter.common.AbstractBlock
24-
import fleet.util.plus
2524
import org.domaframework.doma.intellij.formatter.IndentType
2625
import org.domaframework.doma.intellij.formatter.block.group.SqlColumnGroupBlock
2726
import org.domaframework.doma.intellij.formatter.block.group.SqlCreateKeywordGroupBlock
@@ -43,15 +42,15 @@ open class SqlCommaBlock(
4342
override fun setParentGroupBlock(block: SqlBlock?) {
4443
super.setParentGroupBlock(block)
4544
indent.indentLevel = IndentType.COMMA
46-
indent.indentLen = createIndentLen()
45+
indent.indentLen = createBlockIndentLen()
4746
indent.groupIndentLen = indent.indentLen.plus(node.text.length)
4847
}
4948

5049
override fun buildChildren(): MutableList<AbstractBlock> = mutableListOf()
5150

5251
override fun getIndent(): Indent? = Indent.getSpaceIndent(indent.indentLen)
5352

54-
private fun createIndentLen(): Int {
53+
override fun createBlockIndentLen(): Int {
5554
parentBlock?.let { parent ->
5655
if (parent is SqlSubGroupBlock) {
5756
val parentIndentLen = parent.indent.groupIndentLen

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlKeywordBlock.kt

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import com.intellij.formatting.Wrap
2222
import com.intellij.lang.ASTNode
2323
import com.intellij.psi.formatter.common.AbstractBlock
2424
import org.domaframework.doma.intellij.formatter.IndentType
25-
import org.domaframework.doma.intellij.formatter.SqlKeywordUtil
2625
import org.domaframework.doma.intellij.formatter.block.group.SqlNewGroupBlock
2726

2827
open class SqlKeywordBlock(
@@ -48,7 +47,7 @@ open class SqlKeywordBlock(
4847
super.setParentGroupBlock(block)
4948

5049
indent.indentLevel = indentLevel
51-
indent.indentLen = createIndentLen()
50+
indent.indentLen = createBlockIndentLen()
5251
indent.groupIndentLen = indent.indentLen.plus(node.text.length)
5352
// updateParentIndentLen()
5453
}
@@ -62,7 +61,7 @@ open class SqlKeywordBlock(
6261
return Indent.getNoneIndent()
6362
}
6463

65-
private fun createIndentLen(): Int =
64+
override fun createBlockIndentLen(): Int =
6665
when (indentLevel) {
6766
IndentType.TOP -> {
6867
parentBlock?.let {
@@ -92,20 +91,4 @@ open class SqlKeywordBlock(
9291

9392
else -> 1
9493
}
95-
96-
private fun updateParentIndentLen() {
97-
parentBlock?.let {
98-
if (indentLevel == IndentType.ATTACHED &&
99-
SqlKeywordUtil.isSetLineKeyword(
100-
node.text,
101-
it.node.text,
102-
)
103-
) {
104-
it.indent.groupIndentLen =
105-
it.indent.groupIndentLen
106-
.plus(node.text.length)
107-
.plus(1)
108-
}
109-
}
110-
}
11194
}

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlLineCommentBlock.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ open class SqlLineCommentBlock(
3636
) {
3737
override fun setParentGroupBlock(block: SqlBlock?) {
3838
super.setParentGroupBlock(block)
39-
indent.indentLen = createIndentLen()
39+
indent.indentLen = createBlockIndentLen()
4040
}
4141

4242
override fun buildChildren(): MutableList<AbstractBlock> = mutableListOf()
@@ -45,7 +45,7 @@ open class SqlLineCommentBlock(
4545

4646
override fun isLeaf(): Boolean = true
4747

48-
private fun createIndentLen(): Int {
48+
override fun createBlockIndentLen(): Int {
4949
parentBlock?.let {
5050
if (it is SqlSubQueryGroupBlock) {
5151
if (it.childBlocks.dropLast(1).isEmpty()) {

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlRightPatternBlock.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ open class SqlRightPatternBlock(
7676
override fun setParentGroupBlock(block: SqlBlock?) {
7777
super.setParentGroupBlock(block)
7878
indent.indentLevel = IndentType.NONE
79-
indent.indentLen = createIndentLen()
79+
indent.indentLen = createBlockIndentLen()
8080
indent.groupIndentLen = indent.indentLen
8181
}
8282

8383
override fun buildChildren(): MutableList<AbstractBlock> = mutableListOf()
8484

85-
private fun createIndentLen(): Int = parentBlock?.indent?.groupIndentLen ?: 1
85+
override fun createBlockIndentLen(): Int = parentBlock?.indent?.groupIndentLen ?: 1
8686

8787
override fun isLeaf(): Boolean = true
8888

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlWordBlock.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ open class SqlWordBlock(
4545

4646
override fun setParentGroupBlock(block: SqlBlock?) {
4747
super.setParentGroupBlock(block)
48-
indent.indentLen = createIndentLen()
48+
indent.indentLen = createBlockIndentLen()
4949
indent.groupIndentLen = indent.indentLen
5050
}
5151

5252
override fun buildChildren(): MutableList<AbstractBlock> = mutableListOf()
5353

5454
override fun getIndent(): Indent? = Indent.getSpaceIndent(indent.indentLen)
5555

56-
private fun createIndentLen(): Int {
56+
override fun createBlockIndentLen(): Int {
5757
parentBlock?.let {
5858
when (it) {
5959
is SqlSubQueryGroupBlock -> {

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/expr/SqlElBlockCommentBlock.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class SqlElBlockCommentBlock(
7272
override fun setParentGroupBlock(block: SqlBlock?) {
7373
super.setParentGroupBlock(block)
7474
indent.indentLevel = IndentType.NONE
75-
indent.indentLen = createIndentLen()
75+
indent.indentLen = createBlockIndentLen()
7676
indent.groupIndentLen = 0
7777
}
7878

@@ -233,7 +233,7 @@ class SqlElBlockCommentBlock(
233233

234234
override fun isLeaf(): Boolean = false
235235

236-
private fun createIndentLen(): Int {
236+
override fun createBlockIndentLen(): Int {
237237
parentBlock?.let {
238238
if (it is SqlSubQueryGroupBlock) {
239239
if (it.childBlocks.dropLast(1).isEmpty()) {
@@ -243,7 +243,6 @@ class SqlElBlockCommentBlock(
243243
return it.indent.groupIndentLen.minus(2)
244244
}
245245
}
246-
return 1
247246
}
248247
return 1
249248
}

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/group/SqlColumnDefinitionGroupBlock.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ class SqlColumnDefinitionGroupBlock(
4444

4545
override fun setParentGroupBlock(block: SqlBlock?) {
4646
super.setParentGroupBlock(block)
47-
indent.indentLen = createIndentLen()
47+
indent.indentLen = createBlockIndentLen()
4848
indent.groupIndentLen = indent.indentLen
4949
}
5050

5151
override fun buildChildren(): MutableList<AbstractBlock> = mutableListOf()
5252

5353
override fun getIndent(): Indent? = Indent.getSpaceIndent(indent.indentLen)
5454

55-
override fun createIndentLen(): Int = offset
55+
override fun createBlockIndentLen(): Int = offset
5656
}

0 commit comments

Comments
 (0)