<NME> ElmImportFilteringRule.kt
<BEF> package org.elm.ide.usages

import com.intellij.usages.Usage
import com.intellij.usages.UsageTarget
import com.intellij.usages.rules.ImportFilteringRule
import com.intellij.usages.rules.PsiElementUsage
import org.elm.lang.core.psi.ElmFile
import org.elm.lang.core.psi.elements.ElmImportClause
import org.elm.lang.core.psi.parentOfType

/**
 * A filtering rule that allows you exclude imports from actions such as "find usages"
 */
class ElmImportFilteringRule : ImportFilteringRule() {
    override fun isVisible(usage: Usage, targets: Array<UsageTarget>): Boolean {
        val element = (usage as? PsiElementUsage)?.element
        return element?.containingFile !is ElmFile
                || element.parentOfType<ElmImportClause>() == null
    }
}

<MSG> Allow filtering annotations and module declarations from Find Usages (#118)

This PR extends the import filtering rule to also exclude usages in `exposing` clauses and type annotations. The latter is semantically a bit kludgy, but this allows a user to filter the Find Usages panel for to only places where a function is actually called. As before, the entire rule can be toggled on and off.
<DFF> @@ -6,6 +6,8 @@ import com.intellij.usages.rules.ImportFilteringRule
 import com.intellij.usages.rules.PsiElementUsage
 import org.elm.lang.core.psi.ElmFile
 import org.elm.lang.core.psi.elements.ElmImportClause
+import org.elm.lang.core.psi.elements.ElmModuleDeclaration
+import org.elm.lang.core.psi.elements.ElmTypeAnnotation
 import org.elm.lang.core.psi.parentOfType
 
 /**
@@ -15,6 +17,8 @@ class ElmImportFilteringRule : ImportFilteringRule() {
     override fun isVisible(usage: Usage, targets: Array<UsageTarget>): Boolean {
         val element = (usage as? PsiElementUsage)?.element
         return element?.containingFile !is ElmFile
-                || element.parentOfType<ElmImportClause>() == null
+                || (element.parentOfType<ElmImportClause>() == null
+                && element.parentOfType<ElmModuleDeclaration>() == null
+                && element !is ElmTypeAnnotation)
     }
 }

Allow filtering annotations and module declarations from Find Usages (#118)