Reformat: AbstractKotlinInspection
This commit is contained in:
+5
-4
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.idea.inspections
|
|||||||
|
|
||||||
import com.intellij.codeHighlighting.HighlightDisplayLevel
|
import com.intellij.codeHighlighting.HighlightDisplayLevel
|
||||||
import com.intellij.codeInspection.*
|
import com.intellij.codeInspection.*
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
|
||||||
import com.intellij.openapi.util.TextRange
|
import com.intellij.openapi.util.TextRange
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.asJava.unwrapped
|
import org.jetbrains.kotlin.asJava.unwrapped
|
||||||
@@ -26,7 +25,7 @@ import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
|
|||||||
import org.jetbrains.kotlin.diagnostics.Severity
|
import org.jetbrains.kotlin.diagnostics.Severity
|
||||||
import org.jetbrains.kotlin.idea.highlighter.createSuppressWarningActions
|
import org.jetbrains.kotlin.idea.highlighter.createSuppressWarningActions
|
||||||
|
|
||||||
abstract class AbstractKotlinInspection: LocalInspectionTool(), CustomSuppressableInspectionTool {
|
abstract class AbstractKotlinInspection : LocalInspectionTool(), CustomSuppressableInspectionTool {
|
||||||
override fun getSuppressActions(element: PsiElement?): Array<SuppressIntentionAction>? {
|
override fun getSuppressActions(element: PsiElement?): Array<SuppressIntentionAction>? {
|
||||||
if (element == null) return emptyArray()
|
if (element == null) return emptyArray()
|
||||||
|
|
||||||
@@ -91,7 +90,8 @@ fun toSeverity(highlightDisplayLevel: HighlightDisplayLevel): Severity {
|
|||||||
fun Array<ProblemDescriptor>.registerWithElementsUnwrapped(
|
fun Array<ProblemDescriptor>.registerWithElementsUnwrapped(
|
||||||
holder: ProblemsHolder,
|
holder: ProblemsHolder,
|
||||||
isOnTheFly: Boolean,
|
isOnTheFly: Boolean,
|
||||||
quickFixSubstitutor: ((LocalQuickFix, PsiElement) -> LocalQuickFix?)? = null) {
|
quickFixSubstitutor: ((LocalQuickFix, PsiElement) -> LocalQuickFix?)? = null
|
||||||
|
) {
|
||||||
forEach { problem ->
|
forEach { problem ->
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val originalFixes = problem.fixes as? Array<LocalQuickFix> ?: LocalQuickFix.EMPTY_ARRAY
|
val originalFixes = problem.fixes as? Array<LocalQuickFix> ?: LocalQuickFix.EMPTY_ARRAY
|
||||||
@@ -99,7 +99,8 @@ fun Array<ProblemDescriptor>.registerWithElementsUnwrapped(
|
|||||||
val newFixes = quickFixSubstitutor?.let { subst ->
|
val newFixes = quickFixSubstitutor?.let { subst ->
|
||||||
originalFixes.mapNotNull { subst(it, newElement) }.toTypedArray()
|
originalFixes.mapNotNull { subst(it, newElement) }.toTypedArray()
|
||||||
} ?: originalFixes
|
} ?: originalFixes
|
||||||
val descriptor = holder.manager.createProblemDescriptor(newElement, problem.descriptionTemplate, isOnTheFly, newFixes, problem.highlightType)
|
val descriptor =
|
||||||
|
holder.manager.createProblemDescriptor(newElement, problem.descriptionTemplate, isOnTheFly, newFixes, problem.highlightType)
|
||||||
holder.registerProblem(descriptor)
|
holder.registerProblem(descriptor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user