mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Redundant 'inner' modifier: report when call objects declared in the containing class
GitOrigin-RevId: 32446eba5a14ef77028c5bb82bef4225b28da1f3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
146bd19bbc
commit
818837fc2f
+4
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClass
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isSubclassOf
|
||||
@@ -61,6 +62,9 @@ class RedundantInnerClassModifierInspection : AbstractKotlinInspection() {
|
||||
if (reference is PsiClass && reference.parent is PsiClass) {
|
||||
return@anyDescendantOfType reference.getJavaClassDescriptor()?.isInner == true
|
||||
}
|
||||
if (reference is KtObjectDeclaration || (reference as? KtDeclaration)?.containingClassOrObject is KtObjectDeclaration) {
|
||||
return@anyDescendantOfType false
|
||||
}
|
||||
val referenceContainingClass = reference?.getStrictParentOfType<KtClass>()
|
||||
if (referenceContainingClass != null) {
|
||||
if (referenceContainingClass == targetClass) return@anyDescendantOfType false
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
<caret>inner class InnerM {
|
||||
val v = Test
|
||||
val foo = Test.foo
|
||||
}
|
||||
companion object {
|
||||
const val foo = 1
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
class InnerM {
|
||||
val v = Test
|
||||
val foo = Test.foo
|
||||
}
|
||||
companion object {
|
||||
const val foo = 1
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
<caret>inner class InnerM {
|
||||
val o = O
|
||||
val foo = O.foo
|
||||
}
|
||||
object O {
|
||||
const val foo = 1
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
class InnerM {
|
||||
val o = O
|
||||
val foo = O.foo
|
||||
}
|
||||
object O {
|
||||
const val foo = 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user