Skip to content

Commit

Permalink
Supporting subscribe for Enum when statically imported #10
Browse files Browse the repository at this point in the history
  • Loading branch information
thsaravana committed Aug 22, 2019
1 parent b7ff2e4 commit 3441cd2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ compileTestKotlin {

patchPluginXml {
changeNotes """
- Support for `@file:JvmName()` <br>
- Performance improvement <br>
- Option to view usages in "Find" tool window <br>
- Improved the UI of the usages popup <br>
- Support for Enums <br>
- Support for `@file:JvmName()` <br>
- Performance improvement <br>
"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ReadAction
import com.intellij.openapi.editor.markup.GutterIconRenderer.Alignment.RIGHT
import com.intellij.openapi.util.IconLoader
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiEnumConstant
import com.intellij.psi.impl.source.PsiClassReferenceType
import com.intellij.ui.awt.RelativePoint
import com.intellij.usageView.UsageInfo
Expand Down Expand Up @@ -75,9 +77,17 @@ private class SubscribeLineMarkerInfo(
val elementToSearch =
(uElement.uastParameters[0].type as PsiClassReferenceType).reference.resolve()
if (elementToSearch != null) {
usages = search(elementToSearch)
.filter(UsageInfo::isPost)
.map(::UsageInfo2UsageAdapter)
val psiClassElement = elementToSearch.toUElement()
usages = if((psiClassElement as? PsiClass)?.isEnum == true) {
val elementsToSearch = psiClassElement.allFields.filterIsInstance<PsiEnumConstant>()
search(elementsToSearch)
.filter(UsageInfo::isPost)
.map(::UsageInfo2UsageAdapter)
} else {
search(elementToSearch)
.filter(UsageInfo::isPost)
.map(::UsageInfo2UsageAdapter)
}
}
}
ApplicationManager.getApplication().invokeLater {
Expand Down

0 comments on commit 3441cd2

Please sign in to comment.