Spring Support: Implement Spring @Autowired inspection

#KT-12278 Fixed
 #KT-12147 Fixed
 #KT-12366 Fixed
 #KT-12122 Fixed
This commit is contained in:
Alexey Sedunov
2016-05-17 18:19:46 +03:00
parent 36f3d30250
commit 85d07e5f6d
31 changed files with 820 additions and 129 deletions
@@ -63,16 +63,18 @@ private fun toSeverity(highlightDisplayLevel: HighlightDisplayLevel): Severity
}
@Suppress("unused")
fun Array<ProblemDescriptor>.registerWithElementsUnwrapped(holder: ProblemsHolder, isOnTheFly: Boolean) {
forEach {
fun Array<ProblemDescriptor>.registerWithElementsUnwrapped(
holder: ProblemsHolder,
isOnTheFly: Boolean,
quickFixSubstitutor: ((LocalQuickFix, PsiElement) -> LocalQuickFix?)? = null) {
forEach { problem ->
@Suppress("UNCHECKED_CAST")
val descriptor = holder.manager.createProblemDescriptor(
it.psiElement.unwrapped ?: it.psiElement,
it.descriptionTemplate,
isOnTheFly,
it.fixes as? Array<LocalQuickFix> ?: LocalQuickFix.EMPTY_ARRAY,
it.highlightType
)
val originalFixes = problem.fixes as? Array<LocalQuickFix> ?: LocalQuickFix.EMPTY_ARRAY
val newElement = problem.psiElement.unwrapped ?: return@forEach
val newFixes = quickFixSubstitutor?.let { subst ->
originalFixes.mapNotNull { subst(it, newElement) }.toTypedArray()
} ?: originalFixes
val descriptor = holder.manager.createProblemDescriptor(newElement, problem.descriptionTemplate, isOnTheFly, newFixes, problem.highlightType)
holder.registerProblem(descriptor)
}
}