File tree Expand file tree Collapse file tree 6 files changed +15
-7
lines changed
src/main/kotlin/org/domaframework/doma/intellij Expand file tree Collapse file tree 6 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 1616package org.domaframework.doma.intellij.common.util
1717
1818object StringUtil {
19+ const val LINE_SEPARATE : String = " \n "
20+
1921 fun getSqlElClassText (text : String ): String =
2022 text
2123 .substringAfter(" @" )
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package org.domaframework.doma.intellij.document
1818import com.intellij.lang.documentation.AbstractDocumentationProvider
1919import com.intellij.psi.PsiElement
2020import com.intellij.psi.util.PsiTreeUtil
21+ import org.domaframework.doma.intellij.common.util.StringUtil
2122import org.domaframework.doma.intellij.document.generator.DocumentDaoParameterGenerator
2223import org.domaframework.doma.intellij.document.generator.DocumentStaticFieldGenerator
2324import org.domaframework.doma.intellij.psi.SqlElIdExpr
@@ -62,7 +63,7 @@ class ForItemElementDocumentationProvider : AbstractDocumentationProvider() {
6263
6364 generator.generateDocument()
6465
65- return result.joinToString(" \n " )
66+ return result.joinToString(StringUtil . LINE_SEPARATE )
6667 }
6768
6869 override fun generateHoverDoc (
@@ -77,6 +78,6 @@ class ForItemElementDocumentationProvider : AbstractDocumentationProvider() {
7778 val result: MutableList <String ?> = LinkedList <String ?>()
7879 val typeDocument = generateDoc(element, originalElement)
7980 result.add(typeDocument)
80- return result.joinToString(" \n " )
81+ return result.joinToString(StringUtil . LINE_SEPARATE )
8182 }
8283}
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ package org.domaframework.doma.intellij.formatter.block.comment
1717
1818import com.intellij.lang.ASTNode
1919import com.intellij.psi.util.PsiTreeUtil
20+ import org.domaframework.doma.intellij.common.util.StringUtil
2021import org.domaframework.doma.intellij.formatter.block.SqlBlock
2122import org.domaframework.doma.intellij.formatter.util.SqlBlockFormattingContext
2223
@@ -27,5 +28,6 @@ open class SqlBlockCommentBlock(
2728 node,
2829 context,
2930 ) {
30- override fun isSaveSpace (lastGroup : SqlBlock ? ): Boolean = PsiTreeUtil .prevLeaf(node.psi)?.text?.contains(" \n " ) == true
31+ override fun isSaveSpace (lastGroup : SqlBlock ? ): Boolean =
32+ PsiTreeUtil .prevLeaf(node.psi)?.text?.contains(StringUtil .LINE_SEPARATE ) == true
3133}
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package org.domaframework.doma.intellij.formatter.block.comment
1818import com.intellij.lang.ASTNode
1919import com.intellij.psi.formatter.common.AbstractBlock
2020import com.intellij.psi.util.PsiTreeUtil
21+ import org.domaframework.doma.intellij.common.util.StringUtil
2122import org.domaframework.doma.intellij.formatter.block.SqlBlock
2223import org.domaframework.doma.intellij.formatter.util.IndentType
2324import org.domaframework.doma.intellij.formatter.util.SqlBlockFormattingContext
@@ -60,5 +61,5 @@ abstract class SqlDefaultCommentBlock(
6061 }
6162 }
6263
63- override fun isSaveSpace (lastGroup : SqlBlock ? ) = PsiTreeUtil .prevLeaf(node.psi)?.text?.contains(" \n " ) == true
64+ override fun isSaveSpace (lastGroup : SqlBlock ? ) = PsiTreeUtil .prevLeaf(node.psi)?.text?.contains(StringUtil . LINE_SEPARATE ) == true
6465}
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import com.intellij.psi.PsiWhiteSpace
2222import com.intellij.psi.formatter.common.AbstractBlock
2323import com.intellij.psi.util.PsiTreeUtil
2424import com.intellij.psi.util.elementType
25+ import org.domaframework.doma.intellij.common.util.StringUtil
2526import org.domaframework.doma.intellij.common.util.TypeUtil
2627import org.domaframework.doma.intellij.extension.expr.isConditionOrLoopDirective
2728import org.domaframework.doma.intellij.formatter.block.SqlBlock
@@ -108,7 +109,7 @@ class SqlElConditionLoopCommentBlock(
108109 // If the child is a condition loop directive, align its indentation with the parent directive
109110 child.indent.indentLen = indent.indentLen.plus(2 )
110111 } else if (child is SqlLineCommentBlock ) {
111- if (PsiTreeUtil .prevLeaf(child.node.psi, false )?.text?.contains(" \n " ) == true ) {
112+ if (PsiTreeUtil .prevLeaf(child.node.psi, false )?.text?.contains(StringUtil . LINE_SEPARATE ) == true ) {
112113 child.indent.indentLen = indent.groupIndentLen
113114 } else {
114115 child.indent.indentLen = 1
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import com.intellij.formatting.ASTBlock
1919import com.intellij.formatting.Block
2020import com.intellij.formatting.Spacing
2121import com.intellij.psi.tree.IElementType
22+ import org.domaframework.doma.intellij.common.util.StringUtil
2223import org.domaframework.doma.intellij.formatter.block.SqlBlock
2324import org.domaframework.doma.intellij.formatter.block.SqlRightPatternBlock
2425import org.domaframework.doma.intellij.formatter.block.SqlWhitespaceBlock
@@ -79,8 +80,8 @@ class SqlCustomSpacingBuilder {
7980 null -> return nonSpacing
8081 is SqlWhitespaceBlock -> {
8182 val indentLen: Int = child2.indent.indentLen
82- val afterNewLine = child1.getNodeText().substringAfterLast(" \n " , " " )
83- if (child1.getNodeText().contains(" \n " )) {
83+ val afterNewLine = child1.getNodeText().substringAfterLast(StringUtil . LINE_SEPARATE , " " )
84+ if (child1.getNodeText().contains(StringUtil . LINE_SEPARATE )) {
8485 val currentIndent = afterNewLine.length
8586 val newIndent =
8687 if (currentIndent != indentLen) {
You can’t perform that action at this time.
0 commit comments