From 8a6291a5de932149b701ea89275dc805b296fe00 Mon Sep 17 00:00:00 2001 From: xterao Date: Thu, 10 Apr 2025 14:58:12 +0900 Subject: [PATCH 1/2] Add Called SqlFormat Logging --- .../formatter/SqlFormatPreProcessor.kt | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlFormatPreProcessor.kt b/src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlFormatPreProcessor.kt index a7e3a826..5af0a5cf 100644 --- a/src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlFormatPreProcessor.kt +++ b/src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlFormatPreProcessor.kt @@ -28,6 +28,7 @@ import com.intellij.psi.impl.source.codeStyle.PreFormatProcessor import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.elementType import com.intellij.psi.util.prevLeafs +import org.domaframework.doma.intellij.common.PluginLoggerUtil import org.domaframework.doma.intellij.extension.expr.isConditionOrLoopDirective import org.domaframework.doma.intellij.psi.SqlBlockComment import org.domaframework.doma.intellij.psi.SqlCustomElCommentExpr @@ -49,6 +50,8 @@ class SqlFormatPreProcessor : PreFormatProcessor { if (!isEnableFormat()) return rangeToReformat if (source.language != SqlLanguage.INSTANCE) return rangeToReformat + logging() + val visitor = SqlFormatVisitor() source.accept(visitor) @@ -92,7 +95,13 @@ class SqlFormatPreProcessor : PreFormatProcessor { } SqlTypes.RIGHT_PAREN -> { - newKeyword = getRightPatternNewText(it, newKeyword, replaceKeywordList[keywordIndex - 1], createQueryType) + newKeyword = + getRightPatternNewText( + it, + newKeyword, + replaceKeywordList[keywordIndex - 1], + createQueryType, + ) } SqlTypes.WORD -> { @@ -119,7 +128,8 @@ class SqlFormatPreProcessor : PreFormatProcessor { } else if (isCreateViewAs(replaceKeywordList[keywordIndex], createQueryType)) { removeSpacesAroundNewline(document, it.textRange) } else { - val isNewLineGroup = SqlKeywordUtil.getIndentType(nextElement.text ?: "").isNewLineGroup() + val isNewLineGroup = + SqlKeywordUtil.getIndentType(nextElement.text ?: "").isNewLineGroup() val isSetLineKeyword = if (keywordIndex > 0) { SqlKeywordUtil.isSetLineKeyword( @@ -318,6 +328,15 @@ class SqlFormatPreProcessor : PreFormatProcessor { private fun isSubGroupFirstElement(element: PsiElement): Boolean = getElementsBeforeKeyword(element.prevLeafs.toList()) { it.elementType == SqlTypes.LEFT_PAREN } .findLast { it !is PsiWhiteSpace } == null + + private fun logging() { + PluginLoggerUtil.countLogging( + this::class.java.simpleName, + "SqlFormat", + "Format", + System.nanoTime(), + ) + } } private class SqlFormatVisitor : PsiRecursiveElementVisitor() { @@ -335,6 +354,7 @@ private class SqlFormatVisitor : PsiRecursiveElementVisitor() { SqlTypes.KEYWORD, SqlTypes.COMMA, SqlTypes.LEFT_PAREN, SqlTypes.RIGHT_PAREN, SqlTypes.WORD -> { replaces.add(element) } + SqlTypes.OTHER -> { if (element.text == "=") { val updateSetKeyword = @@ -345,6 +365,7 @@ private class SqlFormatVisitor : PsiRecursiveElementVisitor() { } } } + SqlTypes.BLOCK_COMMENT -> if ( element is SqlCustomElCommentExpr && From ffbf79fe80a703923b29e51c271fc4663f6afcf0 Mon Sep 17 00:00:00 2001 From: xterao Date: Thu, 10 Apr 2025 15:26:31 +0900 Subject: [PATCH 2/2] Add Logging BindVariable Completion --- .../sql/provider/SqlParameterCompletionProvider.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/org/domaframework/doma/intellij/contributor/sql/provider/SqlParameterCompletionProvider.kt b/src/main/kotlin/org/domaframework/doma/intellij/contributor/sql/provider/SqlParameterCompletionProvider.kt index 308f949b..0043d5b6 100644 --- a/src/main/kotlin/org/domaframework/doma/intellij/contributor/sql/provider/SqlParameterCompletionProvider.kt +++ b/src/main/kotlin/org/domaframework/doma/intellij/contributor/sql/provider/SqlParameterCompletionProvider.kt @@ -120,6 +120,12 @@ class SqlParameterCompletionProvider : CompletionProvider( originalFile, result, ) + PluginLoggerUtil.countLogging( + this::class.java.simpleName, + "CompletionDirectiveByVariable", + "Completion", + startTime, + ) } } catch (e: Exception) { e.printStackTrace()