Skip to content

Commit 41dbfa2

Browse files
committed
Modify the condition to allow jumping to the target DAO method after generating an annotation from a file.
1 parent 8a93d2d commit 41dbfa2

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/main/kotlin/org/domaframework/doma/intellij/action/dao/SqlAnnotationConverter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class SqlAnnotationConverter(
238238
if (newDocument != null) {
239239
documentManager.doPostponedOperationsAndUnblockDocument(newDocument)
240240
}
241-
jumpToDaoMethod(project, psiDaoMethod.sqlFile?.name ?: return, newDaoFile.virtualFile)
241+
jumpToDaoMethod(project, psiDaoMethod.sqlFile?.nameWithoutExtension ?: return, newDaoFile.virtualFile)
242242
}
243243

244244
private fun generateSqlFileWithContent(content: String) {
@@ -274,7 +274,7 @@ class SqlAnnotationConverter(
274274
}
275275

276276
// Delete the file
277-
virtualFile.delete(project)
277+
virtualFile.delete(null)
278278
}
279279

280280
private fun formatSql(sqlFile: PsiFile) {

src/main/kotlin/org/domaframework/doma/intellij/common/dao/JumpActionFunctions.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ fun findUseSqlDaoMethod(
8181
val targetMethod =
8282
methods.firstOrNull { method ->
8383
val psiDaoMethod = PsiDaoMethod(file.project, method)
84-
psiDaoMethod.isUseSqlFileMethod()
84+
// When jumping after generating an annotation from an SQL file,
85+
// since the SQL annotation is already present, allow jumping even if the SQL file also exists.
86+
psiDaoMethod.isUseSqlFileMethod() || (psiDaoMethod.useSqlAnnotation() && psiDaoMethod.sqlFile != null)
8587
}
8688
return targetMethod
8789
break

src/main/kotlin/org/domaframework/doma/intellij/formatter/processor/InjectionSqlFormatter.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class InjectionSqlFormatter(
6868
?.firstOrNull()
6969
?.first as? PsiFile ?: return
7070

71-
// format(task.isOriginalTextBlock, task.formattedText, injectionFile, removeSpace)
7271
val formattedText =
7372
if (!task.isOriginalTextBlock) {
7473
val result =

0 commit comments

Comments
 (0)