Skip to content

Commit

Permalink
Pushing changes to 2018.1 branch (v 0.4.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
thsaravana committed Aug 27, 2019
1 parent afcd138 commit 238d561
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 61 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.4.9'
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
id 'org.jetbrains.kotlin.jvm' version '1.2.31'
}

group 'com.madrapps'
version '0.4.2.2018.2'
version '0.4.2.2018.1'

sourceCompatibility = 1.8

Expand All @@ -22,7 +22,7 @@ dependencies {

// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version '2018.2'
version '2018.1'
plugins 'Kotlin'
}
compileKotlin {
Expand All @@ -34,7 +34,7 @@ compileTestKotlin {

patchPluginXml {
changeNotes """
- Add breakpoints to `post` or `subscribe` in a single click <br>
- Add breakpoints to <i>>post</i> or <i>subscribe</i> in a single click <br>
- Option to clear added breakpoints as well <br>
"""
}
4 changes: 2 additions & 2 deletions src/main/kotlin/com/madrapps/eventbus/PopUpView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.actionSystem.IdeActions.ACTION_FIND_USAGES
import com.intellij.openapi.editor.Document
import com.intellij.openapi.ui.popup.JBPopup
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.openapi.ui.popup.PopupChooserBuilder
import com.intellij.psi.PsiDocumentManager
import com.intellij.ui.ScrollingUtil
import com.intellij.ui.SimpleColoredComponent
Expand Down Expand Up @@ -87,7 +87,7 @@ private fun showTablePopUp(usages: List<Usage>, columnInfos: Array<MyColumnInfo>
autoResizeMode = JTable.AUTO_RESIZE_LAST_COLUMN
}

val builder = JBPopupFactory.getInstance().createPopupChooserBuilder(table)
val builder = PopupChooserBuilder(table)
.setTitle(getTitle(usages))
.setMovable(true)
.setResizable(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.intellij.codeHighlighting.Pass
import com.intellij.codeInsight.daemon.LineMarkerInfo
import com.intellij.codeInsight.daemon.LineMarkerProvider
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.PsiClassType
Expand All @@ -13,7 +12,6 @@ import com.intellij.psi.PsiExpressionStatement
import com.intellij.ui.awt.RelativePoint
import com.intellij.usageView.UsageInfo
import com.intellij.usages.UsageInfo2UsageAdapter
import com.intellij.util.concurrency.AppExecutorUtil
import com.madrapps.eventbus.getCallExpression
import com.madrapps.eventbus.getParentOfTypeCallExpression
import com.madrapps.eventbus.search
Expand Down Expand Up @@ -51,7 +49,7 @@ internal fun UsageInfo.isPost(): Boolean {
return false
}

private fun UCallExpression.isPost() : Boolean {
private fun UCallExpression.isPost(): Boolean {
return receiverType?.canonicalText == "org.greenrobot.eventbus.EventBus"
&& (methodName == "post" || methodName == "postSticky")
}
Expand All @@ -65,33 +63,31 @@ private class PostLineMarkerInfo(
Pass.LINE_MARKERS,
null,
{ event, element ->
ReadAction.nonBlocking {
var usages = emptyList<UsageInfo2UsageAdapter>()
val uElement = element.toUElement()?.getParentOfType<UCallExpression>()
if (uElement != null) {
val argument = uElement.valueArguments.firstOrNull()
val elementsToSearch: List<PsiElement> = if (argument is UQualifiedReferenceExpression) {
val sourcePsi = (argument.receiver as USimpleNameReferenceExpression).sourcePsi
sourcePsi?.references?.mapNotNull { it.resolve() } ?: emptyList()
} else {
val resolve = (argument?.getExpressionType() as PsiClassType).resolve()
if (resolve != null) {
listOf(resolve)
} else emptyList()
}
val collection = search(elementsToSearch)
usages = collection
.filter(UsageInfo::isSubscribe)
.map(::UsageInfo2UsageAdapter)
var usages = emptyList<UsageInfo2UsageAdapter>()
val uElement = element.toUElement()?.getParentOfType<UCallExpression>()
if (uElement != null) {
val argument = uElement.valueArguments.firstOrNull()
val elementsToSearch: List<PsiElement> = if (argument is UQualifiedReferenceExpression) {
val sourcePsi = (argument.receiver as USimpleNameReferenceExpression).sourcePsi
sourcePsi?.references?.mapNotNull { it.resolve() } ?: emptyList()
} else {
val resolve = (argument?.getExpressionType() as PsiClassType).resolve()
if (resolve != null) {
listOf(resolve)
} else emptyList()
}
ApplicationManager.getApplication().invokeLater {
if (usages.size == 1) {
usages.first().navigate(true)
} else {
showPostUsages(usages, RelativePoint(event))
}
val collection = search(elementsToSearch)
usages = collection
.filter(UsageInfo::isSubscribe)
.map(::UsageInfo2UsageAdapter)
}
ApplicationManager.getApplication().invokeLater {
if (usages.size == 1) {
usages.first().navigate(true)
} else {
showPostUsages(usages, RelativePoint(event))
}
}.inSmartMode(element.project).submit(AppExecutorUtil.getAppExecutorService())
}
},
RIGHT
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.intellij.codeHighlighting.Pass
import com.intellij.codeInsight.daemon.LineMarkerInfo
import com.intellij.codeInsight.daemon.LineMarkerProvider
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
Expand All @@ -14,7 +13,6 @@ import com.intellij.psi.impl.source.PsiClassReferenceType
import com.intellij.ui.awt.RelativePoint
import com.intellij.usageView.UsageInfo
import com.intellij.usages.UsageInfo2UsageAdapter
import com.intellij.util.concurrency.AppExecutorUtil
import com.madrapps.eventbus.post.isPost
import com.madrapps.eventbus.search
import com.madrapps.eventbus.showSubscribeUsages
Expand Down Expand Up @@ -77,34 +75,32 @@ private class SubscribeLineMarkerInfo(
Pass.LINE_MARKERS,
null,
{ event, element ->
ReadAction.nonBlocking {
var usages = emptyList<UsageInfo2UsageAdapter>()
val uElement = element.toUElement()?.getParentOfType<UMethod>()
if (uElement != null) {
val elementToSearch =
(uElement.uastParameters[0].type as PsiClassReferenceType).reference.resolve()
if (elementToSearch != null) {
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 {
if (usages.size == 1) {
usages.first().navigate(true)
var usages = emptyList<UsageInfo2UsageAdapter>()
val uElement = element.toUElement()?.getParentOfType<UMethod>()
if (uElement != null) {
val elementToSearch =
(uElement.uastParameters[0].type as PsiClassReferenceType).reference.resolve()
if (elementToSearch != null) {
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 {
showSubscribeUsages(usages, RelativePoint(event))
search(elementToSearch)
.filter(UsageInfo::isPost)
.map(::UsageInfo2UsageAdapter)
}
}
}.inSmartMode(element.project).submit(AppExecutorUtil.getAppExecutorService())
}
ApplicationManager.getApplication().invokeLater {
if (usages.size == 1) {
usages.first().navigate(true)
} else {
showSubscribeUsages(usages, RelativePoint(event))
}
}
},
RIGHT
)

0 comments on commit 238d561

Please sign in to comment.