Skip to content

Commit

Permalink
Fixing isPrivateOrParameterInPrivateMethod missing issue. Fixes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
thsaravana committed Feb 13, 2021
1 parent e6b20c9 commit 39fbbe2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.madrapps.dagger.validation

import com.intellij.psi.PsiElement
import com.madrapps.dagger.utils.*
import org.jetbrains.kotlin.asJava.classes.isPrivateOrParameterInPrivateMethod
import org.jetbrains.uast.*

object InjectProblem : Problem {
Expand Down
13 changes: 11 additions & 2 deletions src/main/kotlin/com/madrapps/dagger/validation/Problem.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.madrapps.dagger.validation

import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMethod
import com.intellij.psi.PsiModifierListOwner
import com.intellij.psi.PsiParameter
import com.intellij.psi.impl.source.PsiClassReferenceType
import com.madrapps.dagger.utils.*
import org.jetbrains.kotlin.asJava.classes.isPrivateOrParameterInPrivateMethod
import org.jetbrains.uast.UMethod
import org.jetbrains.uast.getContainingUClass

Expand Down Expand Up @@ -82,4 +84,11 @@ fun UMethod.validateModuleClass(range: PsiElement, error: String): List<Problem.
return if (!uClass.isModule) {
range.errors(error)
} else emptyList()
}
}

fun PsiModifierListOwner.isPrivateOrParameterInPrivateMethod(): Boolean {
if (hasModifierProperty("private")) return true
if (this !is PsiParameter) return false
val parentMethod = declarationScope as? PsiMethod ?: return false
return parentMethod.hasModifierProperty("private")
}

0 comments on commit 39fbbe2

Please sign in to comment.