Skip to content

Commit

Permalink
Make ArrayPrimitive rule honor the RequiresTypeResolution annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
BraisGabin committed Aug 3, 2022
1 parent 3bc81d2 commit ad311fd
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -11,10 +11,12 @@ import io.gitlab.arturbosch.detekt.api.internal.ActiveByDefault
import io.gitlab.arturbosch.detekt.api.internal.RequiresTypeResolution
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.com.intellij.psi.PsiFile
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtCallExpression
import org.jetbrains.kotlin.psi.KtCallableDeclaration
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.psi.KtTypeReference
import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType
Expand Down Expand Up @@ -51,9 +53,13 @@ class ArrayPrimitive(config: Config = Config.empty) : Rule(config) {
Debt.FIVE_MINS
)

override fun visitKtFile(file: KtFile) {
if (bindingContext == BindingContext.EMPTY) return
super.visitKtFile(file)
}

override fun visitCallExpression(expression: KtCallExpression) {
super.visitCallExpression(expression)
if (bindingContext == BindingContext.EMPTY) return
if (expression.calleeExpression?.text !in factoryMethodNames) return

val descriptor = expression.getResolvedCall(bindingContext)?.resultingDescriptor
Expand Down

0 comments on commit ad311fd

Please sign in to comment.