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
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: gradle/actions/wrapper-validation@v4

- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 17
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
uses: actions/checkout@v5

- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 17
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
uses: actions/checkout@v5

- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 17
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
ref: main

- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 17
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 17
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 17
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
ref: ${{ github.event.release.tag_name }}

- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 17
Expand Down
37 changes: 36 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

## [Unreleased]

## [2.3.0] - 2025-09-17

### New Features

- Enable SQL Annotation Conversion Action from DAO Methods and Control SQL File Opening ([#451])
- Check Parameter Types for Method Calls in Bind Variables ([#448])

### Bug Fixes

- Fix: Annotation Option Checks Respect Entity Inheritance ([#454])
- Fix Multiple Registration Error for SQL File to Annotation Conversion Actions ([#452])

### Maintenance

- Set Upper Limit for Plugin Support Versions ([#456])
- Refactor SQL Formatter Block Relations and Translate Comments ([#444])

### Dependency Updates

- Update actions/setup-java action to v5 ([#407])
- Update dependency org.jetbrains.kotlinx.kover to v0.9.2 ([#455])
- Update dependency org.jetbrains.kotlin.jvm to v2.2.20 ([#447])
- Update dependency org.jetbrains.intellij.platform to v2.9.0 ([#443])

## [2.2.1] - 2025-09-03

### Bug Fixes
Expand Down Expand Up @@ -358,7 +382,8 @@
- Rename SQL file directory when renaming DAO
- Change DAO package name or SQL file directory configuration when changing configuration

[Unreleased]: https://github.com/domaframework/doma-tools-for-intellij/compare/v2.2.1...HEAD
[Unreleased]: https://github.com/domaframework/doma-tools-for-intellij/compare/v2.3.0...HEAD
[2.3.0]: https://github.com/domaframework/doma-tools-for-intellij/compare/v2.2.1...v2.3.0
[2.2.1]: https://github.com/domaframework/doma-tools-for-intellij/compare/v2.2.0...v2.2.1
[2.2.0]: https://github.com/domaframework/doma-tools-for-intellij/compare/v2.1.2...v2.2.0
[2.1.2]: https://github.com/domaframework/doma-tools-for-intellij/compare/v2.1.1...v2.1.2
Expand Down Expand Up @@ -409,7 +434,16 @@
[#56]: https://github.com/domaframework/doma-tools-for-intellij/pull/56
[#49]: https://github.com/domaframework/doma-tools-for-intellij/pull/49
[#48]: https://github.com/domaframework/doma-tools-for-intellij/pull/48
[#456]: https://github.com/domaframework/doma-tools-for-intellij/pull/456
[#455]: https://github.com/domaframework/doma-tools-for-intellij/pull/455
[#454]: https://github.com/domaframework/doma-tools-for-intellij/pull/454
[#452]: https://github.com/domaframework/doma-tools-for-intellij/pull/452
[#451]: https://github.com/domaframework/doma-tools-for-intellij/pull/451
[#45]: https://github.com/domaframework/doma-tools-for-intellij/pull/45
[#448]: https://github.com/domaframework/doma-tools-for-intellij/pull/448
[#447]: https://github.com/domaframework/doma-tools-for-intellij/pull/447
[#444]: https://github.com/domaframework/doma-tools-for-intellij/pull/444
[#443]: https://github.com/domaframework/doma-tools-for-intellij/pull/443
[#442]: https://github.com/domaframework/doma-tools-for-intellij/pull/442
[#441]: https://github.com/domaframework/doma-tools-for-intellij/pull/441
[#440]: https://github.com/domaframework/doma-tools-for-intellij/pull/440
Expand All @@ -424,6 +458,7 @@
[#419]: https://github.com/domaframework/doma-tools-for-intellij/pull/419
[#417]: https://github.com/domaframework/doma-tools-for-intellij/pull/417
[#411]: https://github.com/domaframework/doma-tools-for-intellij/pull/411
[#407]: https://github.com/domaframework/doma-tools-for-intellij/pull/407
[#396]: https://github.com/domaframework/doma-tools-for-intellij/pull/396
[#394]: https://github.com/domaframework/doma-tools-for-intellij/pull/394
[#389]: https://github.com/domaframework/doma-tools-for-intellij/pull/389
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
pluginGroup = org.domaframework.doma.intellij
pluginName = Doma Tools for IntelliJ
pluginRepositoryUrl = https://github.com/domaframework/doma-tools-for-intellij
pluginVersion = 2.3.0-beta
pluginVersion = 2.3.1-beta

pluginSinceBuild=233
pluginUntilBuild=252.*

platformType = IC
platformVersion = 2024.3.1
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pluginVerifier = "1.395"
changelog = "2.4.0"
intelliJPlatform = "2.9.0"
kotlin = "2.2.20"
kover = "0.9.1"
kover = "0.9.2"
qodana = "2024.3.4"
grammarkit = "2022.3.2.2"

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 0 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac

CLASSPATH="\\\"\\\""


# Determine the Java command to use to start the JVM.
Expand Down Expand Up @@ -172,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )

JAVACMD=$( cygpath --unix "$JAVACMD" )

Expand Down Expand Up @@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"

Expand Down
3 changes: 1 addition & 2 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ goto fail
:execute
@rem Setup the command line

set CLASSPATH=


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright Doma Tools Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.domaframework.doma.intellij.action.dao

import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction
import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo
import com.intellij.codeInsight.intention.preview.IntentionPreviewUtils
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiMethod
import org.domaframework.doma.intellij.bundle.MessageBundle
import org.domaframework.doma.intellij.common.dao.getDaoClass
import org.domaframework.doma.intellij.common.psi.PsiDaoMethod
import org.domaframework.doma.intellij.common.util.PluginLoggerUtil

/**
* Intention action to convert @Sql annotation to SQL file
*/
class BulkConvertSqlAnnotationToFileAction : PsiElementBaseIntentionAction() {
override fun getFamilyName(): String = MessageBundle.message("bulk.convert.sql.annotation.to.file.family")

override fun getText(): String = MessageBundle.message("bulk.convert.sql.annotation.to.file.text")

override fun isAvailable(
project: Project,
editor: Editor?,
element: PsiElement,
): Boolean {
val daoClass = findDaoClassElement(element) ?: return false
if (getDaoClass(daoClass.containingFile) == null) return false

val methods = getTargetMethods(daoClass, project)

return methods.isNotEmpty()
}

override fun generatePreview(
project: Project,
editor: Editor,
file: PsiFile,
): IntentionPreviewInfo = IntentionPreviewInfo.EMPTY

override fun invoke(
project: Project,
editor: Editor?,
element: PsiElement,
) {
// Do nothing when previewing
if (IntentionPreviewUtils.isIntentionPreviewActive()) return
val startTime = System.nanoTime()
val daoClass = findDaoClassElement(element) ?: return
// Already checked in isAvailable, should not be null here
check(getDaoClass(daoClass.containingFile) != null) { "DAO class should be available" }

val methods = getTargetMethods(daoClass, project)

if (methods.isEmpty()) return

WriteCommandAction.runWriteCommandAction(project) {
methods.reversed().forEach { method ->
val converter = SqlAnnotationConverter(project, method)
converter.convertToSqlFile()
}
}

PluginLoggerUtil.countLogging(
className = this::class.java.simpleName,
actionName = "convertSqlAnnotationToFileBatch",
inputName = "IntentionAction",
start = startTime,
)
}

private fun getTargetMethods(
daoClass: PsiClass,
project: Project,
): List<PsiMethod> =
daoClass.methods.filter { method ->
val isSupportedDaoMethod = SqlAnnotationConverter.supportedTypes.any { it.getPsiAnnotation(method) != null }
val psiDaoMethod = PsiDaoMethod(project, method)
val isSqlAnnotationUsed = psiDaoMethod.useSqlAnnotation()
val hasSqlFileWithParent = psiDaoMethod.sqlFile?.parent != null

isSqlAnnotationUsed && !hasSqlFileWithParent && isSupportedDaoMethod
}

private fun findDaoClassElement(element: PsiElement): PsiClass? = element as? PsiClass ?: element.parent as? PsiClass
}
Loading
Loading