Reformat: AbstractKotlinInspection
This commit is contained in:
+19
-18
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.idea.inspections
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel
|
||||
import com.intellij.codeInspection.*
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
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.idea.highlighter.createSuppressWarningActions
|
||||
|
||||
abstract class AbstractKotlinInspection: LocalInspectionTool(), CustomSuppressableInspectionTool {
|
||||
abstract class AbstractKotlinInspection : LocalInspectionTool(), CustomSuppressableInspectionTool {
|
||||
override fun getSuppressActions(element: PsiElement?): Array<SuppressIntentionAction>? {
|
||||
if (element == null) return emptyArray()
|
||||
|
||||
@@ -49,22 +48,22 @@ abstract class AbstractKotlinInspection: LocalInspectionTool(), CustomSuppressab
|
||||
protected open val suppressionKey: String get() = this.shortName.removePrefix("Kotlin")
|
||||
|
||||
protected fun ProblemsHolder.registerProblemWithoutOfflineInformation(
|
||||
element: PsiElement,
|
||||
description: String,
|
||||
isOnTheFly: Boolean,
|
||||
highlightType: ProblemHighlightType,
|
||||
vararg fixes: LocalQuickFix
|
||||
element: PsiElement,
|
||||
description: String,
|
||||
isOnTheFly: Boolean,
|
||||
highlightType: ProblemHighlightType,
|
||||
vararg fixes: LocalQuickFix
|
||||
) {
|
||||
registerProblemWithoutOfflineInformation(element, description, isOnTheFly, highlightType, null, *fixes)
|
||||
}
|
||||
|
||||
protected fun ProblemsHolder.registerProblemWithoutOfflineInformation(
|
||||
element: PsiElement,
|
||||
description: String,
|
||||
isOnTheFly: Boolean,
|
||||
highlightType: ProblemHighlightType,
|
||||
range: TextRange?,
|
||||
vararg fixes: LocalQuickFix
|
||||
element: PsiElement,
|
||||
description: String,
|
||||
isOnTheFly: Boolean,
|
||||
highlightType: ProblemHighlightType,
|
||||
range: TextRange?,
|
||||
vararg fixes: LocalQuickFix
|
||||
) {
|
||||
if (!isOnTheFly && highlightType == ProblemHighlightType.INFORMATION) return
|
||||
val problemDescriptor = manager.createProblemDescriptor(element, range, description, highlightType, isOnTheFly, *fixes)
|
||||
@@ -72,7 +71,7 @@ abstract class AbstractKotlinInspection: LocalInspectionTool(), CustomSuppressab
|
||||
}
|
||||
}
|
||||
|
||||
fun toSeverity(highlightDisplayLevel: HighlightDisplayLevel): Severity {
|
||||
fun toSeverity(highlightDisplayLevel: HighlightDisplayLevel): Severity {
|
||||
return when (highlightDisplayLevel) {
|
||||
HighlightDisplayLevel.DO_NOT_SHOW -> Severity.INFO
|
||||
|
||||
@@ -89,9 +88,10 @@ fun toSeverity(highlightDisplayLevel: HighlightDisplayLevel): Severity {
|
||||
|
||||
@Suppress("unused")
|
||||
fun Array<ProblemDescriptor>.registerWithElementsUnwrapped(
|
||||
holder: ProblemsHolder,
|
||||
isOnTheFly: Boolean,
|
||||
quickFixSubstitutor: ((LocalQuickFix, PsiElement) -> LocalQuickFix?)? = null) {
|
||||
holder: ProblemsHolder,
|
||||
isOnTheFly: Boolean,
|
||||
quickFixSubstitutor: ((LocalQuickFix, PsiElement) -> LocalQuickFix?)? = null
|
||||
) {
|
||||
forEach { problem ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val originalFixes = problem.fixes as? Array<LocalQuickFix> ?: LocalQuickFix.EMPTY_ARRAY
|
||||
@@ -99,7 +99,8 @@ fun Array<ProblemDescriptor>.registerWithElementsUnwrapped(
|
||||
val newFixes = quickFixSubstitutor?.let { subst ->
|
||||
originalFixes.mapNotNull { subst(it, newElement) }.toTypedArray()
|
||||
} ?: 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user