Skip to content

Commit

Permalink
Pushing changes to 2018.3 branch (v 0.4.6)
Browse files Browse the repository at this point in the history
  • Loading branch information
thsaravana committed Aug 30, 2019
1 parent bad6917 commit 12d456e
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 34 deletions.
13 changes: 1 addition & 12 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,7 @@

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2019 Madrapps

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'com.madrapps'
version '0.4.2.2018.3'
version '0.4.6.2018.3'

sourceCompatibility = 1.8

Expand Down Expand Up @@ -34,7 +34,7 @@ compileTestKotlin {

patchPluginXml {
changeNotes """
- Add breakpoints to `post` or `subscribe` in a single click <br>
- Option to clear added breakpoints as well <br>
- Enabling Speed search in the Usages popup <br>
- Bug fixes <br>
"""
}
12 changes: 11 additions & 1 deletion src/main/kotlin/com/madrapps/eventbus/FindUsages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ internal fun search(elements: List<PsiElement>): Collection<UsageInfo> {
val references = elements.flatMap {
ReferencesSearch.search(it).findAll()
}
blog("Search - ${references.size} found")
return references.map(::UsageInfo)
}

internal fun search(element: PsiElement): Collection<UsageInfo> {
val references = ReferencesSearch.search(element).findAll()
blog("Search - ${references.size} found")
return references.map(::UsageInfo)
}

Expand Down Expand Up @@ -54,4 +56,12 @@ internal fun Usage.getPostStatementSourcePsi() = toUElement()?.getParentOfTypeCa

internal fun Usage.getSubscribeMethodSourcePsi() = getType<UMethod>()?.uastAnchor?.sourcePsi

internal fun Usage.file() = toUElement()?.sourcePsi?.containingFile
internal fun Usage.file() = toUElement()?.sourcePsi?.containingFile

internal fun UQualifiedReferenceExpression.lastReceiver(): UExpression? {
var temp = receiver
while (temp is UQualifiedReferenceExpression) {
temp = temp.receiver
}
return temp
}
24 changes: 11 additions & 13 deletions src/main/kotlin/com/madrapps/eventbus/Log.kt
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
package com.madrapps.eventbus

import com.intellij.notification.NotificationDisplayType
import com.intellij.notification.NotificationDisplayType.NONE
import com.intellij.notification.NotificationGroup
import com.intellij.notification.NotificationType
import com.intellij.notification.NotificationType.ERROR
import com.intellij.notification.NotificationType.INFORMATION
import com.intellij.notification.Notifications
import com.intellij.openapi.application.ApplicationManager
import org.apache.commons.lang.exception.ExceptionUtils
import java.time.LocalDateTime

val notify = NotificationGroup("EventBus", NotificationDisplayType.NONE, false)
val notify = NotificationGroup("GreenRobot EventBus", NONE, false)

fun blog(msg: String) {
val timedMsg = "${LocalDateTime.now()} : $msg"
println(timedMsg)
ApplicationManager.getApplication().invokeLater {
Notifications.Bus.notify(notify.createNotification(timedMsg, NotificationType.INFORMATION))
}
}
fun blog(msg: String) = log(msg, INFORMATION)

fun errLog(msg: String) = log(msg, ERROR)

fun errLog(msg: String) {
private fun log(msg: String, type: NotificationType) {
val timedMsg = "${LocalDateTime.now()} : $msg"
println(timedMsg)
ApplicationManager.getApplication().invokeLater {
Notifications.Bus.notify(notify.createNotification(timedMsg, NotificationType.ERROR))
Notifications.Bus.notify(notify.createNotification(timedMsg, type))
}
}

fun errLog(e: Throwable) {
val timedMsg = "${LocalDateTime.now()} : ${e.message}"
println(timedMsg)
ApplicationManager.getApplication().invokeLater {
Notifications.Bus.notify(notify.createNotification(timedMsg, NotificationType.ERROR))
Notifications.Bus.notify(notify.createNotification(ExceptionUtils.getFullStackTrace(e), NotificationType.ERROR))
Notifications.Bus.notify(notify.createNotification(timedMsg, ERROR))
Notifications.Bus.notify(notify.createNotification(ExceptionUtils.getFullStackTrace(e), ERROR))
}
}
9 changes: 9 additions & 0 deletions src/main/kotlin/com/madrapps/eventbus/PopUpView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import com.intellij.openapi.editor.Document
import com.intellij.openapi.ui.popup.JBPopup
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.psi.PsiDocumentManager
import com.intellij.ui.Cell
import com.intellij.ui.ScrollingUtil
import com.intellij.ui.SimpleColoredComponent
import com.intellij.ui.SimpleTextAttributes.REGULAR_ATTRIBUTES
import com.intellij.ui.SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES
import com.intellij.ui.TableSpeedSearch
import com.intellij.ui.awt.RelativePoint
import com.intellij.ui.table.JBTable
import com.intellij.usages.*
Expand Down Expand Up @@ -73,6 +75,7 @@ private fun showTablePopUp(usages: List<Usage>, columnInfos: Array<MyColumnInfo>

val table = JBTable().apply {
ScrollingUtil.installActions(this)
installSpeedSearch(this)
model = ListTableModel(columnInfos, usages)
tableHeader = null
showHorizontalLines = false
Expand Down Expand Up @@ -116,6 +119,12 @@ private fun showTablePopUp(usages: List<Usage>, columnInfos: Array<MyColumnInfo>
return popUp
}

private fun installSpeedSearch(table: JBTable) {
TableSpeedSearch(table) { o: Any?, cell: Cell ->
if (o != null && cell.column == 2) o.toString() else ""
}
}

private fun getTitle(usages: List<Usage>) = if (usages.isEmpty()) "No usages found" else "Usages"

private fun resizeColumnWidth(table: JTable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ 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
import com.madrapps.eventbus.showPostUsages
import com.madrapps.eventbus.*
import com.madrapps.eventbus.subscribe.isSubscribe
import org.jetbrains.uast.*

Expand Down Expand Up @@ -71,7 +68,7 @@ private class PostLineMarkerInfo(
if (uElement != null) {
val argument = uElement.valueArguments.firstOrNull()
val elementsToSearch: List<PsiElement> = if (argument is UQualifiedReferenceExpression) {
val sourcePsi = (argument.receiver as USimpleNameReferenceExpression).sourcePsi
val sourcePsi = (argument.lastReceiver() as USimpleNameReferenceExpression).sourcePsi
sourcePsi?.references?.mapNotNull { it.resolve() } ?: emptyList()
} else {
val resolve = (argument?.getExpressionType() as PsiClassType).resolve()
Expand All @@ -84,6 +81,7 @@ private class PostLineMarkerInfo(
.filter(UsageInfo::isSubscribe)
.map(::UsageInfo2UsageAdapter)
}
blog("PostLineMarker - ${usages.size} usages found")
ApplicationManager.getApplication().invokeLater {
if (usages.size == 1) {
usages.first().navigate(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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.blog
import com.madrapps.eventbus.post.isPost
import com.madrapps.eventbus.search
import com.madrapps.eventbus.showSubscribeUsages
Expand Down Expand Up @@ -97,6 +98,7 @@ private class SubscribeLineMarkerInfo(
}
}
}
blog("SubscribeLineMarker - ${usages.size} usages found")
ApplicationManager.getApplication().invokeLater {
if (usages.size == 1) {
usages.first().navigate(true)
Expand Down

0 comments on commit 12d456e

Please sign in to comment.