Refactoring: Extract registerWithElementsUnwrapped() function
This commit is contained in:
+16
-4
@@ -17,11 +17,9 @@
|
||||
package org.jetbrains.kotlin.idea.inspections
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel
|
||||
import com.intellij.codeInspection.CustomSuppressableInspectionTool
|
||||
import com.intellij.codeInspection.LocalInspectionTool
|
||||
import com.intellij.codeInspection.SuppressIntentionAction
|
||||
import com.intellij.codeInspection.SuppressManager
|
||||
import com.intellij.codeInspection.*
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.asJava.unwrapped
|
||||
import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.idea.highlighter.createSuppressWarningActions
|
||||
@@ -64,3 +62,17 @@ private fun toSeverity(highlightDisplayLevel: HighlightDisplayLevel): Severity
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun Array<ProblemDescriptor>.registerWithElementsUnwrapped(holder: ProblemsHolder, isOnTheFly: Boolean) {
|
||||
forEach {
|
||||
@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
|
||||
)
|
||||
holder.registerProblem(descriptor)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user