<NME> ElmLocalInspection.kt
<BEF> package org.elm.ide.inspections

import com.intellij.codeInspection.LocalInspectionTool
import com.intellij.codeInspection.LocalQuickFix
import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.psi.PsiElementVisitor
import org.elm.lang.core.psi.ElmPsiElement

abstract class ElmLocalInspection : LocalInspectionTool() {
    override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean) = object : PsiElementVisitor() {
        override fun visitElement(element: PsiElement) {
            super.visitElement(element)
            if (element is ElmPsiElement) {
                visitElement(element, holder, isOnTheFly)
            }
        }
    }

    abstract fun visitElement(element: ElmPsiElement, holder: ProblemsHolder, isOnTheFly: Boolean)
}

/**
 * A [LocalQuickFix] base class that takes care of some of the boilerplate
    protected inline fun quickFix(
            name: String,
            familyName: String = name,
            crossinline fix: (Project, ProblemDescriptor) -> Unit
    ) = object : LocalQuickFix {
        override fun getName(): String = name
        override fun getFamilyName(): String = familyName
        override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
            fix(project, descriptor)
        }
    override fun getName(): String = fixName
    override fun getFamilyName(): String = name
    override fun getPriority(): PriorityAction.Priority = fixPriority
    final override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
        this.applyFix(descriptor.psiElement ?: return, project)
    }

    abstract fun applyFix(element: PsiElement, project: Project)
}

<MSG> Improve sorting of menus in import and case branch inspections (#440)

Fixes #437, #431
<DFF> @@ -1,5 +1,6 @@
 package org.elm.ide.inspections
 
+import com.intellij.codeInsight.intention.PriorityAction
 import com.intellij.codeInspection.LocalInspectionTool
 import com.intellij.codeInspection.LocalQuickFix
 import com.intellij.codeInspection.ProblemDescriptor
@@ -24,10 +25,12 @@ abstract class ElmLocalInspection : LocalInspectionTool() {
     protected inline fun quickFix(
             name: String,
             familyName: String = name,
+            priority: PriorityAction.Priority = PriorityAction.Priority.NORMAL,
             crossinline fix: (Project, ProblemDescriptor) -> Unit
-    ) = object : LocalQuickFix {
+    ): LocalQuickFix = object : LocalQuickFix, PriorityAction {
         override fun getName(): String = name
         override fun getFamilyName(): String = familyName
+        override fun getPriority(): PriorityAction.Priority = priority
         override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
             fix(project, descriptor)
         }

Improve sorting of menus in import and case branch inspections (#440)