File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/main/kotlin/org/domaframework/doma/intellij/formatter Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ import com.intellij.psi.PsiElement
2424import com.intellij.psi.PsiFile
2525import com.intellij.psi.codeStyle.CodeStyleSettings
2626import com.intellij.psi.impl.source.codeStyle.PostFormatProcessor
27+ import org.domaframework.doma.intellij.setting.SqlLanguage
28+ import org.domaframework.doma.intellij.state.DomaToolsFunctionEnableSettings
2729
2830class SqlPostProcessor : PostFormatProcessor {
2931 override fun processElement (
@@ -36,6 +38,9 @@ class SqlPostProcessor : PostFormatProcessor {
3638 rangeToReformat : TextRange ,
3739 settings : CodeStyleSettings ,
3840 ): TextRange {
41+ if (! isEnableFormat()) return rangeToReformat
42+ if (source.language != SqlLanguage .INSTANCE ) return rangeToReformat
43+
3944 val project: Project = source.project
4045 val document = PsiDocumentManager .getInstance(project).getDocument(source) ? : return rangeToReformat
4146
@@ -55,4 +60,10 @@ class SqlPostProcessor : PostFormatProcessor {
5560 }
5661 return TextRange (0 , finalText.length)
5762 }
63+
64+ private fun isEnableFormat (): Boolean {
65+ val setting = DomaToolsFunctionEnableSettings .getInstance()
66+ val isEnableFormat = setting.state.isEnableSqlFormat
67+ return isEnableFormat
68+ }
5869}
You can’t perform that action at this time.
0 commit comments