Skip to content

Commit 10cb126

Browse files
committed
Clarification of return with null check
1 parent 690d649 commit 10cb126

File tree

8 files changed

+8
-11
lines changed

8 files changed

+8
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class GenerateSqlAction : AnAction() {
3939
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
4040
val project = e.project ?: return
4141
val file: PsiFile = currentFile ?: return
42-
getDaoClass(file) ?: return
42+
if (getDaoClass(file) == null) return
4343
val element = file.findElementAt(editor.caretModel.offset) ?: return
4444
val method = PsiTreeUtil.getParentOfType(element, PsiMethod::class.java) ?: return
4545

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class JumpToSQLFromDaoAction : AnAction() {
3636
currentFile = e.getData(CommonDataKeys.PSI_FILE) ?: return
3737
val file: PsiFile = currentFile ?: return
3838

39-
if (!isJavaOrKotlinFileType(file)) return
40-
getDaoClass(file) ?: return
39+
if (!isJavaOrKotlinFileType(file) || getDaoClass(file) == null) return
4140

4241
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
4342
val element = file.findElementAt(editor.caretModel.offset) ?: return

src/main/kotlin/org/domaframework/doma/intellij/action/sql/JumpToDaoFromSQLAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class JumpToDaoFromSQLAction : AnAction() {
3636
e.presentation.isEnabledAndVisible = false
3737
currentFile = e.getData(CommonDataKeys.PSI_FILE) ?: return
3838
val file = currentFile ?: return
39-
findDaoMethod(file) ?: return
39+
if (findDaoMethod(file) == null) return
4040
e.presentation.isEnabledAndVisible =
4141
isSupportFileType(file)
4242
}

src/main/kotlin/org/domaframework/doma/intellij/action/sql/JumpToDeclarationFromSqlAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class JumpToDeclarationFromSqlAction : AnAction() {
7676
file = currentFile ?: return
7777
element = file.findElementAt(countInjectionOffset(literal, caretOffset)) ?: return
7878
}
79-
findDaoMethod(file) ?: return
79+
if (findDaoMethod(file) == null) return
8080

8181
val elm = element ?: return
8282
val elementText = elm.text ?: ""

src/main/kotlin/org/domaframework/doma/intellij/gutter/dao/DaoMethodProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class DaoMethodProvider : RelatedItemLineMarkerProvider() {
7474
if (!isJavaOrKotlinFileType(e.containingFile) && !isFunction(e)) {
7575
return false
7676
}
77-
getDaoClass(e.containingFile) ?: return false
77+
if (getDaoClass(e.containingFile) == null) return false
7878
return e is PsiMethod
7979
}
8080

src/main/kotlin/org/domaframework/doma/intellij/gutter/sql/SqlLineMakerProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class SqlLineMakerProvider : RelatedItemLineMarkerProvider() {
5656
val identifier = e.firstChild ?: e
5757
val daoFile =
5858
findDaoFile(project, file)?.let {
59-
findDaoMethod(e.containingFile) ?: return
59+
if (findDaoMethod(e.containingFile) == null) return
6060
it
6161
} ?: return
6262

src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/inspector/DaoMethodVariableInspector.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ class DaoMethodVariableInspector : AbstractBaseJavaLocalInspectionTool() {
5959
override fun visitMethod(method: PsiMethod) {
6060
super.visitMethod(method)
6161
val file = method.containingFile
62-
if (!isJavaOrKotlinFileType(file)) return
63-
getDaoClass(file) ?: return
62+
if (!isJavaOrKotlinFileType(file) || getDaoClass(file) == null) return
6463

6564
val psiDaoMethod = PsiDaoMethod(method.project, method)
6665
if (!psiDaoMethod.useSqlAnnotation() && !psiDaoMethod.isUseSqlFileMethod()) return

src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/inspector/SqlFileExistInspector.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ class SqlFileExistInspector : AbstractBaseJavaLocalInspectionTool() {
5050
override fun visitMethod(method: PsiMethod) {
5151
super.visitMethod(method)
5252
val file = method.containingFile
53-
if (!isJavaOrKotlinFileType(file)) return
54-
getDaoClass(file) ?: return
53+
if (!isJavaOrKotlinFileType(file) || getDaoClass(file) == null) return
5554

5655
val psiDaoMethod = PsiDaoMethod(method.project, method)
5756
if (psiDaoMethod.isUseSqlFileMethod()) {

0 commit comments

Comments
 (0)