From a4660c9c284d27b8aac652f11b00fd5d1dd95859 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 14 Mar 2022 11:24:52 +0100 Subject: [PATCH] Dev (#685) * protocol update * bump * refactor * refactor * refactor * temp version * refactor * refactor * refactor * clean * organize imports * refactor * refactor * bump * bump * refactor * validate marker auth over tcp * refactor * bump * refactor * bump * bump * backwards compatibility issues * bump * bump * bump * moved packages * refactor * better error message * bump * bump * use official lib * Update build.gradle.kts * Update build.gradle.kts * Update build.gradle.kts * Update build.gradle.kts * Update build.gradle.kts * bump * Update build.gradle.kts * bump * fixes #658 * refactor * remove globalscope * fixes #666 * refactor * formatting * fix log pattern ordering * bump * live variable presentation * refactor * use protocol marshaller * require input * skip if no pattern * bump * clean * Watch log command (#673) * watch log * unused * refactor * refactor * moved portal only code to portal * protocol update * clean * watch log command * bump * refactor * format * remove subscription on mark remove * move package * move test * bump * remove mapper * remove mapper * unused * remove unused * remove unused * remove portal tests * exclude gen * use protocol type * start from current service * remove portal config from status bars * translations * skywalking reroute * skywalking reroute * bump * remove hardcoded config * view event listener merged instrument id source keys * remove portal * bump * bump * use marshaller * use marshaller * use marshaller * re-impl portal * refactor * refactor * bump * refactor * reimpl portal * move portal code * license * sw live service * bump * move packages * MARK_USER_DATA_UPDATED event * bump * activity quick stats * clean * createMethodInlayMark * increase visibility * formatting * bump * more logging * import organizing * remove specific subs instead of clearing all * fix dupe quick stat inlays * bump * remove mapper * reset * Update ViewEventListener.kt * merge refactor * Update build.gradle.kts * remove mapper * compatibility * overview wip * fix edt warning --- .../jetbrains/marker/jvm/ArtifactNavigator.kt | 8 ++++++-- .../spp/jetbrains/sourcemarker/PluginIcons.java | 6 ++++-- .../sourcemarker/command/ControlBarController.kt | 4 +++- .../sourcemarker/command/LiveControlCommand.kt | 10 ++++++++-- .../sourcemarker/portal/PortalController.kt | 10 ++++++++-- .../sourcemarker/portal/PortalEventListener.kt | 16 +++++++++------- .../icons/command/view-overview_selected.svg | 3 +++ .../command/view-overview_selected_dark.svg | 4 ++++ .../icons/command/view-overview_unselected.svg | 4 ++++ .../command/view-overview_unselected_dark.svg | 4 ++++ 10 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 plugin/src/main/resources/icons/command/view-overview_selected.svg create mode 100644 plugin/src/main/resources/icons/command/view-overview_selected_dark.svg create mode 100644 plugin/src/main/resources/icons/command/view-overview_unselected.svg create mode 100644 plugin/src/main/resources/icons/command/view-overview_unselected_dark.svg diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/ArtifactNavigator.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/ArtifactNavigator.kt index 931b2bd08..9265a90dd 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/ArtifactNavigator.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/ArtifactNavigator.kt @@ -50,13 +50,17 @@ object ArtifactNavigator { //todo: remove method from method names and support navigating to classes? fun navigateTo(project: Project, element: LiveStackTraceElement) { - ApplicationManager.getApplication().invokeLater { + ApplicationManager.getApplication().runReadAction { val foundFiles = getFilesByName(project, element.sourceAsFilename()!!, allScope(project)) if (foundFiles.isNotEmpty()) { val file = foundFiles[0] val document: Document = PsiDocumentManager.getInstance(file.project).getDocument(file)!! val offset = document.getLineStartOffset(element.sourceAsLineNumber()!! - 1) - PsiNavigationSupport.getInstance().createNavigatable(project, file.virtualFile, offset).navigate(true) + + ApplicationManager.getApplication().invokeLater { + PsiNavigationSupport.getInstance().createNavigatable(project, file.virtualFile, offset) + .navigate(true) + } } } } diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/PluginIcons.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/PluginIcons.java index c65fde51f..adf1e15d6 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/PluginIcons.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/PluginIcons.java @@ -49,8 +49,8 @@ interface Command { Icon liveBreakpointSelected = IconLoader.getIcon("/icons/command/live-breakpoint_selected.svg", PluginIcons.class); Icon liveBreakpointUnSelected = IconLoader.getIcon("/icons/command/live-breakpoint_unselected.svg", PluginIcons.class); - Icon livelogSelected = IconLoader.getIcon("/icons/command/live-log_selected.svg", PluginIcons.class); - Icon livelogUnSelected = IconLoader.getIcon("/icons/command/live-log_unselected.svg", PluginIcons.class); + Icon liveLogSelected = IconLoader.getIcon("/icons/command/live-log_selected.svg", PluginIcons.class); + Icon liveLogUnSelected = IconLoader.getIcon("/icons/command/live-log_unselected.svg", PluginIcons.class); Icon liveMeterSelected = IconLoader.getIcon("/icons/command/live-meter_selected.svg", PluginIcons.class); Icon liveMeterUnSelected = IconLoader.getIcon("/icons/command/live-meter_unselected.svg", PluginIcons.class); @@ -58,6 +58,8 @@ interface Command { Icon liveSpanSelected = IconLoader.getIcon("/icons/command/live-span_selected.svg", PluginIcons.class); Icon liveSpanUnSelected = IconLoader.getIcon("/icons/command/live-span_unselected.svg", PluginIcons.class); + Icon viewOverviewSelected = IconLoader.getIcon("/icons/command/view-overview_selected.svg", PluginIcons.class); + Icon viewOverviewUnSelected = IconLoader.getIcon("/icons/command/view-overview_unselected.svg", PluginIcons.class); Icon viewActivitySelected = IconLoader.getIcon("/icons/command/view-activity_selected.svg", PluginIcons.class); Icon viewActivityUnSelected = IconLoader.getIcon("/icons/command/view-activity_unselected.svg", PluginIcons.class); Icon viewTracesSelected = IconLoader.getIcon("/icons/command/view-traces_selected.svg", PluginIcons.class); diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/ControlBarController.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/ControlBarController.kt index 7fe1a7221..a2f9ad5db 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/ControlBarController.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/ControlBarController.kt @@ -68,6 +68,7 @@ object ControlBarController { @Suppress("UselessCallOnCollection") //unknown enums are null selfInfo.permissions.filterNotNull().map { it.name }.contains(it.name) }) + //availableCommands.add(VIEW_OVERVIEW) //todo: remove after v0.4.2 } private fun determineAvailableCommandsAtLocation(inlayMark: ExpressionInlayMark): List { @@ -79,7 +80,7 @@ object ControlBarController { val parentMark = inlayMark.getParentSourceMark() if (parentMark is MethodSourceMark) { val loggerDetector = parentMark.getUserData(SourceMarkKeys.LOGGER_DETECTOR) - if (loggerDetector != null) { + if (loggerDetector != null && SourceServices.Instance.liveView != null) { runBlocking { val detectedLogs = loggerDetector.getOrFindLoggerStatements(parentMark) val logOnCurrentLine = detectedLogs.find { it.lineLocation == inlayMark.lineNumber } @@ -95,6 +96,7 @@ object ControlBarController { fun handleCommandInput(input: String, editor: Editor) { log.info("Processing command input: {}", input) when (input) { + VIEW_OVERVIEW.command -> handleViewPortalCommand(editor, VIEW_OVERVIEW) VIEW_ACTIVITY.command -> handleViewPortalCommand(editor, VIEW_ACTIVITY) VIEW_TRACES.command -> handleViewPortalCommand(editor, VIEW_TRACES) VIEW_LOGS.command -> handleViewPortalCommand(editor, VIEW_LOGS) diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/LiveControlCommand.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/LiveControlCommand.kt index 94f34358b..800b9a1dd 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/LiveControlCommand.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/LiveControlCommand.kt @@ -34,6 +34,12 @@ enum class LiveControlCommand( val unselectedIcon: Icon? = null ) : AutocompleteFieldRow { + VIEW_OVERVIEW( + "View Overview", + "Live View ➛ Overview ➛ Scope: Class", + PluginIcons.Command.viewOverviewSelected, + PluginIcons.Command.viewOverviewUnSelected + ), VIEW_ACTIVITY( "View Activity", "Live View ➛ Activity ➛ Scope: Method", @@ -75,8 +81,8 @@ enum class LiveControlCommand( ADD_LIVE_LOG( "Add Log", "Live Instrument ➛ Add ➛ Location: On line *lineNumber*", - PluginIcons.Command.livelogSelected, - PluginIcons.Command.livelogUnSelected + PluginIcons.Command.liveLogSelected, + PluginIcons.Command.liveLogUnSelected ), ADD_LIVE_METER( "Add Meter", diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalController.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalController.kt index 93a0ae463..c500c02fa 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalController.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalController.kt @@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.source.mark.api.component.jcef.SourceMarkJcefComponent import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode +import spp.jetbrains.marker.source.mark.gutter.GutterMark import spp.jetbrains.portal.SourcePortal import spp.jetbrains.portal.backend.PortalServer import spp.jetbrains.portal.protocol.portal.PageType @@ -35,7 +36,9 @@ import spp.jetbrains.sourcemarker.command.LiveControlCommand import spp.jetbrains.sourcemarker.command.LiveControlCommand.* import spp.jetbrains.sourcemarker.mark.SourceMarkKeys import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig +import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.marshall.KSerializers +import spp.protocol.marshall.LocalMessageCodec import javax.swing.UIManager class PortalController(private val markerConfig: SourceMarkerConfig) : CoroutineVerticle() { @@ -54,9 +57,11 @@ class PortalController(private val markerConfig: SourceMarkerConfig) : Coroutine vertx.deployVerticle(portalServer).await() vertx.deployVerticle(PortalEventListener(markerConfig)).await() +// //todo: remove after v0.4.2 +// vertx.eventBus().registerDefaultCodec(ArtifactQualifiedName::class.java, LocalMessageCodec()) + SourceMarker.addGlobalSourceMarkEventListener { - if (it.eventCode == SourceMarkEventCode.MARK_BEFORE_ADDED) { - //todo: only register when needed + if (it.eventCode == SourceMarkEventCode.MARK_BEFORE_ADDED && it.sourceMark is GutterMark) { //register portal for source mark val portal = SourcePortal.getPortal( SourcePortal.register(it.sourceMark.artifactQualifiedName, false) @@ -72,6 +77,7 @@ class PortalController(private val markerConfig: SourceMarkerConfig) : Coroutine it.sourceMark.addEventListener { if (it.eventCode == SourceMarkEventCode.UPDATE_PORTAL_CONFIG) { when (val command = it.params.first() as LiveControlCommand) { + VIEW_OVERVIEW -> portal.configuration.config["currentPage"] = PageType.OVERVIEW VIEW_ACTIVITY -> portal.configuration.config["currentPage"] = PageType.ACTIVITY VIEW_TRACES -> portal.configuration.config["currentPage"] = PageType.TRACES VIEW_LOGS -> portal.configuration.config["currentPage"] = PageType.LOGS diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalEventListener.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalEventListener.kt index a7f2d088a..222990ea8 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalEventListener.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalEventListener.kt @@ -87,6 +87,7 @@ import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import spp.protocol.SourceServices.Instance import spp.protocol.SourceServices.Provide.toLiveViewSubscriberAddress import spp.protocol.artifact.ArtifactQualifiedName +import spp.protocol.artifact.ArtifactType import spp.protocol.artifact.QueryTimeFrame import spp.protocol.artifact.exception.LiveStackTraceElement import spp.protocol.artifact.log.Log @@ -232,9 +233,9 @@ class PortalEventListener( } vertx.eventBus().consumer(FindPortal) { // val artifactQualifiedName = it.body() -// val sourceMarks = SourceMarker.getSourceMarks(artifactQualifiedName) -// if (sourceMarks.isNotEmpty()) { -// it.reply(sourceMarks[0].getUserData(SourceMarkKeys.SOURCE_PORTAL)!!) +// val portals = SourcePortal.getPortals(artifactQualifiedName) +// if (portals.isNotEmpty()) { +// it.reply(portals.first()) // } else { // launch(vertx.dispatcher()) { // val classArtifact = findArtifact( @@ -250,7 +251,8 @@ class PortalEventListener( // val gutterMark = creationService.getOrCreateMethodGutterMark( // fileMarker, searchArtifact.nameIdentifier!! // )!! -// it.reply(gutterMark.getUserData(SourceMarkKeys.SOURCE_PORTAL)!!) +// println(gutterMark) +// //it.reply(gutterMark.getUserData(SourceMarkKeys.SOURCE_PORTAL)!!) // } // } // } @@ -264,9 +266,9 @@ class PortalEventListener( // ApplicationManager.getApplication().invokeLater { // PsiNavigateUtil.navigate(sourceMark.getPsiElement()) // -// val portal = sourceMark.getUserData(SourceMarkKeys.SOURCE_PORTAL)!! -// openPortal(portal) -// it.reply(portal) +// val portals = SourcePortal.getPortals(artifactQualifiedName) +// openPortal(portals.first()) +// it.reply(portals.first()) // } // } else { // log.warn("Failed to find portal for artifact: $artifactQualifiedName") diff --git a/plugin/src/main/resources/icons/command/view-overview_selected.svg b/plugin/src/main/resources/icons/command/view-overview_selected.svg new file mode 100644 index 000000000..f59ce4c54 --- /dev/null +++ b/plugin/src/main/resources/icons/command/view-overview_selected.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/plugin/src/main/resources/icons/command/view-overview_selected_dark.svg b/plugin/src/main/resources/icons/command/view-overview_selected_dark.svg new file mode 100644 index 000000000..07980cc68 --- /dev/null +++ b/plugin/src/main/resources/icons/command/view-overview_selected_dark.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/plugin/src/main/resources/icons/command/view-overview_unselected.svg b/plugin/src/main/resources/icons/command/view-overview_unselected.svg new file mode 100644 index 000000000..07980cc68 --- /dev/null +++ b/plugin/src/main/resources/icons/command/view-overview_unselected.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/plugin/src/main/resources/icons/command/view-overview_unselected_dark.svg b/plugin/src/main/resources/icons/command/view-overview_unselected_dark.svg new file mode 100644 index 000000000..21a5d25ff --- /dev/null +++ b/plugin/src/main/resources/icons/command/view-overview_unselected_dark.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file