Spring Support: Show autowiring candidates line markers for @Autowired-annotated constructors and constructor parameters
#KT-12120 Fixed
This commit is contained in:
+11
-2
@@ -25,7 +25,9 @@ import com.intellij.psi.util.CachedValuesManager
|
||||
import com.intellij.psi.util.PsiModificationTracker
|
||||
import com.intellij.util.ArrayUtil
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
@@ -93,9 +95,16 @@ internal fun computeAnnotations(lightElement: PsiModifierList,
|
||||
val cacheManager = CachedValuesManager.getManager(lightElement.project)
|
||||
return cacheManager.createCachedValue<Array<out PsiAnnotation>>(
|
||||
{
|
||||
val declaration = (lightElement.parent as? KtLightElement<*, *>)?.kotlinOrigin as? KtDeclaration
|
||||
val lightOwner = lightElement.parent as? KtLightElement<*, *>
|
||||
val declaration = lightOwner?.kotlinOrigin as? KtDeclaration
|
||||
val descriptor = declaration?.let { LightClassGenerationSupport.getInstance(lightElement.project).resolveToDescriptor(it) }
|
||||
val ktAnnotations = descriptor?.annotations?.getAllAnnotations() ?: emptyList()
|
||||
val annotatedDescriptor = when {
|
||||
descriptor !is PropertyDescriptor || lightOwner !is KtLightMethod -> descriptor
|
||||
JvmAbi.isGetterName(lightOwner.name) -> descriptor.getter
|
||||
JvmAbi.isSetterName(lightOwner.name) -> descriptor.setter
|
||||
else -> descriptor
|
||||
}
|
||||
val ktAnnotations = annotatedDescriptor?.annotations?.getAllAnnotations() ?: emptyList()
|
||||
var nextIndex = 0
|
||||
val result = delegate.annotations
|
||||
.map { clsAnnotation ->
|
||||
|
||||
@@ -100,6 +100,9 @@ public class KtLightParameter extends LightParameter implements KtLightDeclarati
|
||||
else if (declaration instanceof KtProperty) {
|
||||
setter = ((KtProperty) declaration).getSetter();
|
||||
}
|
||||
else if (declaration instanceof KtParameter) {
|
||||
return (KtParameter) declaration;
|
||||
}
|
||||
|
||||
return setter != null ? setter.getParameter() : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user