Skip to content

Sql Format Official Version #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b7efea1
Refactor SQL formatting and improve logical conditions in queries
xterao Jun 26, 2025
ec5ab28
Merge pull request #284 from domaframework/feature/sql-format-conditi…
xterao Jun 30, 2025
f569bc2
Add SQL conflict clause and do group block support
xterao Jun 30, 2025
f85d5da
Refactor SQL block structure and introduce new group blocks for impro…
xterao Jul 1, 2025
29fcf34
Refactor SQL block classes to remove unused conflict handling and str…
xterao Jul 1, 2025
5744c7b
Modify the formatting so that the equals sign (`=`) block in a bulk u…
xterao Jul 1, 2025
ae7dce7
Rename functions in SQL utility classes for consistency and clarity
xterao Jul 1, 2025
3247255
Implemented an override method to set child block properties into the…
xterao Jul 1, 2025
5a5d382
Merge pull request #290 from domaframework/chore/sql-format-refactor-…
xterao Jul 1, 2025
57ea031
Implemented an override method to set child block properties into the…
xterao Jul 1, 2025
e779778
Add tests and SQL files for insert conflict formatting
xterao Jul 1, 2025
7be9abb
Fix the line break and indentation for comma lines.
xterao Jul 1, 2025
a4a0da6
Add copyright notice to SQL block definition files
xterao Jul 1, 2025
88c1c99
Refactor SQL block classes to remove unused spacing builder parameters
xterao Jul 1, 2025
03edac5
Refactor CONFLICT keyword type branch handling
xterao Jul 1, 2025
52412a0
Add support for 'conflict', 'constraint', 'do', and 'nothing' keyword…
xterao Jul 2, 2025
503b77d
Merge pull request #293 from domaframework/feature/sql-format-support…
xterao Jul 2, 2025
062c45a
Add Support Query Group Blocks
xterao Jul 8, 2025
cc560c6
Support indentation and line-breaking for CTEs, and refactor related …
xterao Jul 8, 2025
34b2e5f
Refactor properties and method parameters.
xterao Jul 8, 2025
48c9db9
Refactor line-breaking logic in the processor:
xterao Jul 8, 2025
192d386
Implement utility class and revise the logic for generating parent-ch…
xterao Jul 8, 2025
6012e39
Add test cases for `CTE` clause support.
xterao Jul 8, 2025
3127277
Add keyword
xterao Jul 8, 2025
e85a32a
Duplicate Removal
xterao Jul 8, 2025
8ca4954
Fix formatting errors with spotless
xterao Jul 8, 2025
06e32c9
Merge pull request #301 from domaframework/feature/sql-format-support…
xterao Jul 8, 2025
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
15 changes: 14 additions & 1 deletion src/main/java/org/domaframework/doma/intellij/Sql.flex
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,24 @@ import org.domaframework.doma.intellij.psi.SqlTypes;
"as",
"asc",
"between",
"breadth",
"by",
"case",
"change",
"check",
"conflict",
"constraint",
"column",
"comment",
"create",
"cross",
"cycle",
"database",
"default",
"delete",
"desc",
"distinct",
"do",
"drop",
"else",
"end",
Expand All @@ -67,7 +72,9 @@ import org.domaframework.doma.intellij.psi.SqlTypes;
"like",
"limit",
"not",
"nothing",
"null",
"materialized",
"modify",
"offset",
"on",
Expand All @@ -77,7 +84,10 @@ import org.domaframework.doma.intellij.psi.SqlTypes;
"primary",
"references",
"rename",
"returning",
"recursive",
"right",
"search",
"select",
"set",
"table",
Expand All @@ -88,10 +98,12 @@ import org.domaframework.doma.intellij.psi.SqlTypes;
"union",
"unique",
"update",
"using",
"values",
"view",
"when",
"where"
"where",
"with"
);

// COLUMN DataTypes
Expand Down Expand Up @@ -124,6 +136,7 @@ import org.domaframework.doma.intellij.psi.SqlTypes;
);

private static boolean isKeyword(CharSequence word) {
// TODO Reads plugin settings and allows users to register arbitrary keywords
return KEYWORDS.contains(word.toString().toLowerCase());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.domaframework.doma.intellij.extension.getJavaClazz
import org.domaframework.doma.intellij.extension.psi.getClassAnnotation
import org.domaframework.doma.intellij.extension.psi.isDomain
import org.domaframework.doma.intellij.extension.psi.isEntity
import org.domaframework.doma.intellij.formatter.block.SqlBlock
import kotlin.reflect.KClass

object TypeUtil {
/**
Expand Down Expand Up @@ -94,4 +96,15 @@ object TypeUtil {
if (type == null) return false
return PsiTypeChecker.isBaseClassType(type) || DomaClassName.isOptionalWrapperType(type.canonicalText)
}

/**
* Determines whether the specified class instance matches.
*/
fun isExpectedClassType(
expectedClasses: List<KClass<*>>,
childBlock: SqlBlock?,
): Boolean =
expectedClasses.any { clazz ->
clazz.isInstance(childBlock)
}
}

This file was deleted.

Loading
Loading