Skip to content

Commit 0d891d4

Browse files
committed
navigation discovery
1 parent ce07cfc commit 0d891d4

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

ide-common/src/main/java/org/digma/intellij/plugin/common/Backgroundable.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ public void run(@NotNull ProgressIndicator indicator) {
5858
}
5959

6060

61-
62-
6361
public static void runInNewBackgroundThread(Project project, String name, Runnable task) {
6462

6563
new Task.Backgroundable(project, name) {
@@ -109,7 +107,7 @@ public static <T> Future<T> executeOnPooledThread(@NotNull Callable<T> action) {
109107
try {
110108
return action.call();
111109
} catch (Throwable e) {
112-
Log.warnWithException(LOGGER, e, "Exception in action");
110+
Log.warnWithException(LOGGER, e, "Exception in task {}", e);
113111
ErrorReporter.getInstance().reportError("executeOnPooledThread", e);
114112
throw e;
115113
}
@@ -121,16 +119,16 @@ private static void runWithErrorReporting(Project project, String name, Runnable
121119
try {
122120
task.run();
123121
} catch (Throwable e) {
124-
Log.warnWithException(LOGGER, e, "Exception in task {}", name);
125-
ErrorReporter.getInstance().reportError(project, "Backgroundable.runWithErrorReporting(Project,Runnable)" + name, e);
122+
Log.warnWithException(LOGGER, e, "Exception in task {},{}", name, e);
123+
ErrorReporter.getInstance().reportError(project, "Backgroundable.runWithErrorReporting(Project,name,Runnable)" + name, e);
126124
}
127125
}
128126

129127
private static void runWithErrorReporting(Runnable task) {
130128
try {
131129
task.run();
132130
} catch (Throwable e) {
133-
Log.warnWithException(LOGGER, e, "Exception in action");
131+
Log.warnWithException(LOGGER, e, "Exception in task {}", e);
134132
ErrorReporter.getInstance().reportError("Backgroundable.runWithErrorReporting(Runnable)", e);
135133
}
136134
}
@@ -140,7 +138,7 @@ private static <T> Future<T> runWithErrorReporting(@NotNull Callable<T> action)
140138
try {
141139
return new FutureResult<>(action.call());
142140
} catch (Exception e) {
143-
Log.warnWithException(LOGGER, e, "Exception in action");
141+
Log.warnWithException(LOGGER, e, "Exception in task {}", e);
144142
ErrorReporter.getInstance().reportError("Backgroundable.runWithErrorReporting(Callable)", e);
145143
return new FutureResult<>();
146144
}

ide-common/src/main/java/org/digma/intellij/plugin/log/Log.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ public static void log(Consumer<String> consumer, String msg) {
102102

103103

104104
// ********** New API
105+
106+
public static void info(Logger logger, Project project, String format, Object... args) {
107+
logger.info(DIGMA_PROJECT + project.getName() + ": " + format(format, args));
108+
}
109+
110+
public static void info(Logger logger, String format, Object... args) {
111+
logger.info(DIGMA + ": " + format(format, args));
112+
}
113+
114+
115+
105116
public static void warn(Logger logger, Project project, String format, Object... args) {
106117
logger.warn(DIGMA_PROJECT + project.getName() + ": " + format(format, args));
107118
}

src/main/kotlin/org/digma/intellij/plugin/ui/notificationcenter/RegistrationRequestNotifications.kt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import com.intellij.openapi.project.Project
1111
import com.intellij.openapi.util.Disposer
1212
import org.digma.intellij.plugin.PluginId
1313
import org.digma.intellij.plugin.activation.UserActivationService
14-
import org.digma.intellij.plugin.common.Backgroundable
1514
import org.digma.intellij.plugin.common.findActiveProject
1615
import org.digma.intellij.plugin.errorreporting.ErrorReporter
1716
import org.digma.intellij.plugin.log.Log
@@ -119,7 +118,7 @@ class RegisterAction(
119118
override fun actionPerformed(e: AnActionEvent) {
120119

121120
try {
122-
Log.log(AppNotificationCenter.logger::info, "in RegisterAction, action clicked")
121+
Log.info(AppNotificationCenter.logger, "in RegisterAction, action clicked")
123122

124123
ActivityMonitor.getInstance(project).registerUserAction(
125124
"RegisterAction link clicked",
@@ -130,19 +129,11 @@ class RegisterAction(
130129

131130
ActivityMonitor.getInstance(project).registerNotificationCenterEvent("$notificationName.clicked", mapOf())
132131

133-
openRegistrationDialog(project)
132+
project.service<RecentActivityService>().openRegistrationDialog()
134133

135134
notification.expire()
136135
} catch (e: Throwable) {
137-
ErrorReporter.getInstance().reportError(project, "ShowTypeformAction.actionPerformed", e)
138-
}
139-
}
140-
141-
private fun openRegistrationDialog(project: Project) {
142-
//this is called on EDT, start background and release the EDT thread
143-
Backgroundable.ensurePooledThreadWithoutReadAccess {
144-
project.service<RecentActivityService>().openRegistrationDialog()
136+
ErrorReporter.getInstance().reportError(project, "RegisterAction.actionPerformed", e)
145137
}
146138
}
147-
148139
}

src/main/kotlin/org/digma/intellij/plugin/ui/recentactivity/RecentActivityService.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class RecentActivityService(val project: Project, private val cs: CoroutineScope
105105
}
106106

107107

108+
//Runs on EDT!
108109
fun openRegistrationDialog() {
109110

110111
RecentActivityToolWindowShower.getInstance(project).showToolWindow()

0 commit comments

Comments
 (0)