From cefef1937b9405a401a5f0a2b28b43693947f2d9 Mon Sep 17 00:00:00 2001 From: thsaravana Date: Fri, 30 Aug 2019 08:52:27 +0530 Subject: [PATCH] Adding essential logs #14 --- build.gradle | 2 +- .../com/madrapps/eventbus/FindUsages.kt | 2 ++ src/main/kotlin/com/madrapps/eventbus/Log.kt | 24 +++++++++---------- .../eventbus/post/PostLineMarkerProvider.kt | 5 +--- .../subscribe/SubscribeLineMarkerProvider.kt | 2 ++ 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index fe722a0..480dd97 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group 'com.madrapps' -version '0.4.5.2019.1' +version '0.4.6.2019.1' sourceCompatibility = 1.8 diff --git a/src/main/kotlin/com/madrapps/eventbus/FindUsages.kt b/src/main/kotlin/com/madrapps/eventbus/FindUsages.kt index f7acb86..e1e359a 100644 --- a/src/main/kotlin/com/madrapps/eventbus/FindUsages.kt +++ b/src/main/kotlin/com/madrapps/eventbus/FindUsages.kt @@ -12,11 +12,13 @@ internal fun search(elements: List): Collection { val references = elements.flatMap { ReferencesSearch.search(it).findAll() } + blog("Search - ${references.size} found") return references.map(::UsageInfo) } internal fun search(element: PsiElement): Collection { val references = ReferencesSearch.search(element).findAll() + blog("Search - ${references.size} found") return references.map(::UsageInfo) } diff --git a/src/main/kotlin/com/madrapps/eventbus/Log.kt b/src/main/kotlin/com/madrapps/eventbus/Log.kt index 0136181..9bd5124 100644 --- a/src/main/kotlin/com/madrapps/eventbus/Log.kt +++ b/src/main/kotlin/com/madrapps/eventbus/Log.kt @@ -1,28 +1,26 @@ 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)) } } @@ -30,7 +28,7 @@ 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)) } } \ No newline at end of file diff --git a/src/main/kotlin/com/madrapps/eventbus/post/PostLineMarkerProvider.kt b/src/main/kotlin/com/madrapps/eventbus/post/PostLineMarkerProvider.kt index 3b32796..78f8fd9 100644 --- a/src/main/kotlin/com/madrapps/eventbus/post/PostLineMarkerProvider.kt +++ b/src/main/kotlin/com/madrapps/eventbus/post/PostLineMarkerProvider.kt @@ -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.* @@ -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) diff --git a/src/main/kotlin/com/madrapps/eventbus/subscribe/SubscribeLineMarkerProvider.kt b/src/main/kotlin/com/madrapps/eventbus/subscribe/SubscribeLineMarkerProvider.kt index dd866dd..a12f492 100644 --- a/src/main/kotlin/com/madrapps/eventbus/subscribe/SubscribeLineMarkerProvider.kt +++ b/src/main/kotlin/com/madrapps/eventbus/subscribe/SubscribeLineMarkerProvider.kt @@ -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 @@ -90,6 +91,7 @@ private class SubscribeLineMarkerInfo( } } } + blog("SubscribeLineMarker - ${usages.size} usages found") ApplicationManager.getApplication().invokeLater { if (usages.size == 1) { usages.first().navigate(true)