Skip to content

Commit

Permalink
Adding essential logs #14
Browse files Browse the repository at this point in the history
  • Loading branch information
thsaravana committed Aug 30, 2019
1 parent 04f0760 commit cefef19
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion 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.5.2019.1'
version '0.4.6.2019.1'

sourceCompatibility = 1.8

Expand Down
2 changes: 2 additions & 0 deletions 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
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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import com.intellij.usageView.UsageInfo
import com.intellij.usages.UsageInfo2UsageAdapter
import com.intellij.util.concurrency.AppExecutorUtil
import com.madrapps.eventbus.*
import com.madrapps.eventbus.getCallExpression
import com.madrapps.eventbus.getParentOfTypeCallExpression
import com.madrapps.eventbus.search
import com.madrapps.eventbus.showPostUsages
import com.madrapps.eventbus.subscribe.isSubscribe
import org.jetbrains.uast.*

Expand Down Expand Up @@ -79,6 +75,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 @@ -14,6 +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.blog
import com.madrapps.eventbus.post.isPost
import com.madrapps.eventbus.search
import com.madrapps.eventbus.showSubscribeUsages
Expand Down Expand Up @@ -90,6 +91,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 cefef19

Please sign in to comment.