WEAK_WARNING -> GENERIC_ERROR_OR_WARNING in three inspections

Now there inspection use configured highlight level instead of
forced weak warning: null check to safe call, reformat, sort modifiers
This commit is contained in:
Mikhail Glukhikh
2018-02-20 19:38:23 +03:00
parent 17e64ebae0
commit acd8edaa9c
3 changed files with 17 additions and 13 deletions
@@ -20,14 +20,16 @@ import org.jetbrains.kotlin.types.TypeUtils
class NullChecksToSafeCallInspection : AbstractKotlinInspection() { class NullChecksToSafeCallInspection : AbstractKotlinInspection() {
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession) = override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession) =
binaryExpressionVisitor { expression -> binaryExpressionVisitor { expression ->
if (isNullChecksToSafeCallFixAvailable(expression)) { if (isNullChecksToSafeCallFixAvailable(expression)) {
holder.registerProblem(expression, holder.registerProblem(
"Null-checks replaceable with safe-calls", expression,
ProblemHighlightType.WEAK_WARNING, "Null-checks replaceable with safe-calls",
NullChecksToSafeCallCheckFix()) ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
} NullChecksToSafeCallCheckFix()
)
} }
}
private class NullChecksToSafeCallCheckFix : LocalQuickFix { private class NullChecksToSafeCallCheckFix : LocalQuickFix {
override fun getName() = "Replace chained null-checks with safe-calls" override fun getName() = "Replace chained null-checks with safe-calls"
@@ -52,11 +52,13 @@ class ReformatInspection : LocalInspectionTool() {
}.filterNotNull() }.filterNotNull()
return elements.map { return elements.map {
ProblemDescriptorImpl(it, it, ProblemDescriptorImpl(
"File is not properly formatted", it, it,
arrayOf(ReformatQuickFix), "File is not properly formatted",
ProblemHighlightType.WEAK_WARNING, false, null, arrayOf(ReformatQuickFix),
isOnTheFly) ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false, null,
isOnTheFly
)
}.toTypedArray() }.toTypedArray()
} }
@@ -44,7 +44,7 @@ class SortModifiersInspection : AbstractKotlinInspection(), CleanupLocalInspecti
holder.registerProblem( holder.registerProblem(
list, list,
message, message,
ProblemHighlightType.WEAK_WARNING, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
SortModifiersFix(sortedModifiers) SortModifiersFix(sortedModifiers)
) )
} }