Files
openide/plugins/devkit/devkit-kotlin-tests/testData/inspections/statefulEp/CapturedFromOuterClass.kt
Karol Lewandowski 73412b84ed IDEA-316821: Support anonymous/inner class fields captured from context in StatefulEpInspection for Kotlin code
GitOrigin-RevId: 7f211c1b5bca9bdcb1f5281cd6717ad58f3751c3
2023-04-18 17:47:46 +00:00

58 lines
1.8 KiB
Kotlin

import com.intellij.codeInspection.LocalQuickFix
import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiReference
class CapturedFromOuterClass(a: PsiElement?, b: String?) : LocalQuickFix {
val <warning descr="Potential memory leak: don't hold PsiElement, use SmartPsiElementPointer instead. See also LocalQuickFixOnPsiElement.">pe</warning>: PsiElement?
val <warning descr="Do not use PsiReference as a field in quick-fix">r</warning>: PsiReference?
var <warning descr="Do not use Project as a field in quick-fix">p</warning>: Project?
val pf: Project?
init {
pe = null
r = null
pf = null
p = pf
@Suppress("UNUSED_VARIABLE")
val fix: LocalQuickFix = object : LocalQuickFix {
private fun a(a1: PsiElement, b1: String) {
any(<warning descr="Potential memory leak: don't hold PsiElement, use SmartPsiElementPointer instead. See also LocalQuickFixOnPsiElement.">a</warning>)
any(b)
any(a1)
any(b1)
}
}
@Suppress("UNUSED_VARIABLE")
val notFix: Any = object : Any() {
private fun a(a1: PsiElement, b1: String) {
any(a)
any(b)
any(a1)
any(b1)
}
}
}
fun test(a: PsiElement?, b: String?) {
open class B(@Suppress("UNUSED_PARAMETER") aa: PsiElement?) : LocalQuickFix {
private fun a(a1: PsiElement, b1: String) {
any(<warning descr="Potential memory leak: don't hold PsiElement, use SmartPsiElementPointer instead. See also LocalQuickFixOnPsiElement.">a</warning>)
any(b)
any(a1)
any(b1)
}
}
@Suppress("UNUSED_VARIABLE")
val b1 = object : B(a) {}
}
}
private fun any(@Suppress("UNUSED_PARAMETER") any: Any?) {
// any
}