Spring Support: Implement Spring @Autowired inspection
#KT-12278 Fixed #KT-12147 Fixed #KT-12366 Fixed #KT-12122 Fixed
This commit is contained in:
@@ -72,9 +72,10 @@ class KtLightAnnotation(
|
||||
}
|
||||
|
||||
override fun getReference() = references.singleOrNull()
|
||||
override fun getReferences() = ReferenceProvidersRegistry.getReferencesFromProviders(delegate, PsiReferenceService.Hints.NO_HINTS)
|
||||
override fun getReferences() = originalExpression?.references ?: PsiReference.EMPTY_ARRAY
|
||||
override fun getLanguage() = KotlinLanguage.INSTANCE
|
||||
override fun getNavigationElement() = originalExpression
|
||||
override fun getTextRange() = originalExpression?.textRange ?: TextRange.EMPTY_RANGE
|
||||
}
|
||||
|
||||
inner class LightArrayInitializerValue(private val delegate: PsiArrayInitializerMemberValue) : PsiArrayInitializerMemberValue by delegate {
|
||||
|
||||
@@ -52,6 +52,8 @@ sealed class KtLightFieldImpl(
|
||||
|
||||
override fun getContainingClass() = containingClass
|
||||
|
||||
override fun getContainingFile() = containingClass.containingFile
|
||||
|
||||
override fun getType() = clsDelegate.type
|
||||
|
||||
override fun getTypeElement() = clsDelegate.typeElement
|
||||
|
||||
@@ -17,19 +17,32 @@
|
||||
package org.jetbrains.kotlin.asJava
|
||||
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiCompiledElement
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiNameIdentifierOwner
|
||||
import com.intellij.psi.impl.light.LightIdentifier
|
||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
||||
import org.jetbrains.kotlin.psi.KtSecondaryConstructor
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||
|
||||
class KtLightIdentifier(
|
||||
private val lightOwner: PsiNameIdentifierOwner,
|
||||
private val ktDeclaration: KtNamedDeclaration?
|
||||
) : LightIdentifier(lightOwner.manager, ktDeclaration?.name ?: "") {
|
||||
) : LightIdentifier(lightOwner.manager, ktDeclaration?.name ?: ""), PsiCompiledElement {
|
||||
val origin: PsiElement?
|
||||
get() = ktDeclaration?.nameIdentifier
|
||||
get() = when (ktDeclaration) {
|
||||
is KtSecondaryConstructor -> ktDeclaration.getConstructorKeyword()
|
||||
is KtPrimaryConstructor -> ktDeclaration.getConstructorKeyword()
|
||||
?: ktDeclaration.valueParameterList
|
||||
?: ktDeclaration.containingClassOrObject?.nameIdentifier
|
||||
else -> ktDeclaration?.nameIdentifier
|
||||
}
|
||||
|
||||
override fun getMirror() = ((lightOwner as? KtLightElement<*, *>)?.clsDelegate as? PsiNameIdentifierOwner)?.nameIdentifier
|
||||
|
||||
override fun isPhysical() = true
|
||||
override fun getParent() = lightOwner
|
||||
override fun getTextRange() = ktDeclaration?.nameIdentifier?.textRange ?: TextRange.EMPTY_RANGE
|
||||
override fun getContainingFile() = lightOwner.containingFile
|
||||
override fun getTextRange() = origin?.textRange ?: TextRange.EMPTY_RANGE
|
||||
}
|
||||
@@ -109,7 +109,12 @@ fun KtTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
|
||||
|
||||
// Returns original declaration if given PsiElement is a Kotlin light element, and element itself otherwise
|
||||
val PsiElement.unwrapped: PsiElement?
|
||||
get() = if (this is KtLightElement<*, *>) kotlinOrigin else this
|
||||
get() = when {
|
||||
this is KtLightElement<*, *> -> kotlinOrigin
|
||||
this is KtLightIdentifier -> origin
|
||||
this is KtLightAnnotation.LightExpressionValue -> originalExpression
|
||||
else -> this
|
||||
}
|
||||
|
||||
val PsiElement.namedUnwrappedElement: PsiNamedElement?
|
||||
get() = unwrapped?.getNonStrictParentOfType<PsiNamedElement>()
|
||||
|
||||
Reference in New Issue
Block a user