From feaaf5df8440914f84b70284664d82f8a58923fa Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 15 May 2018 16:21:14 +0300 Subject: [PATCH] Reformat: AbstractKotlinInspection --- .../inspections/AbstractKotlinInspection.kt | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/AbstractKotlinInspection.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/AbstractKotlinInspection.kt index 59d43d993ae..c07a238621e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/AbstractKotlinInspection.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/AbstractKotlinInspection.kt @@ -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? { 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.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.EMPTY_ARRAY @@ -99,7 +99,8 @@ fun Array.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) } } \ No newline at end of file