Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ class SqlParameterCompletionProvider : CompletionProvider<CompletionParameters>(
originalFile,
result,
)
PluginLoggerUtil.countLogging(
this::class.java.simpleName,
"CompletionDirectiveByVariable",
"Completion",
startTime,
)
}
} catch (e: Exception) {
e.printStackTrace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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 -> {
Expand All @@ -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(
Expand Down Expand Up @@ -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() {
Expand All @@ -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 =
Expand All @@ -345,6 +365,7 @@ private class SqlFormatVisitor : PsiRecursiveElementVisitor() {
}
}
}

SqlTypes.BLOCK_COMMENT ->
if (
element is SqlCustomElCommentExpr &&
Expand Down
Loading