From 0810501b389b3a46406ba980d6dff3d7ec5d61d5 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 11 Aug 2022 22:05:14 +0400 Subject: [PATCH] Support multiple projects simultaneously (#789) * fix: https://github.com/sourceplusplus/live-platform/issues/475 * refactor: use intellij logging * remove plugin debug console * gracefully handle config with removed settings * fix: reload compiled live plugins on project reset * fix: already disposed IncorrectOperationException * refactor: get live services from project refactor: get service discovery backend from project * fix: npe * refactor: get live status manager from project * fix check * unused --- commander | 2 +- detekt.yml | 2 +- marker/build.gradle.kts | 1 - marker/jvm-marker/build.gradle.kts | 1 - .../jetbrains/marker/jvm/ArtifactNavigator.kt | 6 +- .../jetbrains/marker/jvm/ArtifactSearch.kt | 2 +- .../marker/jvm/JVMLineMarkerProvider.kt | 14 +- .../marker/jvm/JVMSourceInlayHintProvider.kt | 8 +- .../marker/jvm/psi/LoggerDetector.kt | 4 +- .../jetbrains/marker/source/JVMMarkerUtils.kt | 8 +- marker/py-marker/build.gradle.kts | 1 - .../marker/py/PythonLineMarkerProvider.kt | 5 +- .../spp/jetbrains/marker/SourceMarker.kt | 31 +++- .../marker/plugin/FileActivityListener.kt | 7 +- .../marker/plugin/SourceInlayHintProvider.kt | 15 +- .../marker/plugin/SourceLineMarkerProvider.kt | 6 +- .../plugin/SourceMarkerVisibilityAction.kt | 2 +- .../marker/source/SourceFileMarker.kt | 4 +- .../marker/source/info/EndpointDetector.kt | 4 +- .../source/mark/SourceMarkPopupAction.kt | 6 +- .../source/mark/api/ExpressionSourceMark.kt | 2 +- .../marker/source/mark/api/SourceMark.kt | 6 +- .../source/mark/guide/ClassGuideMark.kt | 2 +- .../source/mark/guide/ExpressionGuideMark.kt | 4 +- .../source/mark/guide/MethodGuideMark.kt | 4 +- .../source/mark/gutter/ClassGutterMark.kt | 2 +- .../mark/gutter/ExpressionGutterMark.kt | 4 +- .../source/mark/gutter/MethodGutterMark.kt | 4 +- .../source/mark/inlay/ExpressionInlayMark.kt | 8 +- .../source/mark/inlay/MethodInlayMark.kt | 8 +- monitor/build.gradle.kts | 1 - .../monitor/skywalking/SkywalkingClient.kt | 48 +++---- .../monitor/skywalking/SkywalkingMonitor.kt | 20 +-- .../skywalking/bridge/EndpointBridge.kt | 4 +- .../skywalking/bridge/ServiceBridge.kt | 8 +- .../skywalking/service/SWLiveViewService.kt | 4 +- plugin/build.gradle.kts | 2 - .../settings/PluginConfigurationPanel.form | 14 +- .../settings/PluginConfigurationPanel.java | 9 +- .../status/BreakpointStatusBar.java | 17 +-- .../status/LiveMeterStatusPanel.java | 15 +- .../sourcemarker/status/LogStatusBar.java | 31 ++-- .../sourcemarker/status/MeterStatusBar.java | 15 +- .../sourcemarker/status/SpanStatusBar.java | 13 +- .../sourcemarker/SourceMarkerPlugin.kt | 135 ++++++++++-------- .../PluginSourceMarkerStartupActivity.kt | 2 +- .../command/ControlBarController.kt | 10 +- .../console/SourceMarkerAppender.kt | 68 --------- .../console/SourceMarkerConsoleService.kt | 41 ------ .../console/SourceMarkerToolWindowFactory.kt | 54 ------- .../mark/PluginSourceMarkEventListener.kt | 34 ++--- .../sourcemarker/mark/SourceMarkKeys.kt | 8 +- .../sourcemarker/mark/SourceMarkSearch.kt | 9 +- .../sourcemarker/portal/PortalController.kt | 16 ++- .../sourcemarker/reporting/error-report.kt | 8 +- .../service/InstrumentEventListener.kt | 29 ---- .../service/LiveInstrumentManager.kt | 45 +++--- .../sourcemarker/service/LiveViewManager.kt | 20 +-- .../sourcemarker/service/ViewEventListener.kt | 29 ---- .../discover/TCPServiceDiscoveryBackend.kt | 18 ++- .../breakpoint/ExecutionPointManager.kt | 6 +- .../breakpoint/ui/BreakpointHitWindow.kt | 5 +- .../instrument/breakpoint/ui/EventsTab.kt | 5 +- .../instrument/breakpoint/ui/EventsWindow.kt | 4 +- .../settings/SourceMarkerConfig.kt | 1 - .../settings/SourceMarkerConfigurable.kt | 19 ++- ...tusManager.kt => LiveStatusManagerImpl.kt} | 81 +++++------ plugin/src/main/resources/META-INF/plugin.xml | 8 +- plugin/src/main/resources/logback.xml | 33 ----- .../endpoint/GroovyEndpointDetectorTest.kt | 22 +-- .../psi/endpoint/JavaEndpointDetectorTest.kt | 22 +-- .../endpoint/KotlinEndpointDetectorTest.kt | 24 ++-- .../endpoint/ScalaEndpointNameDetectorTest.kt | 12 +- 73 files changed, 456 insertions(+), 686 deletions(-) delete mode 100644 plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerAppender.kt delete mode 100755 plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerConsoleService.kt delete mode 100755 plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerToolWindowFactory.kt delete mode 100644 plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/InstrumentEventListener.kt delete mode 100644 plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/ViewEventListener.kt rename plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/{LiveStatusManager.kt => LiveStatusManagerImpl.kt} (86%) delete mode 100644 plugin/src/main/resources/logback.xml diff --git a/commander b/commander index 719064832..8372cbb96 160000 --- a/commander +++ b/commander @@ -1 +1 @@ -Subproject commit 719064832de2dc79c979a82914b01be9aa9ab162 +Subproject commit 8372cbb96a84a99a2dd10464160f4c4a2d336da1 diff --git a/detekt.yml b/detekt.yml index 1527b81cc..942a0282b 100644 --- a/detekt.yml +++ b/detekt.yml @@ -2,7 +2,7 @@ # https://github.com/detekt/detekt/blob/master/detekt-core/src/main/resources/default-detekt-config.yml build: - maxIssues: 26 #todo: zero out + maxIssues: 38 #todo: zero out formatting: Indentation: diff --git a/marker/build.gradle.kts b/marker/build.gradle.kts index ee6472296..4a0fa0137 100644 --- a/marker/build.gradle.kts +++ b/marker/build.gradle.kts @@ -33,7 +33,6 @@ dependencies { compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8") compileOnly("com.google.guava:guava:31.1-jre") compileOnly("org.jetbrains:annotations:23.0.0") - compileOnly("org.slf4j:slf4j-api:$slf4jVersion") compileOnly("org.jetbrains.intellij.deps.jcef:jcef:97.2.22-g6779618-chromium-97.0.4692.45-api-1.6") compileOnly("com.jetbrains.intellij.platform:ide:$intellijVersion") compileOnly("com.jetbrains.intellij.platform:ide-impl:$intellijVersion") diff --git a/marker/jvm-marker/build.gradle.kts b/marker/jvm-marker/build.gradle.kts index 374c41993..d7470b7d5 100644 --- a/marker/jvm-marker/build.gradle.kts +++ b/marker/jvm-marker/build.gradle.kts @@ -32,7 +32,6 @@ dependencies { compileOnly("io.vertx:vertx-core:$vertxVersion") compileOnly("io.vertx:vertx-lang-kotlin:$vertxVersion") compileOnly("io.vertx:vertx-lang-kotlin-coroutines:$vertxVersion") - compileOnly("org.slf4j:slf4j-api:$slf4jVersion") compileOnly("org.jooq:joor:$joorVersion") compileOnly("org.apache.commons:commons-lang3:3.12.0") compileOnly("com.android.tools.external.org-jetbrains:uast:30.2.2") 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 c3df79ae0..d47b95d46 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 @@ -18,6 +18,7 @@ package spp.jetbrains.marker.jvm import com.intellij.ide.util.PsiNavigationSupport import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.Document import com.intellij.openapi.project.Project import com.intellij.psi.JavaPsiFacade @@ -29,7 +30,6 @@ import io.vertx.core.* import io.vertx.kotlin.coroutines.await import org.jetbrains.uast.UMethod import org.jetbrains.uast.toUElement -import org.slf4j.LoggerFactory import spp.jetbrains.marker.source.JVMMarkerUtils import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.exception.LiveStackTraceElement @@ -44,7 +44,7 @@ import spp.protocol.artifact.exception.sourceAsLineNumber */ object ArtifactNavigator { - private val log = LoggerFactory.getLogger(ArtifactNavigator::class.java) + private val log = logger() //todo: remove method from method names and support navigating to classes? @@ -77,7 +77,7 @@ object ArtifactNavigator { handler.handle(Future.succeededFuture(true)) } } else { - log.warn("Could not find artifact: {}", artifactQualifiedName) + log.warn("Could not find artifact: $artifactQualifiedName") handler.handle(Future.succeededFuture(false)) } } diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/ArtifactSearch.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/ArtifactSearch.kt index 59550a1bd..20e00e573 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/ArtifactSearch.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/ArtifactSearch.kt @@ -109,7 +109,7 @@ object ArtifactSearch { @Suppress("UnstableApiUsage") suspend fun findArtifact(vertx: Vertx, artifact: ArtifactQualifiedName): PsiElement? { val promise = Promise.promise>() - val project = ProjectManager.getInstance().openProjects[0] + val project = ProjectManager.getInstance().openProjects[0] //todo: support multiple projects ApplicationManager.getApplication().runReadAction { if (artifact.type == ArtifactType.CLASS) { diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMLineMarkerProvider.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMLineMarkerProvider.kt index 07c44654c..efad5ee9c 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMLineMarkerProvider.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMLineMarkerProvider.kt @@ -18,6 +18,7 @@ package spp.jetbrains.marker.jvm import com.intellij.codeInsight.daemon.GutterIconNavigationHandler import com.intellij.codeInsight.daemon.LineMarkerInfo +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.markup.GutterIconRenderer import com.intellij.psi.PsiClass import com.intellij.psi.PsiElement @@ -29,7 +30,6 @@ import org.jetbrains.uast.UClass import org.jetbrains.uast.UMethod import org.jetbrains.uast.toUElement import org.jetbrains.uast.toUElementOfType -import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.impl.ArtifactCreationService import spp.jetbrains.marker.plugin.SourceLineMarkerProvider @@ -50,7 +50,7 @@ import spp.jetbrains.marker.source.mark.gutter.MethodGutterMark abstract class JVMLineMarkerProvider : SourceLineMarkerProvider() { companion object { - private val log = LoggerFactory.getLogger(JVMLineMarkerProvider::class.java) + private val log = logger() } override fun getLineMarkerInfo( @@ -65,9 +65,9 @@ abstract class JVMLineMarkerProvider : SourceLineMarkerProvider() { } private fun getClassGutterMark(element: PsiIdentifier): LineMarkerInfo? { - val fileMarker = SourceMarker.getSourceFileMarker(element.containingFile) ?: return null + val fileMarker = SourceMarker.getInstance(element.project).getSourceFileMarker(element.containingFile) ?: return null val artifactQualifiedName = JVMMarkerUtils.getFullyQualifiedName(element.parent.toUElement() as UClass) - if (!SourceMarker.configuration.createSourceMarkFilter.test(artifactQualifiedName)) return null + if (!SourceMarker.getInstance(element.project).configuration.createSourceMarkFilter.test(artifactQualifiedName)) return null //check by artifact name first due to user can erroneously name same class twice var gutterMark = fileMarker.getSourceMark(artifactQualifiedName, SourceMark.Type.GUTTER) as ClassGutterMark? @@ -95,14 +95,14 @@ abstract class JVMLineMarkerProvider : SourceLineMarkerProvider() { } private fun getMethodGutterMark(element: PsiElement): LineMarkerInfo? { - val fileMarker = SourceMarker.getSourceFileMarker(element.containingFile) ?: return null + val fileMarker = SourceMarker.getInstance(element.project).getSourceFileMarker(element.containingFile) ?: return null val uMethod = element.parent.toUElementOfType() if (uMethod == null) { - log.warn("Unable to transform to UMethod: {}", element.parent) + log.warn("Unable to transform to UMethod: ${element.parent}") return null } val artifactQualifiedName = JVMMarkerUtils.getFullyQualifiedName(uMethod) - if (!SourceMarker.configuration.createSourceMarkFilter.test(artifactQualifiedName)) return null + if (!SourceMarker.getInstance(element.project).configuration.createSourceMarkFilter.test(artifactQualifiedName)) return null //check by artifact name first due to user can erroneously name same method twice var gutterMark = fileMarker.getSourceMark( diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMSourceInlayHintProvider.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMSourceInlayHintProvider.kt index cbb81474f..349213970 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMSourceInlayHintProvider.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMSourceInlayHintProvider.kt @@ -44,17 +44,17 @@ class JVMSourceInlayHintProvider : SourceInlayHintProvider() { if ((parent is PsiMethod && element === parent.nameIdentifier) || (JVMMarkerUtils.getNameIdentifier(parent) === element) ) { - val fileMarker = SourceMarker.getSourceFileMarker(element.containingFile)!! + val fileMarker = SourceMarker.getInstance(element.project).getSourceFileMarker(element.containingFile)!! val artifactQualifiedName = JVMMarkerUtils.getFullyQualifiedName(parent.toUElement() as UMethod) - return if (!SourceMarker.configuration.createSourceMarkFilter.test(artifactQualifiedName)) null else { + return if (!SourceMarker.getInstance(element.project).configuration.createSourceMarkFilter.test(artifactQualifiedName)) null else { JVMMarkerUtils.getOrCreateMethodInlayMark(fileMarker, element) } } else if (element is PsiStatement) { - val fileMarker = SourceMarker.getSourceFileMarker(element.containingFile)!! + val fileMarker = SourceMarker.getInstance(element.project).getSourceFileMarker(element.containingFile)!! val artifactQualifiedName = JVMMarkerUtils.getFullyQualifiedName( JVMMarkerUtils.getUniversalExpression(element).toUElement() as UExpression ) - return if (!SourceMarker.configuration.createSourceMarkFilter.test(artifactQualifiedName)) null else { + return if (!SourceMarker.getInstance(element.project).configuration.createSourceMarkFilter.test(artifactQualifiedName)) null else { JVMMarkerUtils.getOrCreateExpressionInlayMark(fileMarker, element) } } diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/LoggerDetector.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/LoggerDetector.kt index e7830eba5..fce783586 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/LoggerDetector.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/LoggerDetector.kt @@ -17,6 +17,7 @@ package spp.jetbrains.marker.jvm.psi import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.LogicalPosition import com.intellij.openapi.util.TextRange @@ -33,7 +34,6 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import org.jetbrains.uast.UMethod import org.jetbrains.uast.toUElementOfType -import org.slf4j.LoggerFactory import spp.jetbrains.marker.source.SourceFileMarker import spp.jetbrains.marker.source.mark.api.MethodSourceMark import spp.jetbrains.marker.source.mark.api.key.SourceKey @@ -48,7 +48,7 @@ import spp.jetbrains.marker.source.mark.inlay.InlayMark class LoggerDetector(val vertx: Vertx) { companion object { - private val log = LoggerFactory.getLogger(LoggerDetector::class.java) + private val log = logger() val LOGGER_STATEMENTS = SourceKey>("LOGGER_STATEMENTS") private val LOGGER_CLASSES = setOf( diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/source/JVMMarkerUtils.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/source/JVMMarkerUtils.kt index 079518639..a9fff92a6 100755 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/source/JVMMarkerUtils.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/source/JVMMarkerUtils.kt @@ -16,11 +16,11 @@ */ package spp.jetbrains.marker.source +import com.intellij.openapi.diagnostic.logger import com.intellij.psi.* import com.intellij.psi.util.PsiUtil import org.jetbrains.uast.* import org.joor.Reflect -import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarkerUtils import spp.jetbrains.marker.source.mark.api.SourceMark import spp.jetbrains.marker.source.mark.api.key.SourceKey @@ -42,7 +42,7 @@ import java.util.* @Suppress("TooManyFunctions") object JVMMarkerUtils { - private val log = LoggerFactory.getLogger(JVMMarkerUtils::class.java) + private val log = logger() /** * todo: description. @@ -445,7 +445,7 @@ object JVMMarkerUtils { if (gutterMark == null) { val uClass = element.parent.toUElement() as UClass if (uClass.qualifiedName == null) { - log.warn("Could not determine qualified name of class: {}", uClass) + log.warn("Could not determine qualified name of class: $uClass") return null } gutterMark = fileMarker.createClassSourceMark( @@ -611,7 +611,7 @@ object JVMMarkerUtils { it.type.canonicalText } } else { - log.warn("Unable to detect element type: {}", it) + log.warn("Unable to detect element type: $it") } } return "$methodName($methodParams)" diff --git a/marker/py-marker/build.gradle.kts b/marker/py-marker/build.gradle.kts index 3d3df55d7..7a2a45360 100644 --- a/marker/py-marker/build.gradle.kts +++ b/marker/py-marker/build.gradle.kts @@ -25,7 +25,6 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") implementation("com.google.guava:guava:31.1-jre") implementation("org.jetbrains:annotations:23.0.0") - compileOnly("org.slf4j:slf4j-api:$slf4jVersion") compileOnly("com.jetbrains.intellij.platform:ide:$intellijVersion") compileOnly("com.jetbrains.intellij.platform:ide-impl:$intellijVersion") compileOnly("com.jetbrains.intellij.platform:core:$intellijVersion") diff --git a/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonLineMarkerProvider.kt b/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonLineMarkerProvider.kt index a2f53ccad..203571ed3 100644 --- a/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonLineMarkerProvider.kt +++ b/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonLineMarkerProvider.kt @@ -19,7 +19,6 @@ package spp.jetbrains.marker.py import com.intellij.codeInsight.daemon.LineMarkerInfo import com.intellij.psi.PsiElement import com.jetbrains.python.psi.PyFile -import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.plugin.SourceLineMarkerProvider import spp.jetbrains.marker.source.SourceFileMarker @@ -33,8 +32,6 @@ import spp.jetbrains.marker.source.mark.gutter.GutterMark */ class PythonLineMarkerProvider : SourceLineMarkerProvider() { - private val log = LoggerFactory.getLogger(PythonLineMarkerProvider::class.java) - companion object { init { SourceFileMarker.SUPPORTED_FILE_TYPES.add(PyFile::class.java) @@ -42,7 +39,7 @@ class PythonLineMarkerProvider : SourceLineMarkerProvider() { } override fun getLineMarkerInfo(parent: PsiElement?, element: PsiElement): LineMarkerInfo? { - val fileMarker = SourceMarker.getSourceFileMarker(element.containingFile) + val fileMarker = SourceMarker.getInstance(element.project).getSourceFileMarker(element.containingFile) return null //todo: this } diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/SourceMarker.kt b/marker/src/main/kotlin/spp/jetbrains/marker/SourceMarker.kt index c8744f8de..468bc3a8b 100755 --- a/marker/src/main/kotlin/spp/jetbrains/marker/SourceMarker.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/SourceMarker.kt @@ -19,10 +19,13 @@ package spp.jetbrains.marker import com.google.common.collect.ImmutableList import com.google.common.collect.Lists import com.google.common.collect.Maps +import com.intellij.openapi.diagnostic.logger +import com.intellij.openapi.project.Project +import com.intellij.openapi.util.Key import com.intellij.psi.PsiFile +import io.vertx.core.Vertx import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch -import org.slf4j.LoggerFactory import spp.jetbrains.marker.impl.ArtifactNamingService import spp.jetbrains.marker.impl.SourceGuideProvider import spp.jetbrains.marker.source.SourceFileMarker @@ -39,14 +42,28 @@ import spp.protocol.artifact.ArtifactType * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ @Suppress("TooManyFunctions") -object SourceMarker { +class SourceMarker { - var PLUGIN_NAME = "SourceMarker" + companion object { + var PLUGIN_NAME = "SourceMarker" + + private val log = logger() + private val KEY = Key.create("SPP_SOURCE_MARKER") + val VERTX_KEY = Key.create("SPP_VERTX") + + @Synchronized + fun getInstance(project: Project): SourceMarker { + if (project.getUserData(KEY) == null) { + val sourceMarker = SourceMarker() + project.putUserData(KEY, sourceMarker) + } + return project.getUserData(KEY)!! + } + } @Volatile var enabled = true val configuration: SourceMarkerConfiguration = SourceMarkerConfiguration() - private val log = LoggerFactory.getLogger(javaClass) private val availableSourceFileMarkers = Maps.newConcurrentMap() private val globalSourceMarkEventListeners = Lists.newArrayList() @@ -65,7 +82,7 @@ object SourceMarker { if (availableSourceFileMarkers.remove(sourceFileMarker.hashCode()) != null) { sourceFileMarker.clearSourceMarks() sourceFileMarker.psiFile.putUserData(SourceFileMarker.KEY, null) - log.info("Deactivated source file marker: {}", sourceFileMarker) + log.info("Deactivated source file marker: $sourceFileMarker") return true } return false @@ -120,12 +137,12 @@ object SourceMarker { } fun addGlobalSourceMarkEventListener(sourceMarkEventListener: SourceMarkEventListener) { - log.info("Adding global source mark event listener: {}", sourceMarkEventListener) + log.info("Adding global source mark event listener: $sourceMarkEventListener") globalSourceMarkEventListeners.add(sourceMarkEventListener) } fun removeGlobalSourceMarkEventListener(sourceMarkEventListener: SourceMarkEventListener) { - log.info("Removing global source mark event listener: {}", sourceMarkEventListener) + log.info("Removing global source mark event listener: $sourceMarkEventListener") globalSourceMarkEventListeners.remove(sourceMarkEventListener) } diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/plugin/FileActivityListener.kt b/marker/src/main/kotlin/spp/jetbrains/marker/plugin/FileActivityListener.kt index 69157b447..f4678eff0 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/plugin/FileActivityListener.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/plugin/FileActivityListener.kt @@ -17,6 +17,7 @@ package spp.jetbrains.marker.plugin import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.event.EditorMouseEvent @@ -30,7 +31,6 @@ import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiFile import com.intellij.psi.PsiManager import kotlinx.coroutines.runBlocking -import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.source.SourceFileMarker import spp.jetbrains.marker.source.mark.gutter.GutterMark @@ -61,15 +61,14 @@ class FileActivityListener : FileEditorManagerListener { val fileMarker = psiFile?.getUserData(SourceFileMarker.KEY) if (fileMarker != null) { runBlocking { - SourceMarker.deactivateSourceFileMarker(fileMarker) + SourceMarker.getInstance(source.project).deactivateSourceFileMarker(fileMarker) } } } } companion object { - - private val log = LoggerFactory.getLogger(FileActivityListener::class.java) + private val log = logger() @JvmStatic fun triggerFileOpened(source: FileEditorManager, file: VirtualFile) { diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceInlayHintProvider.kt b/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceInlayHintProvider.kt index cfffda30e..121501748 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceInlayHintProvider.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceInlayHintProvider.kt @@ -21,6 +21,7 @@ import com.intellij.codeInsight.hints.presentation.* import com.intellij.ide.ui.AntialiasingType import com.intellij.lang.Language import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.DefaultLanguageHighlighterColors.INLINE_PARAMETER_HINT import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.colors.EditorFontType @@ -33,9 +34,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.ui.paint.EffectPainter import org.joor.Reflect -import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker -import spp.jetbrains.marker.SourceMarker.getSourceFileMarker import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode.MARK_REMOVED import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventListener import spp.jetbrains.marker.source.mark.api.key.SourceKey @@ -60,7 +59,7 @@ import javax.swing.JPanel abstract class SourceInlayHintProvider : InlayHintsProvider { companion object { - private val log = LoggerFactory.getLogger(SourceInlayHintProvider::class.java) + private val log = logger() val EVENT_LISTENER = SourceMarkEventListener { event -> when (event.eventCode) { @@ -140,17 +139,17 @@ abstract class SourceInlayHintProvider : InlayHintsProvider { settings: NoSettings, sink: InlayHintsSink ): InlayHintsCollector? { - if (!SourceMarker.enabled) { + if (!SourceMarker.getInstance(editor.project!!).enabled) { log.warn("SourceMarker is disabled. Skipping inlay hints.") return null } return object : FactoryInlayHintsCollector(editor) { override fun collect(element: PsiElement, editor: Editor, sink: InlayHintsSink): Boolean { - val fileMarker = getSourceFileMarker(element.containingFile) ?: return true + val fileMarker = SourceMarker.getInstance(editor.project!!).getSourceFileMarker(element.containingFile) ?: return true var inlayMark = element.getUserData(SourceKey.InlayMark) if (inlayMark == null) { - if (SourceMarker.configuration.inlayMarkConfiguration.strictlyManualCreation) return true else { + if (SourceMarker.getInstance(editor.project!!).configuration.inlayMarkConfiguration.strictlyManualCreation) return true else { inlayMark = createInlayMarkIfNecessary(element) ?: return true } } @@ -244,6 +243,7 @@ abstract class SourceInlayHintProvider : InlayHintsProvider { descent, font ) + EffectType.BOLD_LINE_UNDERSCORE -> EffectPainter.BOLD_LINE_UNDERSCORE.paint( g, 0, @@ -252,6 +252,7 @@ abstract class SourceInlayHintProvider : InlayHintsProvider { descent, font ) + EffectType.STRIKEOUT -> EffectPainter.STRIKE_THROUGH.paint(g, 0, ascent, width, height, font) EffectType.WAVE_UNDERSCORE -> EffectPainter.WAVE_UNDERSCORE.paint( g, @@ -261,6 +262,7 @@ abstract class SourceInlayHintProvider : InlayHintsProvider { descent, font ) + EffectType.BOLD_DOTTED_LINE -> EffectPainter.BOLD_DOTTED_UNDERSCORE.paint( g, 0, @@ -269,6 +271,7 @@ abstract class SourceInlayHintProvider : InlayHintsProvider { descent, font ) + else -> { } } diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceLineMarkerProvider.kt b/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceLineMarkerProvider.kt index c52a186f0..20fc32d2c 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceLineMarkerProvider.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceLineMarkerProvider.kt @@ -36,7 +36,7 @@ abstract class SourceLineMarkerProvider : LineMarkerProviderDescriptor() { abstract fun getLineMarkerInfo(parent: PsiElement?, element: PsiElement): LineMarkerInfo? override fun getLineMarkerInfo(element: PsiElement): LineMarkerInfo? { - if (!SourceMarker.enabled) { + if (!SourceMarker.getInstance(element.project).enabled) { return null } @@ -75,12 +75,12 @@ abstract class SourceLineMarkerProvider : LineMarkerProviderDescriptor() { elements: MutableList, result: MutableCollection> ) { - if (!SourceMarker.enabled) { + if (elements.firstOrNull() == null || !SourceMarker.getInstance(elements.first().project).enabled) { return } elements.stream().map { it.containingFile }.distinct().forEach { - SourceMarker.getSourceFileMarker(it)?.removeInvalidSourceMarks() + SourceMarker.getInstance(it.project).getSourceFileMarker(it)?.removeInvalidSourceMarks() } } diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceMarkerVisibilityAction.kt b/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceMarkerVisibilityAction.kt index 362e9c762..71e7fa047 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceMarkerVisibilityAction.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceMarkerVisibilityAction.kt @@ -36,7 +36,7 @@ class SourceMarkerVisibilityAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { globalVisibility = !globalVisibility - val currentMarks = SourceMarker.getSourceMarks().filter { it !is GuideMark } + val currentMarks = SourceMarker.getInstance(e.project!!).getSourceMarks().filter { it !is GuideMark } if (currentMarks.isNotEmpty()) { currentMarks.forEach { it.setVisible(globalVisibility) } DaemonCodeAnalyzer.getInstance(e.project).restart() diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/SourceFileMarker.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/SourceFileMarker.kt index adca99ad4..09b2df9be 100755 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/SourceFileMarker.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/SourceFileMarker.kt @@ -19,6 +19,7 @@ package spp.jetbrains.marker.source import com.google.common.collect.ImmutableList import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.project.Project import com.intellij.openapi.util.Key @@ -26,7 +27,6 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.PsiNameIdentifierOwner import kotlinx.coroutines.runBlocking -import org.slf4j.LoggerFactory import spp.jetbrains.marker.source.mark.api.* import spp.jetbrains.marker.source.mark.api.event.SourceMarkEvent import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode @@ -54,7 +54,7 @@ open class SourceFileMarker(val psiFile: PsiFile) : SourceMarkProvider { companion object { val KEY = Key.create("sm.SourceFileMarker") - private val log = LoggerFactory.getLogger(SourceFileMarker::class.java) + private val log = logger() val SUPPORTED_FILE_TYPES = mutableListOf>() @JvmStatic diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/info/EndpointDetector.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/info/EndpointDetector.kt index f09e4f69c..5e810681e 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/info/EndpointDetector.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/info/EndpointDetector.kt @@ -16,10 +16,10 @@ */ package spp.jetbrains.marker.source.info +import com.intellij.openapi.diagnostic.logger import io.vertx.core.Future import io.vertx.core.Vertx import io.vertx.kotlin.coroutines.await -import org.slf4j.LoggerFactory import spp.jetbrains.marker.source.mark.api.key.SourceKey import spp.jetbrains.marker.source.mark.guide.GuideMark import spp.jetbrains.marker.source.mark.guide.MethodGuideMark @@ -35,7 +35,7 @@ import java.util.* abstract class EndpointDetector(val vertx: Vertx) { companion object { - private val log = LoggerFactory.getLogger(EndpointDetector::class.java) + private val log = logger>() val ENDPOINT_ID = SourceKey("ENDPOINT_ID") val ENDPOINT_NAME = SourceKey("ENDPOINT_NAME") val ENDPOINT_INTERNAL = SourceKey("ENDPOINT_INTERNAL") diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/SourceMarkPopupAction.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/SourceMarkPopupAction.kt index 2ac772116..481928389 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/SourceMarkPopupAction.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/SourceMarkPopupAction.kt @@ -19,11 +19,11 @@ package spp.jetbrains.marker.source.mark import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.openapi.util.TextRange import org.jetbrains.annotations.NotNull -import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.source.SourceFileMarker import spp.jetbrains.marker.source.mark.api.ClassSourceMark @@ -40,10 +40,10 @@ import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode */ open class SourceMarkPopupAction : AnAction() { - private val log = LoggerFactory.getLogger(SourceMarkPopupAction::class.java) + private val log = logger() override fun update(@NotNull e: AnActionEvent) { - if (!SourceMarker.enabled) { + if (!SourceMarker.getInstance(e.project!!).enabled) { log.warn("SourceMarker disabled. Ignoring popup action.") return } diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/api/ExpressionSourceMark.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/api/ExpressionSourceMark.kt index 6b8b61538..4c19a9475 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/api/ExpressionSourceMark.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/api/ExpressionSourceMark.kt @@ -110,7 +110,7 @@ abstract class ExpressionSourceMark( } fun getParentSourceMark(): SourceMark? { - return SourceMarker.getSourceMark( + return SourceMarker.getInstance(project).getSourceMark( artifactQualifiedName.copy( identifier = artifactQualifiedName.identifier.substringBefore("#"), type = ArtifactType.METHOD diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/api/SourceMark.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/api/SourceMark.kt index 60bf66f50..be321dcf4 100755 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/api/SourceMark.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/api/SourceMark.kt @@ -20,6 +20,7 @@ import com.intellij.codeInsight.hints.InlayHintsPassFactory import com.intellij.lang.Language import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.event.VisibleAreaEvent import com.intellij.openapi.editor.event.VisibleAreaListener @@ -40,7 +41,6 @@ import com.intellij.util.ui.JBUI import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.plugin.SourceInlayComponentProvider import spp.jetbrains.marker.plugin.SourceInlayHintProvider @@ -83,7 +83,7 @@ interface SourceMark : JBPopupListener, MouseMotionListener, VisibleAreaListener } companion object { - private val log = LoggerFactory.getLogger(SourceMark::class.java) + private val log = logger() private val buildingPopup = AtomicBoolean() private var openedMarks: MutableList = ArrayList() @@ -122,7 +122,7 @@ interface SourceMark : JBPopupListener, MouseMotionListener, VisibleAreaListener fun canApply(): Boolean = configuration.applySourceMarkFilter.test(this) fun apply(sourceMarkComponent: SourceMarkComponent, addToMarker: Boolean = true, editor: Editor? = null) fun apply(addToMarker: Boolean = true, editor: Editor? = null) { - SourceMarker.getGlobalSourceMarkEventListeners().forEach(::addEventListener) + SourceMarker.getInstance(project).getGlobalSourceMarkEventListeners().forEach(::addEventListener) if (addToMarker) { check(sourceFileMarker.applySourceMark(this, autoRefresh = true, overrideFilter = true)) diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/ClassGuideMark.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/ClassGuideMark.kt index a8dcbab0c..53f81c3ec 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/ClassGuideMark.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/ClassGuideMark.kt @@ -35,5 +35,5 @@ open class ClassGuideMark( ) : ClassSourceMark(sourceFileMarker, psiClass), GuideMark { override val id: String = UUID.randomUUID().toString() - override val configuration: GuideMarkConfiguration = SourceMarker.configuration.guideMarkConfiguration + override val configuration: GuideMarkConfiguration = SourceMarker.getInstance(project).configuration.guideMarkConfiguration.copy() } diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/ExpressionGuideMark.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/ExpressionGuideMark.kt index 094671fa0..024ed0c7d 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/ExpressionGuideMark.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/ExpressionGuideMark.kt @@ -17,11 +17,11 @@ package spp.jetbrains.marker.source.mark.guide import com.intellij.psi.PsiElement +import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.source.SourceFileMarker import spp.jetbrains.marker.source.mark.api.ExpressionSourceMark import spp.jetbrains.marker.source.mark.guide.config.GuideMarkConfiguration import java.util.* -import spp.jetbrains.marker.SourceMarker.configuration as pluginConfiguration /** * Represents a [GuideMark] associated to an expression artifact. @@ -35,5 +35,5 @@ open class ExpressionGuideMark( ) : ExpressionSourceMark(sourceFileMarker, psiExpression), GuideMark { override val id: String = UUID.randomUUID().toString() - override val configuration: GuideMarkConfiguration = pluginConfiguration.guideMarkConfiguration.copy() + override val configuration: GuideMarkConfiguration = SourceMarker.getInstance(project).configuration.guideMarkConfiguration.copy() } diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/MethodGuideMark.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/MethodGuideMark.kt index bf11ff357..2cc3568e4 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/MethodGuideMark.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/guide/MethodGuideMark.kt @@ -17,11 +17,11 @@ package spp.jetbrains.marker.source.mark.guide import com.intellij.psi.PsiNameIdentifierOwner +import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.source.SourceFileMarker import spp.jetbrains.marker.source.mark.api.MethodSourceMark import spp.jetbrains.marker.source.mark.guide.config.GuideMarkConfiguration import java.util.* -import spp.jetbrains.marker.SourceMarker.configuration as pluginConfiguration /** * Represents a [GuideMark] associated to a method artifact. @@ -35,5 +35,5 @@ open class MethodGuideMark( ) : MethodSourceMark(sourceFileMarker, psiMethod), GuideMark { override val id: String = UUID.randomUUID().toString() - override val configuration: GuideMarkConfiguration = pluginConfiguration.guideMarkConfiguration.copy() + override val configuration: GuideMarkConfiguration = SourceMarker.getInstance(project).configuration.guideMarkConfiguration.copy() } diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/ClassGutterMark.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/ClassGutterMark.kt index 30d4c9381..a1534e5f6 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/ClassGutterMark.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/ClassGutterMark.kt @@ -40,7 +40,7 @@ open class ClassGutterMark( override val id: String = UUID.randomUUID().toString() - final override val configuration: GutterMarkConfiguration = SourceMarker.configuration.gutterMarkConfiguration + final override val configuration: GutterMarkConfiguration = SourceMarker.getInstance(project).configuration.gutterMarkConfiguration.copy() private var visible: AtomicBoolean = AtomicBoolean(SourceMarkerVisibilityAction.globalVisibility) override fun isVisible(): Boolean { diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/ExpressionGutterMark.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/ExpressionGutterMark.kt index 7ac986a21..eb4fa3f36 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/ExpressionGutterMark.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/ExpressionGutterMark.kt @@ -17,6 +17,7 @@ package spp.jetbrains.marker.source.mark.gutter import com.intellij.psi.PsiElement +import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.plugin.SourceMarkerVisibilityAction import spp.jetbrains.marker.source.SourceFileMarker import spp.jetbrains.marker.source.mark.api.ExpressionSourceMark @@ -25,7 +26,6 @@ import spp.jetbrains.marker.source.mark.gutter.config.GutterMarkConfiguration import spp.jetbrains.marker.source.mark.gutter.event.GutterMarkEventCode import java.util.* import java.util.concurrent.atomic.AtomicBoolean -import spp.jetbrains.marker.SourceMarker.configuration as pluginConfiguration /** * Represents a [GutterMark] associated to an expression artifact. @@ -39,7 +39,7 @@ open class ExpressionGutterMark( ) : ExpressionSourceMark(sourceFileMarker, psiExpression), GutterMark { override val id: String = UUID.randomUUID().toString() - override val configuration: GutterMarkConfiguration = pluginConfiguration.gutterMarkConfiguration.copy() + override val configuration: GutterMarkConfiguration = SourceMarker.getInstance(project).configuration.gutterMarkConfiguration.copy() private var visible: AtomicBoolean = AtomicBoolean(SourceMarkerVisibilityAction.globalVisibility) override fun isVisible(): Boolean { diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/MethodGutterMark.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/MethodGutterMark.kt index 37670313b..f2ae1ae42 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/MethodGutterMark.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/gutter/MethodGutterMark.kt @@ -17,6 +17,7 @@ package spp.jetbrains.marker.source.mark.gutter import com.intellij.psi.PsiNameIdentifierOwner +import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.plugin.SourceMarkerVisibilityAction import spp.jetbrains.marker.source.SourceFileMarker import spp.jetbrains.marker.source.mark.api.MethodSourceMark @@ -25,7 +26,6 @@ import spp.jetbrains.marker.source.mark.gutter.config.GutterMarkConfiguration import spp.jetbrains.marker.source.mark.gutter.event.GutterMarkEventCode import java.util.* import java.util.concurrent.atomic.AtomicBoolean -import spp.jetbrains.marker.SourceMarker.configuration as pluginConfiguration /** * Represents a [GutterMark] associated to a method artifact. @@ -39,7 +39,7 @@ open class MethodGutterMark( ) : MethodSourceMark(sourceFileMarker, psiMethod), GutterMark { override val id: String = UUID.randomUUID().toString() - override val configuration: GutterMarkConfiguration = pluginConfiguration.gutterMarkConfiguration.copy() + override val configuration: GutterMarkConfiguration = SourceMarker.getInstance(project).configuration.gutterMarkConfiguration.copy() private var visible: AtomicBoolean = AtomicBoolean(SourceMarkerVisibilityAction.globalVisibility) override fun isVisible(): Boolean { diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/inlay/ExpressionInlayMark.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/inlay/ExpressionInlayMark.kt index fec1199b1..380af228c 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/inlay/ExpressionInlayMark.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/inlay/ExpressionInlayMark.kt @@ -17,13 +17,13 @@ package spp.jetbrains.marker.source.mark.inlay import com.intellij.psi.PsiElement +import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.plugin.SourceMarkerVisibilityAction import spp.jetbrains.marker.source.SourceFileMarker import spp.jetbrains.marker.source.mark.api.ExpressionSourceMark import spp.jetbrains.marker.source.mark.inlay.config.InlayMarkConfiguration import java.util.* import java.util.concurrent.atomic.AtomicBoolean -import spp.jetbrains.marker.SourceMarker.configuration as pluginConfiguration /** * Represents an [InlayMark] associated to an expression artifact. @@ -31,13 +31,13 @@ import spp.jetbrains.marker.SourceMarker.configuration as pluginConfiguration * @since 0.1.0 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ -open class ExpressionInlayMark @JvmOverloads constructor( +open class ExpressionInlayMark constructor( override val sourceFileMarker: SourceFileMarker, - override var psiExpression: PsiElement, - override val configuration: InlayMarkConfiguration = pluginConfiguration.inlayMarkConfiguration.copy() + override var psiExpression: PsiElement ) : ExpressionSourceMark(sourceFileMarker, psiExpression), InlayMark { override val id: String = UUID.randomUUID().toString() + override val configuration: InlayMarkConfiguration = SourceMarker.getInstance(project).configuration.inlayMarkConfiguration.copy() override var visible: AtomicBoolean = AtomicBoolean(SourceMarkerVisibilityAction.globalVisibility) var showAboveExpression = false } diff --git a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/inlay/MethodInlayMark.kt b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/inlay/MethodInlayMark.kt index daa7f9e11..1a6b67a7a 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/inlay/MethodInlayMark.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/mark/inlay/MethodInlayMark.kt @@ -17,13 +17,13 @@ package spp.jetbrains.marker.source.mark.inlay import com.intellij.psi.PsiNameIdentifierOwner +import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.plugin.SourceMarkerVisibilityAction import spp.jetbrains.marker.source.SourceFileMarker import spp.jetbrains.marker.source.mark.api.MethodSourceMark import spp.jetbrains.marker.source.mark.inlay.config.InlayMarkConfiguration import java.util.* import java.util.concurrent.atomic.AtomicBoolean -import spp.jetbrains.marker.SourceMarker.configuration as pluginConfiguration /** * Represents an [InlayMark] associated to a method artifact. @@ -31,12 +31,12 @@ import spp.jetbrains.marker.SourceMarker.configuration as pluginConfiguration * @since 0.1.0 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ -open class MethodInlayMark @JvmOverloads constructor( +open class MethodInlayMark constructor( override val sourceFileMarker: SourceFileMarker, - override var psiMethod: PsiNameIdentifierOwner, - override val configuration: InlayMarkConfiguration = pluginConfiguration.inlayMarkConfiguration.copy(), + override var psiMethod: PsiNameIdentifierOwner ) : MethodSourceMark(sourceFileMarker, psiMethod), InlayMark { override val id: String = UUID.randomUUID().toString() + override val configuration: InlayMarkConfiguration = SourceMarker.getInstance(project).configuration.inlayMarkConfiguration.copy() override var visible: AtomicBoolean = AtomicBoolean(SourceMarkerVisibilityAction.globalVisibility) } diff --git a/monitor/build.gradle.kts b/monitor/build.gradle.kts index e45fc60f7..b414f77c3 100644 --- a/monitor/build.gradle.kts +++ b/monitor/build.gradle.kts @@ -17,7 +17,6 @@ repositories { dependencies { implementation("plus.sourceplus:protocol:$projectVersion") - implementation("org.slf4j:slf4j-api:$slf4jVersion") implementation("com.apollographql.apollo3:apollo-runtime:$apolloVersion") api("com.apollographql.apollo3:apollo-api:$apolloVersion") diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingClient.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingClient.kt index a312e1740..d01865868 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingClient.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingClient.kt @@ -20,6 +20,7 @@ import com.apollographql.apollo3.ApolloClient import com.apollographql.apollo3.api.Optional import com.codahale.metrics.MetricRegistry import com.google.common.cache.CacheBuilder +import com.intellij.openapi.diagnostic.logger import io.vertx.core.Vertx import io.vertx.core.json.Json import io.vertx.core.json.JsonArray @@ -35,7 +36,6 @@ import monitor.skywalking.protocol.metrics.SortMetricsQuery import monitor.skywalking.protocol.trace.QueryBasicTracesQuery import monitor.skywalking.protocol.trace.QueryTraceQuery import monitor.skywalking.protocol.type.* -import org.slf4j.LoggerFactory import spp.jetbrains.monitor.skywalking.model.GetEndpointMetrics import spp.jetbrains.monitor.skywalking.model.GetEndpointTraces import spp.jetbrains.monitor.skywalking.model.GetMultipleEndpointMetrics @@ -62,7 +62,7 @@ class SkywalkingClient( companion object { private val metricRegistry: MetricRegistry = MetricRegistry() - private val log = LoggerFactory.getLogger(SkywalkingClient::class.java) + private val log = logger() fun registerCodecs(vertx: Vertx) { log.info("Registering Apache SkyWalking codecs") @@ -104,7 +104,7 @@ class SkywalkingClient( response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Get version response: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Get version response: ${response.data!!.result}") return response.data!!.result } } @@ -123,7 +123,7 @@ class SkywalkingClient( response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Get time info response: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Get time info response: ${response.data!!.result}") return response.data!! } } @@ -133,14 +133,14 @@ class SkywalkingClient( traceId: String, ): QueryTraceQuery.Result? { metricRegistry.timer("queryTraceStack").time().use { - if (log.isTraceEnabled) log.trace("Query trace stack request. Trace: {}", traceId) + if (log.isTraceEnabled) log.trace("Query trace stack request. Trace: $traceId") val response = apolloClient.query(QueryTraceQuery(traceId)).execute() if (response.hasErrors()) { response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Query trace stack response: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Query trace stack response: ${response.data!!.result}") return response.data!!.result } } @@ -148,7 +148,7 @@ class SkywalkingClient( suspend fun queryBasicTraces(request: GetEndpointTraces): QueryBasicTracesQuery.Result? { metricRegistry.timer("queryBasicTraces").time().use { - if (log.isTraceEnabled) log.trace("Query basic traces request. Request: {}", request) + if (log.isTraceEnabled) log.trace("Query basic traces request. Request: $request") val response = apolloClient.query( QueryBasicTracesQuery( @@ -167,7 +167,7 @@ class SkywalkingClient( response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Query basic traces response: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Query basic traces response: ${response.data!!.result}") return response.data!!.result } } @@ -181,8 +181,7 @@ class SkywalkingClient( metricRegistry.timer("getEndpointMetrics").time().use { if (log.isTraceEnabled) { log.trace( - "Get endpoint metrics request. Metric: {} - Endpoint: {} - Duration: {}", - metricName, endpointId, duration + "Get endpoint metrics request. Metric: $metricName - Endpoint: $endpointId - Duration: $duration" ) } @@ -193,7 +192,7 @@ class SkywalkingClient( response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Get endpoint metrics response: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Get endpoint metrics response: ${response.data!!.result}") return response.data!!.result } } @@ -208,8 +207,7 @@ class SkywalkingClient( metricRegistry.timer("getMultipleEndpointMetrics").time().use { if (log.isTraceEnabled) { log.trace( - "Get multiple endpoint metrics request. Metric: {} - Endpoint: {} - Number: {} - Duration: {}", - metricName, endpointId, numOfLinear, duration + "Get multiple endpoint metrics request. Metric: $metricName - Endpoint: $endpointId - Number: $numOfLinear - Duration: $duration" ) } @@ -224,7 +222,7 @@ class SkywalkingClient( response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Get multiple endpoint metrics response: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Get multiple endpoint metrics response: ${response.data!!.result}") return response.data!!.result } } @@ -239,9 +237,7 @@ class SkywalkingClient( metricRegistry.timer("searchEndpoint").time().use { if (log.isTraceEnabled) { - log.trace( - "Search endpoint request. Keyword: {} - Service: {} - Limit: {}", keyword, serviceId, limit - ) + log.trace("Search endpoint request. Keyword: $keyword - Service: $serviceId - Limit: $limit") } val response = apolloClient.query( @@ -251,7 +247,7 @@ class SkywalkingClient( response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Search endpoint response: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Search endpoint response: ${response.data!!.result}") val resp = JsonArray(Json.encode(response.data!!.result)) oneMinRespCache.put(Triple(keyword, serviceId, limit), resp) return resp @@ -261,7 +257,7 @@ class SkywalkingClient( suspend fun queryLogs(condition: LogQueryCondition): QueryLogsQuery.Result? { metricRegistry.timer("queryLogs").time().use { - if (log.isTraceEnabled) log.trace("Query logs request. Condition: {}", condition) + if (log.isTraceEnabled) log.trace("Query logs request. Condition: $condition") val response = apolloClient.query( QueryLogsQuery(Optional.Present(condition)) @@ -270,7 +266,7 @@ class SkywalkingClient( response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Query logs response: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Query logs response: ${response.data!!.result}") return response.data!!.result //todo: change return type if this can never be null } } @@ -278,7 +274,7 @@ class SkywalkingClient( suspend fun getServices(duration: Duration): List { metricRegistry.timer("getServices").time().use { - if (log.isTraceEnabled) log.trace("Get services request. Duration: {}", duration) + if (log.isTraceEnabled) log.trace("Get services request. Duration: $duration") val response = apolloClient.query( GetAllServicesQuery(duration) @@ -287,7 +283,7 @@ class SkywalkingClient( response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Get services response: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Get services response: ${response.data!!.result}") return response.data!!.result.map { it.toProtocol() } } } @@ -296,7 +292,7 @@ class SkywalkingClient( suspend fun getServiceInstances(serviceId: String, duration: Duration): List { metricRegistry.timer("getServiceInstances").time().use { if (log.isTraceEnabled) { - log.trace("Get service instances request. Service: {} - Duration: {}", serviceId, duration) + log.trace("Get service instances request. Service: $serviceId - Duration: $duration") } val response = apolloClient.query( @@ -306,7 +302,7 @@ class SkywalkingClient( response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Get service instances: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Get service instances: $response.data!!.result") return response.data!!.result } } @@ -321,7 +317,7 @@ class SkywalkingClient( metricRegistry.timer("sortMetrics").time().use { if (log.isTraceEnabled) { - log.trace("Sort metrics request. Condition: {} - Duration: {}", condition, duration) + log.trace("Sort metrics request. Condition: $condition - Duration: $duration") } val response = apolloClient.query( @@ -331,7 +327,7 @@ class SkywalkingClient( response.errors!!.forEach { log.error(it.message) } throw IOException(response.errors!![0].message) } else { - if (log.isTraceEnabled) log.trace("Sort metrics response: {}", response.data!!.result) + if (log.isTraceEnabled) log.trace("Sort metrics response: ${response.data!!.result}") val resp = JsonArray(Json.encode(response.data!!.result)) oneMinRespCache.put(Pair(condition, duration), resp) return resp diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingMonitor.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingMonitor.kt index 7e6e212f0..bda405a31 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingMonitor.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingMonitor.kt @@ -18,6 +18,7 @@ package spp.jetbrains.monitor.skywalking import com.apollographql.apollo3.ApolloClient import com.apollographql.apollo3.network.okHttpClient +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.project.Project import com.intellij.openapi.util.Key import eu.geekplace.javapinning.JavaPinning @@ -26,12 +27,10 @@ import io.vertx.kotlin.coroutines.CoroutineVerticle import io.vertx.kotlin.coroutines.await import monitor.skywalking.protocol.metadata.GetTimeInfoQuery import okhttp3.OkHttpClient -import org.slf4j.LoggerFactory import spp.jetbrains.monitor.skywalking.bridge.* import spp.jetbrains.monitor.skywalking.impl.SkywalkingMonitorServiceImpl import spp.jetbrains.monitor.skywalking.service.SWLiveService import spp.jetbrains.monitor.skywalking.service.SWLiveViewService -import spp.protocol.SourceServices import spp.protocol.service.LiveInstrumentService import spp.protocol.service.LiveService import spp.protocol.service.LiveViewService @@ -56,12 +55,19 @@ class SkywalkingMonitor( private val project: Project ) : CoroutineVerticle() { + @Suppress("unused", "FunctionName") companion object { - private val log = LoggerFactory.getLogger(SkywalkingMonitor::class.java) + private val log = logger() + @JvmField val LIVE_SERVICE = Key.create("SPP_LIVE_SERVICE") + fun getLIVE_SERVICE() = LIVE_SERVICE + @JvmField val LIVE_VIEW_SERVICE = Key.create("SPP_LIVE_VIEW_SERVICE") + fun getLIVE_VIEW_SERVICE() = LIVE_VIEW_SERVICE + @JvmField val LIVE_INSTRUMENT_SERVICE = Key.create("SPP_LIVE_INSTRUMENT_SERVICE") + fun getLIVE_INSTRUMENT_SERVICE() = LIVE_INSTRUMENT_SERVICE } override suspend fun start() { @@ -121,18 +127,14 @@ class SkywalkingMonitor( vertx.deployVerticle(EndpointTracesBridge(skywalkingClient)).await() vertx.deployVerticle(LogsBridge(skywalkingClient)).await() - if (SourceServices.Instance.liveService == null) { + if (project.getUserData(LIVE_SERVICE) == null) { val swLiveService = SWLiveService() vertx.deployVerticle(swLiveService).await() - SourceServices.Instance.liveService = swLiveService - project.putUserData(LIVE_SERVICE, swLiveService) } - if (SourceServices.Instance.liveView == null) { + if (project.getUserData(LIVE_VIEW_SERVICE) == null) { val swLiveViewService = SWLiveViewService() vertx.deployVerticle(swLiveViewService).await() - SourceServices.Instance.liveView = swLiveViewService - project.putUserData(LIVE_VIEW_SERVICE, swLiveViewService) } diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointBridge.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointBridge.kt index 9d832bce8..ee05a7a15 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointBridge.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointBridge.kt @@ -16,13 +16,13 @@ */ package spp.jetbrains.monitor.skywalking.bridge +import com.intellij.openapi.diagnostic.logger import io.vertx.core.Vertx import io.vertx.core.json.JsonObject import io.vertx.kotlin.coroutines.CoroutineVerticle import io.vertx.kotlin.coroutines.await import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.launch -import org.slf4j.LoggerFactory import spp.jetbrains.monitor.skywalking.SkywalkingClient import spp.protocol.marshall.LocalMessageCodec @@ -74,7 +74,7 @@ class EndpointBridge(private val skywalkingClient: SkywalkingClient) : Coroutine * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ companion object { - private val log = LoggerFactory.getLogger(EndpointBridge::class.java) + private val log = logger() private const val rootAddress = "monitor.skywalking.endpoint" private const val searchExactEndpointAddress = "$rootAddress.searchExactEndpoint" diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/ServiceBridge.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/ServiceBridge.kt index a74279492..5dff33bb3 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/ServiceBridge.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/ServiceBridge.kt @@ -16,13 +16,13 @@ */ package spp.jetbrains.monitor.skywalking.bridge +import com.intellij.openapi.diagnostic.logger import io.vertx.core.Vertx import io.vertx.core.eventbus.MessageConsumer import io.vertx.kotlin.coroutines.CoroutineVerticle import io.vertx.kotlin.coroutines.await import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.launch -import org.slf4j.LoggerFactory import spp.jetbrains.monitor.skywalking.SkywalkingClient import spp.jetbrains.monitor.skywalking.SkywalkingClient.DurationStep import spp.protocol.platform.general.Service @@ -81,11 +81,11 @@ class ServiceBridge( if (initServiceName != null) { currentService = activeServices.find { it.name == initServiceName } - currentService?.let { log.info("Current service set to: {}", it.name) } + currentService?.let { log.info("Current service set to: ${it.name}") } } if (currentService == null) { currentService = activeServices[0] - log.info("Current service set to: {}", currentService!!.name) + log.info("Current service set to: ${currentService!!.name}") } vertx.eventBus().publish(currentServiceUpdatedAddress, currentService) return true @@ -94,7 +94,7 @@ class ServiceBridge( } companion object { - private val log = LoggerFactory.getLogger(ServiceBridge::class.java) + private val log = logger() private const val rootAddress = "monitor.skywalking.service" private const val getCurrentServiceAddress = "$rootAddress.currentService" diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/service/SWLiveViewService.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/service/SWLiveViewService.kt index 4e0fb565a..914335467 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/service/SWLiveViewService.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/service/SWLiveViewService.kt @@ -16,6 +16,7 @@ */ package spp.jetbrains.monitor.skywalking.service +import com.intellij.openapi.diagnostic.logger import io.vertx.core.Future import io.vertx.core.eventbus.ReplyException import io.vertx.core.json.JsonArray @@ -24,7 +25,6 @@ import io.vertx.kotlin.coroutines.CoroutineVerticle import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.launch import kotlinx.datetime.toJavaInstant -import org.slf4j.LoggerFactory import spp.jetbrains.monitor.skywalking.SkywalkingClient import spp.jetbrains.monitor.skywalking.bridge.EndpointMetricsBridge import spp.jetbrains.monitor.skywalking.bridge.EndpointTracesBridge @@ -57,7 +57,7 @@ class SWLiveViewService : CoroutineVerticle(), LiveViewService { .appendPattern("yyyyMMddHHmm") .toFormatter() .withZone(ZoneOffset.UTC) - private val log = LoggerFactory.getLogger(SWLiveViewService::class.java) + private val log = logger() } data class SWLiveViewSubscription( diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index baf1236d8..b177cf275 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -99,8 +99,6 @@ dependencies { implementation("org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5") implementation("org.apache.commons:commons-lang3:3.12.0") implementation("eu.geekplace.javapinning:java-pinning-core:1.2.0") - implementation("ch.qos.logback:logback-core:1.2.11") - implementation("ch.qos.logback:logback-classic:1.2.11") implementation("info.debatty:java-string-similarity:2.0.0") testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.0") diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.form b/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.form index a0ff1670c..4dd8774e5 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.form +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.form @@ -21,7 +21,7 @@ - + @@ -56,19 +56,9 @@ - - - - - - - - - - - + diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.java index 85844a9de..f3d6c7fa1 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.java @@ -43,7 +43,6 @@ public class PluginConfigurationPanel { private JPanel myGlobalSettingsPanel; private JTextField rootSourcePackageTextField; private JCheckBox autoResolveEndpointNamesCheckBox; - private JCheckBox debugConsoleCheckBox; private JPanel myServiceSettingsPanel; private JTextField serviceHostTextField; private JTextField accessTokenTextField; @@ -83,14 +82,12 @@ public PluginConfigurationPanel(SourceMarkerConfig config, List availab certificatePinsLabel.setText(message("certificate_pins")); serviceLabel.setText(message("service")); rootSourcePackageLabel.setText(message("root_source_package")); - debugConsoleCheckBox.setText(message("debug_console")); autoResolveEndpointNamesCheckBox.setText(message("auto_resolve_endpoint_names")); } private void setUIEnabled(boolean enabled) { rootSourcePackageTextField.setEnabled(enabled); autoResolveEndpointNamesCheckBox.setEnabled(enabled); - debugConsoleCheckBox.setEnabled(enabled); serviceHostTextField.setEnabled(enabled); accessTokenTextField.setEnabled(enabled); serviceComboBox.setEnabled(enabled); @@ -114,9 +111,6 @@ boolean isModified() { if (!Objects.equals(autoResolveEndpointNamesCheckBox.isSelected(), config.getAutoResolveEndpointNames())) { return true; } - if (!Objects.equals(debugConsoleCheckBox.isSelected(), config.getPluginConsoleEnabled())) { - return true; - } if (!Objects.equals(serviceHostTextField.getText(), config.getServiceHost() != null ? config.getServiceHost() : "")) { return true; } @@ -149,7 +143,7 @@ public SourceMarkerConfig getPluginConfig() { Arrays.stream(rootSourcePackageTextField.getText().split(",")) .map(String::trim).collect(Collectors.toList()), autoResolveEndpointNamesCheckBox.isSelected(), - true, debugConsoleCheckBox.isSelected(), + true, serviceHostTextField.getText(), accessTokenTextField.getText(), new ArrayList<>(Collections.list(myCertificatePins.listModel.elements())), @@ -166,7 +160,6 @@ public void applySourceMarkerConfig(SourceMarkerConfig config) { this.config = config; rootSourcePackageTextField.setText(String.join(",", config.getRootSourcePackages())); autoResolveEndpointNamesCheckBox.setSelected(config.getAutoResolveEndpointNames()); - debugConsoleCheckBox.setSelected(config.getPluginConsoleEnabled()); serviceHostTextField.setText(config.getServiceHost()); accessTokenTextField.setText(config.getAccessToken()); verifyHostCheckBox.setSelected(config.getVerifyHost()); diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/BreakpointStatusBar.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/BreakpointStatusBar.java index b075b7ab5..93c514ec8 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/BreakpointStatusBar.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/BreakpointStatusBar.java @@ -29,6 +29,7 @@ import com.intellij.util.ui.ListTableModel; import com.intellij.util.ui.UIUtil; import io.vertx.core.json.JsonObject; +import liveplugin.implementation.plugin.LiveStatusManager; import net.miginfocom.swing.MigLayout; import org.apache.commons.lang.StringUtils; import org.jetbrains.annotations.NotNull; @@ -39,7 +40,6 @@ import spp.jetbrains.sourcemarker.PluginUI; import spp.jetbrains.sourcemarker.status.util.AutocompleteFieldRow; import spp.jetbrains.sourcemarker.mark.SourceMarkKeys; -import spp.jetbrains.sourcemarker.service.InstrumentEventListener; import spp.jetbrains.sourcemarker.service.instrument.breakpoint.BreakpointHitColumnInfo; import spp.jetbrains.sourcemarker.service.instrument.breakpoint.BreakpointHitWindowService; import spp.jetbrains.sourcemarker.settings.LiveBreakpointConfigurationPanel; @@ -53,6 +53,7 @@ import spp.protocol.instrument.throttle.InstrumentThrottle; import spp.protocol.instrument.throttle.ThrottleStep; import spp.protocol.marshall.ProtocolMarshaller; +import spp.protocol.service.listen.LiveInstrumentEventListener; import javax.swing.*; import javax.swing.border.CompoundBorder; @@ -70,15 +71,15 @@ import java.util.function.Function; import java.util.stream.Collectors; +import static spp.jetbrains.monitor.skywalking.SkywalkingMonitor.LIVE_INSTRUMENT_SERVICE; import static spp.jetbrains.sourcemarker.PluginBundle.message; import static spp.jetbrains.sourcemarker.PluginUI.*; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; -import static spp.protocol.SourceServices.Instance.INSTANCE; import static spp.protocol.instrument.event.LiveInstrumentEventType.BREAKPOINT_HIT; import static spp.protocol.instrument.event.LiveInstrumentEventType.BREAKPOINT_REMOVED; import static spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved; -public class BreakpointStatusBar extends JPanel implements StatusBar, InstrumentEventListener, VisibleAreaListener { +public class BreakpointStatusBar extends JPanel implements StatusBar, LiveInstrumentEventListener, VisibleAreaListener { private final InlayMark inlayMark; private final LiveSourceLocation sourceLocation; @@ -202,7 +203,7 @@ private void removeActiveDecorations() { } private void setupAsActive() { - LiveStatusManager.INSTANCE.addStatusBar(inlayMark, event -> { + LiveStatusManager.getInstance(inlayMark.getProject()).addStatusBar(inlayMark, event -> { if (statusPanel == null) return; if (event.getEventType() == BREAKPOINT_HIT) { commandModel.insertRow(0, event); @@ -486,11 +487,11 @@ private void saveLiveBreakpoint() { throttle, meta ); - INSTANCE.getLiveInstrument().addLiveInstrument(instrument).onComplete(it -> { + inlayMark.getProject().getUserData(LIVE_INSTRUMENT_SERVICE).addLiveInstrument(instrument).onComplete(it -> { if (it.succeeded()) { liveBreakpoint = (LiveBreakpoint) it.result(); inlayMark.putUserData(SourceMarkKeys.INSTANCE.getINSTRUMENT_ID(), liveBreakpoint.getId()); - LiveStatusManager.INSTANCE.addActiveLiveInstrument(liveBreakpoint); + LiveStatusManager.getInstance(inlayMark.getProject()).addActiveLiveInstrument(liveBreakpoint); } else { it.cause().printStackTrace(); } @@ -510,9 +511,9 @@ private void dispose() { if (groupedMarks != null) groupedMarks.forEach(SourceMark::dispose); if (liveBreakpoint != null) { - INSTANCE.getLiveInstrument().removeLiveInstrument(liveBreakpoint.getId()).onComplete(it -> { + inlayMark.getProject().getUserData(LIVE_INSTRUMENT_SERVICE).removeLiveInstrument(liveBreakpoint.getId()).onComplete(it -> { if (it.succeeded()) { - LiveStatusManager.INSTANCE.removeActiveLiveInstrument(liveBreakpoint); + LiveStatusManager.getInstance(inlayMark.getProject()).removeActiveLiveInstrument(liveBreakpoint); } else { it.cause().printStackTrace(); } diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LiveMeterStatusPanel.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LiveMeterStatusPanel.java index c766058bc..aa299d526 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LiveMeterStatusPanel.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LiveMeterStatusPanel.java @@ -21,16 +21,17 @@ import com.jgoodies.forms.layout.*; import io.vertx.core.json.Json; import io.vertx.core.json.JsonObject; +import liveplugin.implementation.plugin.LiveStatusManager; import org.apache.commons.lang.WordUtils; import org.jetbrains.annotations.NotNull; import spp.jetbrains.marker.source.mark.gutter.GutterMark; import spp.jetbrains.sourcemarker.PluginIcons; -import spp.jetbrains.sourcemarker.service.InstrumentEventListener; -import spp.jetbrains.sourcemarker.service.ViewEventListener; import spp.protocol.instrument.LiveMeter; import spp.protocol.instrument.event.LiveInstrumentEvent; import spp.protocol.instrument.event.LiveInstrumentEventType; import spp.protocol.instrument.meter.MeterType; +import spp.protocol.service.listen.LiveInstrumentEventListener; +import spp.protocol.service.listen.LiveViewEventListener; import spp.protocol.view.LiveViewEvent; import javax.swing.*; @@ -39,12 +40,12 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import static spp.jetbrains.monitor.skywalking.SkywalkingMonitor.LIVE_INSTRUMENT_SERVICE; import static spp.jetbrains.sourcemarker.PluginBundle.message; import static spp.jetbrains.sourcemarker.PluginUI.*; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; -import static spp.protocol.SourceServices.Instance.INSTANCE; -public class LiveMeterStatusPanel extends JPanel implements InstrumentEventListener, ViewEventListener { +public class LiveMeterStatusPanel extends JPanel implements LiveInstrumentEventListener, LiveViewEventListener { private final LiveMeter liveMeter; private final GutterMark gutterMark; @@ -79,7 +80,7 @@ public LiveMeterStatusPanel(LiveMeter liveMeter, GutterMark gutterMark) { dayLabel.setVisible(false); dayValueLabel.setVisible(false); } - LiveStatusManager.addViewEventListener(gutterMark, this); + LiveStatusManager.getInstance(gutterMark.getProject()).addViewEventListener(gutterMark, this); } @Override @@ -122,10 +123,10 @@ public void mouseMoved(MouseEvent e) { addRecursiveMouseListener(closeLabel, new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - INSTANCE.getLiveInstrument().removeLiveInstrument(liveMeter.getId()).onComplete(it -> { + gutterMark.getProject().getUserData(LIVE_INSTRUMENT_SERVICE).removeLiveInstrument(liveMeter.getId()).onComplete(it -> { if (it.succeeded()) { gutterMark.dispose(); - LiveStatusManager.INSTANCE.removeActiveLiveInstrument(liveMeter); + LiveStatusManager.getInstance(gutterMark.getProject()).removeActiveLiveInstrument(liveMeter); } else { it.cause().printStackTrace(); } diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LogStatusBar.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LogStatusBar.java index 47c084765..35f3ae2f3 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LogStatusBar.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LogStatusBar.java @@ -30,6 +30,7 @@ import com.intellij.util.ui.UIUtil; import io.vertx.core.json.Json; import io.vertx.core.json.JsonObject; +import liveplugin.implementation.plugin.LiveStatusManager; import net.miginfocom.swing.MigLayout; import org.jetbrains.annotations.NotNull; import spp.jetbrains.marker.impl.InstrumentConditionParser; @@ -38,8 +39,6 @@ import spp.jetbrains.sourcemarker.PluginUI; import spp.jetbrains.sourcemarker.status.util.AutocompleteFieldRow; import spp.jetbrains.sourcemarker.mark.SourceMarkKeys; -import spp.jetbrains.sourcemarker.service.InstrumentEventListener; -import spp.jetbrains.sourcemarker.service.ViewEventListener; import spp.jetbrains.sourcemarker.service.instrument.log.LogHitColumnInfo; import spp.jetbrains.sourcemarker.service.instrument.log.VariableParser; import spp.jetbrains.sourcemarker.settings.LiveLogConfigurationPanel; @@ -56,6 +55,8 @@ import spp.protocol.instrument.throttle.InstrumentThrottle; import spp.protocol.instrument.throttle.ThrottleStep; import spp.protocol.marshall.ProtocolMarshaller; +import spp.protocol.service.listen.LiveInstrumentEventListener; +import spp.protocol.service.listen.LiveViewEventListener; import spp.protocol.view.LiveViewEvent; import javax.swing.*; @@ -87,16 +88,16 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import static spp.jetbrains.monitor.skywalking.SkywalkingMonitor.LIVE_INSTRUMENT_SERVICE; import static spp.jetbrains.sourcemarker.PluginBundle.message; import static spp.jetbrains.sourcemarker.PluginUI.*; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; -import static spp.protocol.SourceServices.Instance.INSTANCE; import static spp.protocol.instrument.event.LiveInstrumentEventType.LOG_HIT; import static spp.protocol.instrument.event.LiveInstrumentEventType.LOG_REMOVED; import static spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved; public class LogStatusBar extends JPanel implements StatusBar, VisibleAreaListener, - InstrumentEventListener, ViewEventListener { + LiveInstrumentEventListener, LiveViewEventListener { private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("hh:mm:ss a") .withZone(ZoneId.systemDefault()); @@ -178,7 +179,7 @@ public Icon getUnselectedIcon() { setupComponents(); if (watchExpression) { - LiveStatusManager.addViewEventListener(inlayMark, this); + LiveStatusManager.getInstance(inlayMark.getProject()).addViewEventListener(inlayMark, this); liveLogTextField.setCanShowSaveButton(false); liveLogTextField.setEditMode(false); removeActiveDecorations(); @@ -187,7 +188,7 @@ public Icon getUnselectedIcon() { addExpandButton(); initCommandModel(); } else { - LiveStatusManager.addStatusBar(inlayMark, this); + LiveStatusManager.getInstance(inlayMark.getProject()).addStatusBar(inlayMark, this); showEditableMode(); liveLogTextField.setEditMode(true); liveLogTextField.addSaveListener(this::saveLiveLog); @@ -203,7 +204,7 @@ public void setLiveInstrument(LiveInstrument liveInstrument) { displayTimeField(); addExpandButton(); repaint(); - LiveStatusManager.addStatusBar(inlayMark, this); + LiveStatusManager.getInstance(inlayMark.getProject()).addStatusBar(inlayMark, this); } private void initCommandModel() { @@ -215,7 +216,7 @@ private void initCommandModel() { new LogHitColumnInfo(TIME) }, new ArrayList<>(), 0, SortOrder.DESCENDING); } else { - List logData = LiveStatusManager.INSTANCE.getLogData(inlayMark); + List logData = LiveStatusManager.getInstance(inlayMark.getProject()).getLogData(inlayMark); if (logData.isEmpty()) { liveLogTextField.setPlaceHolderText(WAITING_FOR_LIVE_LOG_DATA); } else { @@ -641,9 +642,9 @@ private void saveLiveLog() { latestTime = null; latestLog = null; - INSTANCE.getLiveInstrument().removeLiveInstrument(oldLiveLog.getId()).onComplete(it -> { + inlayMark.getProject().getUserData(LIVE_INSTRUMENT_SERVICE).removeLiveInstrument(oldLiveLog.getId()).onComplete(it -> { if (it.succeeded()) { - LiveStatusManager.INSTANCE.removeActiveLiveInstrument(oldLiveLog); + LiveStatusManager.getInstance(inlayMark.getProject()).removeActiveLiveInstrument(oldLiveLog); } else { it.cause().printStackTrace(); } @@ -700,11 +701,11 @@ private void saveLiveLog() { displayTimeField(); wrapper.grabFocus(); - INSTANCE.getLiveInstrument().addLiveInstrument(instrument).onComplete(it -> { + inlayMark.getProject().getUserData(LIVE_INSTRUMENT_SERVICE).addLiveInstrument(instrument).onComplete(it -> { if (it.succeeded()) { liveLog = (LiveLog) it.result(); inlayMark.putUserData(SourceMarkKeys.INSTANCE.getINSTRUMENT_ID(), it.result().getId()); - LiveStatusManager.INSTANCE.addActiveLiveInstrument(liveLog); + LiveStatusManager.getInstance(inlayMark.getProject()).addActiveLiveInstrument(liveLog); inlayMark.getUserData(SourceMarkKeys.INSTANCE.getLOGGER_DETECTOR()) .addLiveLog(editor, inlayMark, finalLogPattern, sourceLocation.getLine()); @@ -724,10 +725,10 @@ private void dispose() { } if (liveLog != null) { - LiveStatusManager.INSTANCE.removeLogData(inlayMark); - INSTANCE.getLiveInstrument().removeLiveInstrument(liveLog.getId()).onComplete(it -> { + LiveStatusManager.getInstance(inlayMark.getProject()).removeLogData(inlayMark); + inlayMark.getProject().getUserData(LIVE_INSTRUMENT_SERVICE).removeLiveInstrument(liveLog.getId()).onComplete(it -> { if (it.succeeded()) { - LiveStatusManager.INSTANCE.removeActiveLiveInstrument(liveLog); + LiveStatusManager.getInstance(inlayMark.getProject()).removeActiveLiveInstrument(liveLog); } else { it.cause().printStackTrace(); } diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/MeterStatusBar.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/MeterStatusBar.java index 916d2036f..869f3cd02 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/MeterStatusBar.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/MeterStatusBar.java @@ -28,6 +28,7 @@ import com.intellij.util.ui.ListTableModel; import com.intellij.util.ui.UIUtil; import io.vertx.core.json.JsonObject; +import liveplugin.implementation.plugin.LiveStatusManager; import net.miginfocom.swing.MigLayout; import spp.jetbrains.marker.impl.InstrumentConditionParser; import spp.jetbrains.marker.source.mark.api.SourceMark; @@ -60,11 +61,11 @@ import java.util.List; import java.util.concurrent.atomic.AtomicLong; +import static spp.jetbrains.monitor.skywalking.SkywalkingMonitor.LIVE_INSTRUMENT_SERVICE; import static spp.jetbrains.sourcemarker.PluginBundle.message; import static spp.jetbrains.sourcemarker.PluginUI.*; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; import static spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved; -import static spp.protocol.SourceServices.Instance.INSTANCE; import static spp.protocol.instrument.event.LiveInstrumentEventType.METER_REMOVED; public class MeterStatusBar extends JPanel implements StatusBar, VisibleAreaListener { @@ -141,7 +142,7 @@ private void removeActiveDecorations() { } private void setupAsActive() { - LiveStatusManager.INSTANCE.addStatusBar(inlayMark, event -> { + LiveStatusManager.getInstance(inlayMark.getProject()).addStatusBar(inlayMark, event -> { if (statusPanel == null) return; if (event.getEventType() == METER_REMOVED) { configLabel.setIcon(PluginIcons.eyeSlash); @@ -391,17 +392,17 @@ private void saveLiveMeter() { null, meta ); - INSTANCE.getLiveInstrument().addLiveInstrument(instrument).onComplete(it -> { + inlayMark.getProject().getUserData(LIVE_INSTRUMENT_SERVICE).addLiveInstrument(instrument).onComplete(it -> { if (it.succeeded()) { liveMeter = (LiveMeter) it.result(); - LiveStatusManager.INSTANCE.addActiveLiveInstrument(liveMeter); + LiveStatusManager.getInstance(inlayMark.getProject()).addActiveLiveInstrument(liveMeter); ApplicationManager.getApplication().invokeLater(() -> { inlayMark.dispose(); //dispose this bar //create gutter popup ApplicationManager.getApplication().runReadAction(() - -> LiveStatusManager.showMeterStatusIcon(liveMeter, inlayMark.getSourceFileMarker())); + -> LiveStatusManager.getInstance(inlayMark.getProject()).showMeterStatusIcon(liveMeter, inlayMark.getSourceFileMarker())); }); } else { it.cause().printStackTrace(); @@ -422,9 +423,9 @@ private void dispose() { if (groupedMarks != null) groupedMarks.forEach(SourceMark::dispose); if (liveMeter != null) { - INSTANCE.getLiveInstrument().removeLiveInstrument(liveMeter.getId()).onComplete(it -> { + inlayMark.getProject().getUserData(LIVE_INSTRUMENT_SERVICE).removeLiveInstrument(liveMeter.getId()).onComplete(it -> { if (it.succeeded()) { - LiveStatusManager.INSTANCE.removeActiveLiveInstrument(liveMeter); + LiveStatusManager.getInstance(inlayMark.getProject()).removeActiveLiveInstrument(liveMeter); } else { it.cause().printStackTrace(); } diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/SpanStatusBar.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/SpanStatusBar.java index f6b544673..ff7daca00 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/SpanStatusBar.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/SpanStatusBar.java @@ -28,6 +28,7 @@ import com.intellij.util.ui.ListTableModel; import com.intellij.util.ui.UIUtil; import io.vertx.core.json.JsonObject; +import liveplugin.implementation.plugin.LiveStatusManager; import net.miginfocom.swing.MigLayout; import spp.jetbrains.marker.impl.InstrumentConditionParser; import spp.jetbrains.marker.source.mark.api.SourceMark; @@ -57,11 +58,11 @@ import java.util.List; import java.util.concurrent.atomic.AtomicLong; +import static spp.jetbrains.monitor.skywalking.SkywalkingMonitor.LIVE_INSTRUMENT_SERVICE; import static spp.jetbrains.sourcemarker.PluginBundle.message; import static spp.jetbrains.sourcemarker.PluginUI.*; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; import static spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved; -import static spp.protocol.SourceServices.Instance.INSTANCE; import static spp.protocol.instrument.event.LiveInstrumentEventType.METER_REMOVED; public class SpanStatusBar extends JPanel implements StatusBar, VisibleAreaListener { @@ -138,7 +139,7 @@ private void removeActiveDecorations() { } private void setupAsActive() { - LiveStatusManager.INSTANCE.addStatusBar(inlayMark, event -> { + LiveStatusManager.getInstance(inlayMark.getProject()).addStatusBar(inlayMark, event -> { if (statusPanel == null) return; if (event.getEventType() == METER_REMOVED) { configLabel.setIcon(PluginIcons.eyeSlash); @@ -376,10 +377,10 @@ private void saveLiveSpan() { null, meta ); - INSTANCE.getLiveInstrument().addLiveInstrument(instrument).onComplete(it -> { + inlayMark.getProject().getUserData(LIVE_INSTRUMENT_SERVICE).addLiveInstrument(instrument).onComplete(it -> { if (it.succeeded()) { liveSpan = (LiveSpan) it.result(); - LiveStatusManager.INSTANCE.addActiveLiveInstrument(liveSpan); + LiveStatusManager.getInstance(inlayMark.getProject()).addActiveLiveInstrument(liveSpan); ApplicationManager.getApplication().invokeLater(() -> { inlayMark.dispose(); //dispose this bar @@ -403,9 +404,9 @@ private void dispose() { if (groupedMarks != null) groupedMarks.forEach(SourceMark::dispose); if (liveSpan != null) { - INSTANCE.getLiveInstrument().removeLiveInstrument(liveSpan.getId()).onComplete(it -> { + inlayMark.getProject().getUserData(LIVE_INSTRUMENT_SERVICE).removeLiveInstrument(liveSpan.getId()).onComplete(it -> { if (it.succeeded()) { - LiveStatusManager.INSTANCE.removeActiveLiveInstrument(liveSpan); + LiveStatusManager.getInstance(inlayMark.getProject()).removeActiveLiveInstrument(liveSpan); } else { it.cause().printStackTrace(); } diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/SourceMarkerPlugin.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/SourceMarkerPlugin.kt index 45ed29fb2..d1e3b8434 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/SourceMarkerPlugin.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/SourceMarkerPlugin.kt @@ -18,6 +18,7 @@ package spp.jetbrains.sourcemarker import com.apollographql.apollo3.exception.ApolloHttpException import com.fasterxml.jackson.core.JacksonException +import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.dataformat.yaml.YAMLMapper import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer @@ -27,11 +28,13 @@ import com.intellij.notification.NotificationType import com.intellij.notification.Notifications import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.progress.Task import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project +import com.intellij.openapi.util.Key import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.openapi.vfs.newvfs.BulkFileListener import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent @@ -57,8 +60,8 @@ import io.vertx.serviceproxy.ServiceProxyBuilder import kotlinx.coroutines.* import liveplugin.implementation.LivePluginProjectLoader import liveplugin.implementation.plugin.LivePluginService +import liveplugin.implementation.plugin.LiveStatusManager import org.apache.commons.text.CaseUtils -import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.jvm.ArtifactSearch import spp.jetbrains.marker.jvm.JVMMarker @@ -79,9 +82,8 @@ import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import spp.jetbrains.sourcemarker.settings.getServicePortNormalized import spp.jetbrains.sourcemarker.settings.isSsl import spp.jetbrains.sourcemarker.settings.serviceHostNormalized -import spp.jetbrains.sourcemarker.status.LiveStatusManager +import spp.jetbrains.sourcemarker.status.LiveStatusManagerImpl import spp.protocol.SourceServices -import spp.protocol.SourceServices.Instance import spp.protocol.service.LiveInstrumentService import spp.protocol.service.LiveService import spp.protocol.service.LiveViewService @@ -96,18 +98,32 @@ import javax.net.ssl.SSLHandshakeException * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ @Suppress("MagicNumber") -object SourceMarkerPlugin { +class SourceMarkerPlugin(val project: Project) { + + companion object { + private const val SPP_PLUGIN_YML_PATH = ".spp/spp-plugin.yml" + private val log = logger() + private val KEY = Key.create("SPP_SOURCE_MARKER_PLUGIN") + + @Synchronized + fun getInstance(project: Project): SourceMarkerPlugin { + if (project.getUserData(KEY) == null) { + val sourceMarkerPlugin = SourceMarkerPlugin(project) + project.putUserData(KEY, sourceMarkerPlugin) + project.putUserData(SourceMarker.VERTX_KEY, sourceMarkerPlugin.vertx) + } + return project.getUserData(KEY)!! + } + } - private const val SPP_PLUGIN_YML_PATH = ".spp/spp-plugin.yml" - private val log = LoggerFactory.getLogger(SourceMarkerPlugin::class.java) private val deploymentIds = mutableListOf() - val vertx: Vertx private var connectionJob: Job? = null private var discovery: ServiceDiscovery? = null private var addedConfigListener = false + val vertx: Vertx init { - SourceMarker.enabled = false + SourceMarker.getInstance(project).enabled = false val options = if (System.getProperty("sourcemarker.debug.unblocked_threads", "false")!!.toBoolean()) { log.info("Removed blocked thread checker") VertxOptions().setBlockedThreadCheckInterval(Int.MAX_VALUE.toLong()) @@ -127,16 +143,14 @@ object SourceMarkerPlugin { } suspend fun init( - project: Project, configInput: SourceMarkerConfig? = null, notifySuccessfulConnection: Boolean = false ) { - log.info("Initializing SourceMarkerPlugin on project: {}", project) + log.info("Initializing SourceMarkerPlugin on project: $project") restartIfNecessary() - LivePluginProjectLoader.projectClosing(project) LivePluginProjectLoader.projectOpened(project) - val config = configInput ?: getConfig(project) + val config = configInput ?: getConfig() if (!addedConfigListener) { addedConfigListener = true val localConfigListener = object : BulkFileListener { @@ -146,10 +160,10 @@ object SourceMarkerPlugin { if (event is VFileContentChangeEvent && event.isFromSave && event.path.endsWith(SPP_PLUGIN_YML_PATH)) { if (event.oldTimestamp <= lastUpdated) return else lastUpdated = event.oldTimestamp DumbService.getInstance(project).smartInvokeLater { - val localConfig = loadSppPluginFileConfiguration(project) + val localConfig = loadSppPluginFileConfiguration() if (localConfig != null && localConfig.override) { runBlocking { - init(project, localConfig, true) + init(localConfig, true) } } } @@ -178,8 +192,8 @@ object SourceMarkerPlugin { connectionJob = GlobalScope.launch(vertx.dispatcher()) { var connectedMonitor = false try { - initServices(project, config) - initMonitor(project, config) + initServices(config) + initMonitor(config) connectedMonitor = true if (notifySuccessfulConnection) { @@ -250,7 +264,7 @@ object SourceMarkerPlugin { ) ) } - log.error("Connection failed. Reason: {}", throwable.message) + log.error("Connection failed", throwable) } if (connectedMonitor) { @@ -260,19 +274,19 @@ object SourceMarkerPlugin { ProgressManager.getInstance() .run(object : Task.Backgroundable(project, "Loading Source++ plugins", false, ALWAYS_BACKGROUND) { override fun run(indicator: ProgressIndicator) { - log.info("Loading live plugins") + log.info("Loading live plugins for project: $project") project.getUserData(LivePluginService.LIVE_PLUGIN_LOADER)!!.invoke() - log.info("Loaded live plugins") + log.info("Loaded live plugins for project: $project") pluginsPromise.complete() } }) pluginsPromise.future().await() - initMarker(config, project) + initMarker(config) } } } - fun loadSppPluginFileConfiguration(project: Project): SourceMarkerConfig? { + fun loadSppPluginFileConfiguration(): SourceMarkerConfig? { if (project.basePath != null) { val configFile = File(project.basePath, SPP_PLUGIN_YML_PATH) if (configFile.exists()) { @@ -281,7 +295,7 @@ object SourceMarkerPlugin { ObjectMapper().writeValueAsString(YAMLMapper().readValue(configFile, Object::class.java)) ) } catch (ex: JacksonException) { - log.error("Failed to parse config file {}", configFile.absolutePath, ex) + log.error("Failed to parse config file ${configFile.absolutePath}", ex) return null } @@ -290,7 +304,10 @@ object SourceMarkerPlugin { config.put("commandConfig", commandConfig) return try { - Json.decodeValue(config.toString(), SourceMarkerConfig::class.java) + val objectMapper = ObjectMapper() + //ignore unknown properties (i.e old settings) + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + objectMapper.readValue(config.toString(), SourceMarkerConfig::class.java) } catch (ex: DecodeException) { log.warn("Failed to decode $SPP_PLUGIN_YML_PATH", ex) return null @@ -313,8 +330,8 @@ object SourceMarkerPlugin { return result } - fun getConfig(project: Project): SourceMarkerConfig { - val fileConfig = loadSppPluginFileConfiguration(project) + fun getConfig(): SourceMarkerConfig { + val fileConfig = loadSppPluginFileConfiguration() val config = if (fileConfig != null && fileConfig.override) { fileConfig } else { @@ -343,7 +360,7 @@ object SourceMarkerPlugin { return null } - private suspend fun discoverAvailableServices(config: SourceMarkerConfig, project: Project) { + private suspend fun discoverAvailableServices(config: SourceMarkerConfig) { val originalClassLoader = Thread.currentThread().contextClassLoader try { Thread.currentThread().contextClassLoader = javaClass.classLoader @@ -353,25 +370,29 @@ object SourceMarkerPlugin { JsonObject() .put("backend-name", "tcp-service-discovery") .put("sourcemarker_plugin_config", JsonObject.mapFrom(config)) + .put("project_location_hash", project.locationHash) ) ) } finally { Thread.currentThread().contextClassLoader = originalClassLoader } + val liveStatusManager = LiveStatusManagerImpl(project) + project.putUserData(LiveStatusManager.KEY, liveStatusManager) + log.info("Discovering available services") val availableRecords = discovery!!.getRecords { true }.await() - log.info("Discovered {} services", availableRecords.size) + log.info("Discovered $availableRecords.size services") //live service if (availableRecords.any { it.name == SourceServices.Utilize.LIVE_SERVICE }) { log.info("Live service available") - Instance.liveService = ServiceProxyBuilder(vertx) + val liveService = ServiceProxyBuilder(vertx) .apply { config.serviceToken?.let { setToken(it) } } .setAddress(SourceServices.Utilize.LIVE_SERVICE) .build(LiveService::class.java) - project.putUserData(SkywalkingMonitor.LIVE_SERVICE, Instance.liveService) + project.putUserData(SkywalkingMonitor.LIVE_SERVICE, liveService) } else { log.warn("Live service unavailable") } @@ -379,13 +400,13 @@ object SourceMarkerPlugin { //live instrument if (availableRecords.any { it.name == SourceServices.Utilize.LIVE_INSTRUMENT }) { log.info("Live instruments available") - SourceMarker.addGlobalSourceMarkEventListener(LiveStatusManager) + SourceMarker.getInstance(project).addGlobalSourceMarkEventListener(liveStatusManager) - Instance.liveInstrument = ServiceProxyBuilder(vertx) + val liveInstrument = ServiceProxyBuilder(vertx) .apply { config.serviceToken?.let { setToken(it) } } .setAddress(SourceServices.Utilize.LIVE_INSTRUMENT) .build(LiveInstrumentService::class.java) - project.putUserData(SkywalkingMonitor.LIVE_INSTRUMENT_SERVICE, Instance.liveInstrument) + project.putUserData(SkywalkingMonitor.LIVE_INSTRUMENT_SERVICE, liveInstrument) ApplicationManager.getApplication().invokeLater { BreakpointHitWindowService.getInstance(project).showEventsWindow() @@ -401,13 +422,13 @@ object SourceMarkerPlugin { //live view if (availableRecords.any { it.name == SourceServices.Utilize.LIVE_VIEW }) { log.info("Live views available") - Instance.liveView = ServiceProxyBuilder(vertx) + val liveView = ServiceProxyBuilder(vertx) .apply { config.serviceToken?.let { setToken(it) } } .setAddress(SourceServices.Utilize.LIVE_VIEW) .build(LiveViewService::class.java) - project.putUserData(SkywalkingMonitor.LIVE_VIEW_SERVICE, Instance.liveView) + project.putUserData(SkywalkingMonitor.LIVE_VIEW_SERVICE, liveView) - val viewListener = LiveViewManager(config) + val viewListener = LiveViewManager(project, config) GlobalScope.launch(vertx.dispatcher()) { deploymentIds.add(vertx.deployVerticle(viewListener).await()) } @@ -417,25 +438,25 @@ object SourceMarkerPlugin { } private suspend fun restartIfNecessary() { - if (SourceMarker.enabled) { - SourceMarker.clearAvailableSourceFileMarkers() - SourceMarker.clearGlobalSourceMarkEventListeners() + if (SourceMarker.getInstance(project).enabled) { + SourceMarker.getInstance(project).clearAvailableSourceFileMarkers() + SourceMarker.getInstance(project).clearGlobalSourceMarkEventListeners() } - SourceMarker.enabled = false + SourceMarker.getInstance(project).enabled = false + + project.getUserData(LivePluginService.KEY)?.reset() deploymentIds.forEach { vertx.undeploy(it).await() } deploymentIds.clear() - TCPServiceDiscoveryBackend.socket?.close()?.await() - TCPServiceDiscoveryBackend.socket = null + TCPServiceDiscoveryBackend.closeSocket(project) discovery?.close() discovery = null - Instance.clearServices() ControlBarController.clearAvailableCommands() } - private suspend fun initServices(project: Project, config: SourceMarkerConfig) { + private suspend fun initServices(config: SourceMarkerConfig) { if (!config.serviceHost.isNullOrBlank()) { val certificatePins = mutableListOf() certificatePins.addAll(config.certificatePins) @@ -492,23 +513,23 @@ object SourceMarkerPlugin { config.serviceToken = body } - discoverAvailableServices(config, project) + discoverAvailableServices(config) } else { config.serviceToken = null } } else { //try default local access try { - tryDefaultAccess(true, config, project) + tryDefaultAccess(true, config) } catch (ignore: SSLHandshakeException) { - tryDefaultAccess(false, config, project) + tryDefaultAccess(false, config) } catch (e: Exception) { log.warn("Unable to find local live platform", e) } } } - private suspend fun tryDefaultAccess(ssl: Boolean, config: SourceMarkerConfig, project: Project) { + private suspend fun tryDefaultAccess(ssl: Boolean, config: SourceMarkerConfig) { val defaultAccessToken = "change-me" val tokenUri = "/api/new-token?access_token=$defaultAccessToken" val req = vertx.createHttpClient(HttpClientOptions().setSsl(ssl).setVerifyHost(false).setTrustAll(true)) @@ -539,7 +560,7 @@ object SourceMarkerPlugin { val projectSettings = PropertiesComponent.getInstance(project) projectSettings.setValue("sourcemarker_plugin_config", Json.encode(config)) - discoverAvailableServices(config, project) + discoverAvailableServices(config) //auto-established notification Notifications.Bus.notify( @@ -571,7 +592,7 @@ object SourceMarkerPlugin { } } - private suspend fun initMonitor(project: Project, config: SourceMarkerConfig) { + private suspend fun initMonitor(config: SourceMarkerConfig) { val scheme = if (config.isSsl()) "https" else "http" val skywalkingHost = "$scheme://${config.serviceHostNormalized}:${config.getServicePortNormalized()}/graphql" val certificatePins = mutableListOf() @@ -586,19 +607,19 @@ object SourceMarkerPlugin { } private suspend fun initUI(config: SourceMarkerConfig) { - deploymentIds.add(vertx.deployVerticle(PortalController(config)).await()) + deploymentIds.add(vertx.deployVerticle(PortalController(project, config)).await()) } - private fun initMarker(config: SourceMarkerConfig, project: Project) { + private fun initMarker(config: SourceMarkerConfig) { log.info("Initializing marker") - SourceMarker.addGlobalSourceMarkEventListener(SourceInlayHintProvider.EVENT_LISTENER) - SourceMarker.addGlobalSourceMarkEventListener(PluginSourceMarkEventListener()) + SourceMarker.getInstance(project).addGlobalSourceMarkEventListener(SourceInlayHintProvider.EVENT_LISTENER) + SourceMarker.getInstance(project).addGlobalSourceMarkEventListener(PluginSourceMarkEventListener(project)) - SourceMarker.configuration.guideMarkConfiguration.activateOnKeyboardShortcut = true - SourceMarker.configuration.inlayMarkConfiguration.strictlyManualCreation = true + SourceMarker.getInstance(project).configuration.guideMarkConfiguration.activateOnKeyboardShortcut = true + SourceMarker.getInstance(project).configuration.inlayMarkConfiguration.strictlyManualCreation = true if (config.rootSourcePackages.isNotEmpty()) { - SourceMarker.configuration.createSourceMarkFilter = CreateSourceMarkFilter { artifactQualifiedName -> + SourceMarker.getInstance(project).configuration.createSourceMarkFilter = CreateSourceMarkFilter { artifactQualifiedName -> config.rootSourcePackages.any { artifactQualifiedName.identifier.startsWith(it) } } } else { @@ -607,7 +628,7 @@ object SourceMarkerPlugin { log.warn("Could not determine root source package. Skipped adding create source mark filter...") } } - SourceMarker.enabled = true + SourceMarker.getInstance(project).enabled = true log.info("Source marker enabled") //force marker re-processing diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/activities/PluginSourceMarkerStartupActivity.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/activities/PluginSourceMarkerStartupActivity.kt index 10090c802..cab1edc48 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/activities/PluginSourceMarkerStartupActivity.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/activities/PluginSourceMarkerStartupActivity.kt @@ -62,7 +62,7 @@ class PluginSourceMarkerStartupActivity : SourceMarkerStartupActivity() { //setup plugin runBlocking { - SourceMarkerPlugin.init(project) + SourceMarkerPlugin.getInstance(project).init() } super.runActivity(project) } 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 a77b0fe48..d79052543 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/ControlBarController.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/ControlBarController.kt @@ -16,6 +16,7 @@ */ package spp.jetbrains.sourcemarker.command +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiDeclarationStatement import com.intellij.psi.PsiDocumentManager @@ -25,7 +26,6 @@ import kotlinx.coroutines.runBlocking import liveplugin.implementation.common.toFilePath import liveplugin.implementation.plugin.LivePluginService import org.joor.Reflect -import org.slf4j.LoggerFactory import spp.command.LiveCommand import spp.command.LiveCommandContext import spp.jetbrains.marker.impl.ArtifactCreationService @@ -48,7 +48,7 @@ import javax.swing.JPanel */ object ControlBarController { - private val log = LoggerFactory.getLogger(ControlBarController::class.java) + private val log = logger() private var previousControlBar: InlayMark? = null private val availableCommands: MutableList = mutableListOf() @@ -110,7 +110,7 @@ object ControlBarController { } fun handleCommandInput(input: String, fullText: String, editor: Editor) { - log.info("Processing command input: {}", input) + log.info("Processing command input: $input") (availableCommands + LivePluginService.getInstance(editor.project!!) .getRegisteredLiveCommands()).find { it.name == input } ?.let { @@ -160,7 +160,7 @@ object ControlBarController { val fileMarker = PsiDocumentManager.getInstance(editor.project!!).getPsiFile(editor.document)!! .getUserData(SourceFileMarker.KEY) if (fileMarker == null) { - log.warn("Could not find file marker for file: {}", editor.document) + log.warn("Could not find file marker for file: ${editor.document}") return } @@ -193,7 +193,7 @@ object ControlBarController { controlBar.focus() } } else if (tryingAboveLine) { - log.warn("No detected expression at line {}. Inlay mark ignored", lineNumber) + log.warn("No detected expression at line $lineNumber. Inlay mark ignored") } else { showControlBar(editor, lineNumber - 1, true) } diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerAppender.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerAppender.kt deleted file mode 100644 index a2450cc43..000000000 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerAppender.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package spp.jetbrains.sourcemarker.console - -import ch.qos.logback.classic.Level -import ch.qos.logback.classic.spi.LoggingEvent -import ch.qos.logback.classic.spi.ThrowableProxyUtil -import ch.qos.logback.core.AppenderBase -import com.intellij.execution.ui.ConsoleView -import com.intellij.execution.ui.ConsoleViewContentType - -/** - * Displays logs from the SourceMarker plugin to a console window. - * - * @since 0.3.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class SourceMarkerAppender : AppenderBase() { - - companion object { - var consoleView: ConsoleView? = null - } - - override fun append(eventObject: E) { - if (consoleView == null) return - - val loggingEvent = eventObject as LoggingEvent - val message = loggingEvent.formattedMessage - if (loggingEvent.level.isGreaterOrEqual(Level.WARN)) { - if (message.toString().startsWith("[PORTAL]")) { - consoleView!!.print("$message\n", ConsoleViewContentType.ERROR_OUTPUT) - } else { - var module = loggingEvent.loggerName.replace("spp.jetbrains.", "") - module = module.substring(0, module.indexOf(".")).toUpperCase() - if (loggingEvent.throwableProxy != null) { - consoleView!!.print( - "[$module] - $message\n${ThrowableProxyUtil.asString(loggingEvent.throwableProxy)}\n", - ConsoleViewContentType.ERROR_OUTPUT - ) - } else { - consoleView!!.print("[$module] - $message\n", ConsoleViewContentType.ERROR_OUTPUT) - } - } - } else { - if (message.toString().startsWith("[PORTAL]")) { - consoleView!!.print("$message\n", ConsoleViewContentType.NORMAL_OUTPUT) - } else { - var module = loggingEvent.loggerName.replace("spp.jetbrains.", "") - module = module.substring(0, module.indexOf(".")).toUpperCase() - consoleView!!.print("[$module] - $message\n", ConsoleViewContentType.NORMAL_OUTPUT) - } - } - } -} diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerConsoleService.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerConsoleService.kt deleted file mode 100755 index c4ed1490e..000000000 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerConsoleService.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package spp.jetbrains.sourcemarker.console - -import com.intellij.execution.filters.TextConsoleBuilderFactory -import com.intellij.execution.ui.ConsoleView -import com.intellij.openapi.project.Project -import com.intellij.openapi.util.Disposer - -/** - * Displays logs from the SourceMarker plugin to a console window. - * - * @since 0.2.1 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class SourceMarkerConsoleService(project: Project) { - - private var consoleView: ConsoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).console - - init { - Disposer.register(project, consoleView) - } - - fun getConsoleView(): ConsoleView { - return consoleView - } -} diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerToolWindowFactory.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerToolWindowFactory.kt deleted file mode 100755 index 7ae98ceb2..000000000 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerToolWindowFactory.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package spp.jetbrains.sourcemarker.console - -import com.intellij.openapi.components.ServiceManager -import com.intellij.openapi.project.Project -import com.intellij.openapi.wm.ToolWindow -import com.intellij.openapi.wm.ToolWindowAnchor -import com.intellij.openapi.wm.ToolWindowFactory -import org.slf4j.LoggerFactory -import spp.jetbrains.sourcemarker.SourceMarkerPlugin - -/** - * Displays logs from the SourceMarker plugin to a console window. - * - * @since 0.2.1 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class SourceMarkerToolWindowFactory : ToolWindowFactory { - - companion object { - private val log = LoggerFactory.getLogger(SourceMarkerToolWindowFactory::class.java) - } - - override fun isApplicable(project: Project): Boolean { - return SourceMarkerPlugin.getConfig(project).pluginConsoleEnabled - } - - override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) { - val consoleService = ServiceManager.getService(project, SourceMarkerConsoleService::class.java) - val consoleView = consoleService.getConsoleView() - val content = toolWindow.contentManager.factory.createContent(consoleView.component, "", true) - toolWindow.contentManager.addContent(content) - toolWindow.setAnchor(ToolWindowAnchor.BOTTOM, null) - toolWindow.isAvailable = true - - SourceMarkerAppender.consoleView = consoleView - log.info("Internal console enabled") - } -} diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/PluginSourceMarkEventListener.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/PluginSourceMarkEventListener.kt index 851121ff1..de9670090 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/PluginSourceMarkEventListener.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/PluginSourceMarkEventListener.kt @@ -16,10 +16,11 @@ */ package spp.jetbrains.sourcemarker.mark +import com.intellij.openapi.diagnostic.logger +import com.intellij.openapi.project.Project import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch -import org.slf4j.LoggerFactory import spp.jetbrains.marker.jvm.JVMEndpointDetector import spp.jetbrains.marker.jvm.psi.LoggerDetector import spp.jetbrains.marker.py.PythonEndpointDetector @@ -28,7 +29,7 @@ import spp.jetbrains.marker.source.mark.api.event.SourceMarkEvent import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode import spp.jetbrains.marker.source.mark.api.event.SynchronousSourceMarkEventListener import spp.jetbrains.marker.source.mark.guide.MethodGuideMark -import spp.jetbrains.sourcemarker.SourceMarkerPlugin.vertx +import spp.jetbrains.sourcemarker.SourceMarkerPlugin import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.ENDPOINT_DETECTOR import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.LOGGER_DETECTOR @@ -38,23 +39,24 @@ import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.LOGGER_DETECTOR * @since 0.1.0 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ -class PluginSourceMarkEventListener : SynchronousSourceMarkEventListener { +class PluginSourceMarkEventListener(val project: Project) : SynchronousSourceMarkEventListener { companion object { - private val log = LoggerFactory.getLogger(PluginSourceMarkEventListener::class.java) - private val loggerDetector = LoggerDetector(vertx) - private val endpointDetectors = mutableMapOf>() - .apply { - JVMEndpointDetector(vertx).let { - put("JAVA", it) - put("kotlin", it) - put("Scala", it) - put("Groovy", it) - } - put("Python", PythonEndpointDetector(vertx)) - }.toMap() + private val log = logger() } + private val loggerDetector = LoggerDetector(SourceMarkerPlugin.getInstance(project).vertx) + private val endpointDetectors = mutableMapOf>() + .apply { + JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx).let { + put("JAVA", it) + put("kotlin", it) + put("Scala", it) + put("Groovy", it) + } + put("Python", PythonEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx)) + }.toMap() + override fun handleEvent(event: SourceMarkEvent) { if (log.isTraceEnabled) { log.trace("Handling event: $event") @@ -66,7 +68,7 @@ class PluginSourceMarkEventListener : SynchronousSourceMarkEventListener { if (sourceMark is MethodGuideMark) { //setup endpoint detector and attempt detection sourceMark.putUserData(ENDPOINT_DETECTOR, endpointDetectors[sourceMark.language.id]) - GlobalScope.launch(vertx.dispatcher()) { + GlobalScope.launch(SourceMarkerPlugin.getInstance(project).vertx.dispatcher()) { endpointDetectors[sourceMark.language.id]!!.getOrFindEndpointId(sourceMark) } } diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkKeys.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkKeys.kt index 5a5f44b05..854d3eb4e 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkKeys.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkKeys.kt @@ -20,10 +20,10 @@ import spp.jetbrains.marker.jvm.psi.LoggerDetector import spp.jetbrains.marker.source.info.EndpointDetector import spp.jetbrains.marker.source.mark.api.SourceMark import spp.jetbrains.marker.source.mark.api.key.SourceKey -import spp.jetbrains.sourcemarker.service.InstrumentEventListener -import spp.jetbrains.sourcemarker.service.ViewEventListener import spp.jetbrains.sourcemarker.status.StatusBar import spp.protocol.portal.PortalConfiguration +import spp.protocol.service.listen.LiveInstrumentEventListener +import spp.protocol.service.listen.LiveViewEventListener /** * Used to associate custom data to [SourceMark]s. @@ -38,7 +38,7 @@ object SourceMarkKeys { val INSTRUMENT_ID = SourceKey("INSTRUMENT_ID") val VIEW_SUBSCRIPTION_ID = SourceKey("VIEW_SUBSCRIPTION_ID") val GROUPED_MARKS = SourceKey>("GROUPED_MARKS") - val INSTRUMENT_EVENT_LISTENERS = SourceKey>("INSTRUMENT_EVENT_LISTENERS") - val VIEW_EVENT_LISTENERS = SourceKey>("VIEW_EVENT_LISTENERS") + val INSTRUMENT_EVENT_LISTENERS = SourceKey>("INSTRUMENT_EVENT_LISTENERS") + val VIEW_EVENT_LISTENERS = SourceKey>("LIVE_VIEW_EVENT_LISTENERS") val STATUS_BAR = SourceKey("STATUS_BAR") } diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkSearch.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkSearch.kt index 484c51f01..92c8879c0 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkSearch.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkSearch.kt @@ -17,6 +17,7 @@ package spp.jetbrains.sourcemarker.mark import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project import com.intellij.openapi.util.TextRange import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.source.SourceFileMarker @@ -57,14 +58,14 @@ object SourceMarkSearch { return sourceMark ?: classSourceMark } - fun findByInstrumentId(instrumentId: String): SourceMark? { - return SourceMarker.getSourceMarks().firstOrNull { + fun findByInstrumentId(project: Project, instrumentId: String): SourceMark? { + return SourceMarker.getInstance(project).getSourceMarks().firstOrNull { it.getUserData(SourceMarkKeys.INSTRUMENT_ID) == instrumentId } } - fun findBySubscriptionId(subscriptionId: String): SourceMark? { - return SourceMarker.getSourceMarks().firstOrNull { + fun findBySubscriptionId(project: Project, subscriptionId: String): SourceMark? { + return SourceMarker.getInstance(project).getSourceMarks().firstOrNull { it.getUserData(SourceMarkKeys.VIEW_SUBSCRIPTION_ID) == subscriptionId } } 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 ca38f286a..77fd88000 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalController.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalController.kt @@ -19,13 +19,14 @@ package spp.jetbrains.sourcemarker.portal import com.fasterxml.jackson.databind.module.SimpleModule import com.intellij.ide.ui.laf.IntelliJLaf import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project import io.vertx.core.json.JsonObject import io.vertx.core.json.jackson.DatabindCodec import io.vertx.kotlin.coroutines.CoroutineVerticle import io.vertx.kotlin.coroutines.await import kotlinx.datetime.Instant -import org.slf4j.LoggerFactory import spp.booster.PortalServer import spp.booster.SourcePortal import spp.jetbrains.marker.SourceMarker @@ -48,9 +49,12 @@ import javax.swing.UIManager import kotlin.math.ceil import kotlin.math.floor -class PortalController(private val markerConfig: SourceMarkerConfig) : CoroutineVerticle() { +class PortalController( + private val project: Project, + private val markerConfig: SourceMarkerConfig +) : CoroutineVerticle() { - private val log = LoggerFactory.getLogger(PortalController::class.java) + private val log = logger() override suspend fun start() { log.info("Initializing portal") @@ -97,10 +101,10 @@ class PortalController(private val markerConfig: SourceMarkerConfig) : Coroutine } } } - SourceMarker.configuration.guideMarkConfiguration.componentProvider = componentProvider - SourceMarker.configuration.inlayMarkConfiguration.componentProvider = componentProvider + SourceMarker.getInstance(project).configuration.guideMarkConfiguration.componentProvider = componentProvider + SourceMarker.getInstance(project).configuration.inlayMarkConfiguration.componentProvider = componentProvider - SourceMarker.addGlobalSourceMarkEventListener { + SourceMarker.getInstance(project).addGlobalSourceMarkEventListener { if (it.eventCode == SourceMarkEventCode.MARK_BEFORE_ADDED && it.sourceMark is GuideMark) { //register portal for source mark val portal = SourcePortal.getPortal( diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/reporting/error-report.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/reporting/error-report.kt index 2e836c571..607bd0636 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/reporting/error-report.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/reporting/error-report.kt @@ -28,10 +28,7 @@ import com.intellij.notification.NotificationType import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.application.ApplicationNamesInfo import com.intellij.openapi.application.ex.ApplicationInfoEx -import com.intellij.openapi.diagnostic.Attachment -import com.intellij.openapi.diagnostic.ErrorReportSubmitter -import com.intellij.openapi.diagnostic.IdeaLoggingEvent -import com.intellij.openapi.diagnostic.SubmittedReportInfo +import com.intellij.openapi.diagnostic.* import com.intellij.openapi.diagnostic.SubmittedReportInfo.SubmissionStatus import com.intellij.openapi.extensions.PluginId import com.intellij.openapi.progress.EmptyProgressIndicator @@ -47,7 +44,6 @@ import org.eclipse.egit.github.core.Label import org.eclipse.egit.github.core.RepositoryId import org.eclipse.egit.github.core.client.GitHubClient import org.eclipse.egit.github.core.service.IssueService -import org.slf4j.LoggerFactory import spp.jetbrains.sourcemarker.PluginBundle import java.awt.Component import java.io.PrintWriter @@ -63,7 +59,7 @@ import java.util.* */ private object AnonymousFeedback { - private val log = LoggerFactory.getLogger(AnonymousFeedback::class.java) + private val log = logger() private const val gitRepoUser = "sourceplusplus" private const val gitRepo = "interface-jetbrains" diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/InstrumentEventListener.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/InstrumentEventListener.kt deleted file mode 100644 index ae6b10d1d..000000000 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/InstrumentEventListener.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package spp.jetbrains.sourcemarker.service - -import spp.protocol.instrument.event.LiveInstrumentEvent - -/** - * todo: description. - * - * @since 0.3.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -fun interface InstrumentEventListener { - fun accept(event: LiveInstrumentEvent) -} diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveInstrumentManager.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveInstrumentManager.kt index e26604b96..c786cb48e 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveInstrumentManager.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveInstrumentManager.kt @@ -17,23 +17,22 @@ package spp.jetbrains.sourcemarker.service import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.project.Project -import com.intellij.openapi.project.ProjectManager import io.vertx.core.json.Json import io.vertx.core.json.JsonObject import io.vertx.ext.auth.impl.jose.JWT import io.vertx.ext.bridge.BridgeEventType import io.vertx.ext.eventbus.bridge.tcp.impl.protocol.FrameHelper import io.vertx.kotlin.coroutines.CoroutineVerticle -import org.slf4j.LoggerFactory +import liveplugin.implementation.plugin.LiveStatusManager import spp.jetbrains.marker.SourceMarker +import spp.jetbrains.monitor.skywalking.SkywalkingMonitor.Companion.LIVE_INSTRUMENT_SERVICE import spp.jetbrains.sourcemarker.mark.SourceMarkKeys import spp.jetbrains.sourcemarker.mark.SourceMarkSearch import spp.jetbrains.sourcemarker.service.discover.TCPServiceDiscoveryBackend import spp.jetbrains.sourcemarker.service.instrument.breakpoint.BreakpointHitWindowService import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig -import spp.jetbrains.sourcemarker.status.LiveStatusManager -import spp.protocol.SourceServices.Instance import spp.protocol.SourceServices.Provide.toLiveInstrumentSubscriberAddress import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.LiveLog @@ -48,14 +47,13 @@ import spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved * @since 0.3.0 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ -@Suppress("UNCHECKED_CAST") class LiveInstrumentManager( private val project: Project, private val pluginConfig: SourceMarkerConfig ) : CoroutineVerticle() { companion object { - private val log = LoggerFactory.getLogger(LiveInstrumentManager::class.java) + private val log = logger() } override suspend fun start() { @@ -67,7 +65,7 @@ class LiveInstrumentManager( vertx.eventBus().consumer(toLiveInstrumentSubscriberAddress(developer)) { val liveEvent = Json.decodeValue(it.body().toString(), LiveInstrumentEvent::class.java) - log.debug("Received instrument event. Type: {}", liveEvent.eventType) + log.debug("Received instrument event. Type: ${liveEvent.eventType}") when (liveEvent.eventType) { LiveInstrumentEventType.LOG_HIT -> handleLogHitEvent(liveEvent) @@ -76,7 +74,7 @@ class LiveInstrumentManager( LiveInstrumentEventType.BREAKPOINT_REMOVED -> handleInstrumentRemovedEvent(liveEvent) LiveInstrumentEventType.LOG_ADDED -> handleLogAddedEvent(liveEvent) LiveInstrumentEventType.LOG_REMOVED -> handleInstrumentRemovedEvent(liveEvent) - else -> log.warn("Un-implemented event type: {}", liveEvent.eventType) + else -> log.warn("Un-implemented event type: ${liveEvent.eventType}") } } @@ -85,14 +83,14 @@ class LiveInstrumentManager( BridgeEventType.REGISTER.name.toLowerCase(), toLiveInstrumentSubscriberAddress(developer), null, JsonObject().apply { pluginConfig.serviceToken?.let { put("auth-token", it) } }, - null, null, TCPServiceDiscoveryBackend.socket!! + null, null, TCPServiceDiscoveryBackend.getSocket(project) ) //show live status bars - Instance.liveInstrument!!.getLiveInstruments(null).onComplete { + project.getUserData(LIVE_INSTRUMENT_SERVICE)!!.getLiveInstruments(null).onComplete { if (it.succeeded()) { - log.info("Found {} active live status bars", it.result().size) - LiveStatusManager.addActiveLiveInstruments(it.result()) + log.info("Found ${it.result().size} active live status bars") + LiveStatusManager.getInstance(project).addActiveLiveInstruments(it.result()) } else { log.error("Failed to get live status bars", it.cause()) } @@ -100,21 +98,21 @@ class LiveInstrumentManager( } private fun handleLogAddedEvent(liveEvent: LiveInstrumentEvent) { - if (!SourceMarker.enabled) { + if (!SourceMarker.getInstance(project).enabled) { log.debug("SourceMarker disabled. Ignored log added") return } val logAdded = Json.decodeValue(liveEvent.data, LiveLog::class.java) ApplicationManager.getApplication().invokeLater { - val fileMarker = SourceMarker.getSourceFileMarker(logAdded.location.source) + val fileMarker = SourceMarker.getInstance(project).getSourceFileMarker(logAdded.location.source) if (fileMarker != null) { val smId = logAdded.meta["original_source_mark"] as String? ?: return@invokeLater - val inlayMark = SourceMarker.getSourceMark(smId) ?: return@invokeLater + val inlayMark = SourceMarker.getInstance(project).getSourceMark(smId) ?: return@invokeLater inlayMark.putUserData(SourceMarkKeys.INSTRUMENT_ID, logAdded.id) inlayMark.getUserData(SourceMarkKeys.STATUS_BAR)!!.setLiveInstrument(logAdded) } else { - LiveStatusManager.addActiveLiveInstrument(logAdded) + LiveStatusManager.getInstance(project).addActiveLiveInstrument(logAdded) } } } @@ -122,10 +120,10 @@ class LiveInstrumentManager( private fun handleBreakpointAddedEvent(liveEvent: LiveInstrumentEvent) { val bpAdded = Json.decodeValue(liveEvent.data, LiveBreakpoint::class.java) ApplicationManager.getApplication().invokeLater { - val fileMarker = SourceMarker.getSourceFileMarker(bpAdded.location.source) + val fileMarker = SourceMarker.getInstance(project).getSourceFileMarker(bpAdded.location.source) if (fileMarker != null) { val smId = bpAdded.meta["original_source_mark"] as String? ?: return@invokeLater - val inlayMark = SourceMarker.getSourceMark(smId) ?: return@invokeLater + val inlayMark = SourceMarker.getInstance(project).getSourceMark(smId) ?: return@invokeLater inlayMark.putUserData(SourceMarkKeys.INSTRUMENT_ID, bpAdded.id) inlayMark.getUserData(SourceMarkKeys.STATUS_BAR)!!.setLiveInstrument(bpAdded) } @@ -135,7 +133,7 @@ class LiveInstrumentManager( private fun handleInstrumentRemovedEvent(liveEvent: LiveInstrumentEvent) { val instrumentRemoved = deserializeLiveInstrumentRemoved(JsonObject(liveEvent.data)) ApplicationManager.getApplication().invokeLater { - val inlayMark = SourceMarkSearch.findByInstrumentId(instrumentRemoved.liveInstrument.id!!) + val inlayMark = SourceMarkSearch.findByInstrumentId(project, instrumentRemoved.liveInstrument.id!!) if (inlayMark != null) { val eventListeners = inlayMark.getUserData(SourceMarkKeys.INSTRUMENT_EVENT_LISTENERS) if (eventListeners?.isNotEmpty() == true) { @@ -146,29 +144,28 @@ class LiveInstrumentManager( } private fun handleBreakpointHitEvent(liveEvent: LiveInstrumentEvent) { - if (!SourceMarker.enabled) { + if (!SourceMarker.getInstance(project).enabled) { log.debug("SourceMarker disabled. Ignored breakpoint hit") return } val bpHit = ProtocolMarshaller.deserializeLiveBreakpointHit(JsonObject(liveEvent.data)) ApplicationManager.getApplication().invokeLater { - val project = ProjectManager.getInstance().openProjects[0] BreakpointHitWindowService.getInstance(project).addBreakpointHit(bpHit) - SourceMarkSearch.findByInstrumentId(bpHit.breakpointId) + SourceMarkSearch.findByInstrumentId(project, bpHit.breakpointId) ?.getUserData(SourceMarkKeys.INSTRUMENT_EVENT_LISTENERS)?.forEach { it.accept(liveEvent) } } } private fun handleLogHitEvent(liveEvent: LiveInstrumentEvent) { - if (!SourceMarker.enabled) { + if (!SourceMarker.getInstance(project).enabled) { log.debug("SourceMarker disabled. Ignored log hit") return } val logHit = ProtocolMarshaller.deserializeLiveLogHit(JsonObject(liveEvent.data)) - SourceMarkSearch.findByInstrumentId(logHit.logId) + SourceMarkSearch.findByInstrumentId(project, logHit.logId) ?.getUserData(SourceMarkKeys.INSTRUMENT_EVENT_LISTENERS)?.forEach { it.accept(liveEvent) } } } diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveViewManager.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveViewManager.kt index 6fce4aa6a..b6f916f73 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveViewManager.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveViewManager.kt @@ -16,13 +16,14 @@ */ package spp.jetbrains.sourcemarker.service +import com.intellij.openapi.diagnostic.logger +import com.intellij.openapi.project.Project import io.vertx.core.json.Json import io.vertx.core.json.JsonObject import io.vertx.ext.auth.impl.jose.JWT import io.vertx.ext.bridge.BridgeEventType import io.vertx.ext.eventbus.bridge.tcp.impl.protocol.FrameHelper import io.vertx.kotlin.coroutines.CoroutineVerticle -import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.jetbrains.sourcemarker.mark.SourceMarkKeys import spp.jetbrains.sourcemarker.mark.SourceMarkSearch @@ -31,9 +32,12 @@ import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import spp.protocol.SourceServices.Provide.toLiveViewSubscriberAddress import spp.protocol.view.LiveViewEvent -class LiveViewManager(private val pluginConfig: SourceMarkerConfig) : CoroutineVerticle() { +class LiveViewManager( + private val project: Project, + private val pluginConfig: SourceMarkerConfig +) : CoroutineVerticle() { - private val log = LoggerFactory.getLogger(LiveViewManager::class.java) + private val log = logger() override suspend fun start() { //register listener @@ -45,14 +49,14 @@ class LiveViewManager(private val pluginConfig: SourceMarkerConfig) : CoroutineV vertx.eventBus().consumer(toLiveViewSubscriberAddress(developer)) { val event = Json.decodeValue(it.body().toString(), LiveViewEvent::class.java) - if (log.isTraceEnabled) log.trace("Received live event: {}", event) - if (!SourceMarker.enabled) { - log.warn("SourceMarker is not enabled, ignoring live event: {}", event) + if (log.isTraceEnabled) log.trace("Received live event: $event") + if (!SourceMarker.getInstance(project).enabled) { + log.warn("SourceMarker is not enabled, ignoring live event: $event") return@consumer } //todo: remove in favor of sending events to individual subscribers - SourceMarkSearch.findBySubscriptionId(event.subscriptionId) + SourceMarkSearch.findBySubscriptionId(project, event.subscriptionId) ?.getUserData(SourceMarkKeys.VIEW_EVENT_LISTENERS)?.forEach { it.accept(event) } vertx.eventBus().publish(toLiveViewSubscriberAddress(event.subscriptionId), it.body()) @@ -62,7 +66,7 @@ class LiveViewManager(private val pluginConfig: SourceMarkerConfig) : CoroutineV BridgeEventType.REGISTER.name.toLowerCase(), toLiveViewSubscriberAddress(developer), null, JsonObject().apply { pluginConfig.serviceToken?.let { put("auth-token", it) } }, - null, null, TCPServiceDiscoveryBackend.socket!! + null, null, TCPServiceDiscoveryBackend.getSocket(project) ) } } diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/ViewEventListener.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/ViewEventListener.kt deleted file mode 100644 index 1d6ad1e42..000000000 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/ViewEventListener.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package spp.jetbrains.sourcemarker.service - -import spp.protocol.view.LiveViewEvent - -/** - * todo: description. - * - * @since 0.4.2 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -fun interface ViewEventListener { - fun accept(event: LiveViewEvent) -} diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/discover/TCPServiceDiscoveryBackend.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/discover/TCPServiceDiscoveryBackend.kt index 709e29464..4546bc1c0 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/discover/TCPServiceDiscoveryBackend.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/discover/TCPServiceDiscoveryBackend.kt @@ -16,6 +16,8 @@ */ package spp.jetbrains.sourcemarker.service.discover +import com.intellij.openapi.diagnostic.logger +import com.intellij.openapi.project.Project import eu.geekplace.javapinning.JavaPinning import eu.geekplace.javapinning.pin.Pin import io.vertx.core.* @@ -37,7 +39,6 @@ import io.vertx.servicediscovery.Record import io.vertx.servicediscovery.spi.ServiceDiscoveryBackend import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch -import org.slf4j.LoggerFactory import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import spp.jetbrains.sourcemarker.settings.isSsl import spp.jetbrains.sourcemarker.settings.serviceHostNormalized @@ -57,10 +58,20 @@ import java.util.* class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend { companion object { - private val log = LoggerFactory.getLogger(TCPServiceDiscoveryBackend::class.java) - var socket: NetSocket? = null + private val log = logger() + private val projectMap = mutableMapOf() + + fun getSocket(project: Project): NetSocket? { + return projectMap[project.locationHash]?.socket + } + + suspend fun closeSocket(project: Project) { + projectMap[project.locationHash]?.socket?.close()?.await() + projectMap[project.locationHash]?.socket = null + } } + var socket: NetSocket? = null private lateinit var vertx: Vertx private lateinit var client: NetClient private lateinit var pluginConfig: SourceMarkerConfig @@ -72,6 +83,7 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend { pluginConfig = Json.decodeValue( config.getJsonObject("sourcemarker_plugin_config").toString(), SourceMarkerConfig::class.java ) + projectMap[config.getString("project_location_hash")] = this val serviceHost = pluginConfig.serviceHostNormalized val certificatePins = mutableListOf() diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ExecutionPointManager.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ExecutionPointManager.kt index 151394d41..32eb2a0a3 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ExecutionPointManager.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ExecutionPointManager.kt @@ -18,13 +18,13 @@ package spp.jetbrains.sourcemarker.service.instrument.breakpoint import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.fileEditor.OpenFileDescriptor import com.intellij.openapi.project.Project import com.intellij.xdebugger.XDebuggerUtil import com.intellij.xdebugger.impl.ui.ExecutionPointHighlighter -import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.protocol.artifact.exception.qualifiedClassName import spp.protocol.artifact.exception.sourceAsLineNumber @@ -42,7 +42,7 @@ class ExecutionPointManager( ) : DebugStackFrameListener, Disposable { companion object { - private val log = LoggerFactory.getLogger(ExecutionPointManager::class.java) + private val log = logger() } override fun onChanged(stackFrameManager: StackFrameManager) { @@ -55,7 +55,7 @@ class ExecutionPointManager( if (indexOfDollarSign >= 0) { fromClass = fromClass.substring(0, indexOfDollarSign) } - val fileMarker = SourceMarker.getSourceFileMarker(fromClass) ?: return + val fileMarker = SourceMarker.getInstance(project).getSourceFileMarker(fromClass) ?: return val virtualFile = fileMarker.psiFile.containingFile.virtualFile ?: return val document = FileDocumentManager.getInstance().getDocument(virtualFile) ?: return val lineStartOffset = document.getLineStartOffset(currentFrame.sourceAsLineNumber()!!) - 1 diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/BreakpointHitWindow.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/BreakpointHitWindow.kt index afb763651..a24768c2a 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/BreakpointHitWindow.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/BreakpointHitWindow.kt @@ -22,7 +22,6 @@ import com.intellij.icons.AllIcons import com.intellij.openapi.Disposable import com.intellij.openapi.application.ReadAction import com.intellij.openapi.project.Project -import com.intellij.openapi.project.ProjectManager import com.intellij.openapi.util.Disposer import com.intellij.ui.content.Content import com.intellij.util.concurrency.AppExecutorUtil @@ -44,7 +43,7 @@ import javax.swing.JComponent * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ class BreakpointHitWindow( - project: Project, + val project: Project, executionPointHighlighter: ExecutionPointHighlighter, showExecutionPoint: Boolean ) : Disposable { @@ -74,7 +73,7 @@ class BreakpointHitWindow( } private fun addFramesTab() { - val config = SourceMarkerPlugin.getConfig(ProjectManager.getInstance().openProjects[0]) + val config = SourceMarkerPlugin.getInstance(project).getConfig() val framesTab = FramesTab(this, config) val content = layoutUi.createContent( LiveBreakpointConstants.LIVE_RECORDER_STACK_FRAMES, framesTab.component, "Frames", diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/EventsTab.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/EventsTab.kt index 7f6ec1080..4e675ee15 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/EventsTab.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/EventsTab.kt @@ -19,7 +19,7 @@ package spp.jetbrains.sourcemarker.service.instrument.breakpoint.ui import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.project.ProjectManager +import com.intellij.openapi.project.Project import com.intellij.ui.components.JBScrollPane import com.intellij.ui.table.JBTable import com.intellij.util.ui.ListTableModel @@ -43,7 +43,7 @@ import javax.swing.SortOrder * @since 0.3.0 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ -class EventsTab : Disposable { +class EventsTab(val project: Project) : Disposable { val component: JPanel = JPanel(BorderLayout()) val model: ListTableModel = ListTableModel( @@ -77,7 +77,6 @@ class EventsTab : Disposable { val row = table.rowAtPoint(point) if (mouseEvent.clickCount == 2 && row >= 0) { ApplicationManager.getApplication().invokeLater { - val project = ProjectManager.getInstance().openProjects[0] BreakpointHitWindowService.getInstance(project) .showBreakpointHit(model.getItem(table.convertRowIndexToModel(row))) } diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/EventsWindow.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/EventsWindow.kt index 14857907b..585239ef0 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/EventsWindow.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ui/EventsWindow.kt @@ -34,7 +34,7 @@ import javax.swing.JComponent * @since 0.3.0 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ -class EventsWindow(project: Project) : Disposable { +class EventsWindow(val project: Project) : Disposable { lateinit var stackFrameManager: StackFrameManager private val listeners: MutableList @@ -42,7 +42,7 @@ class EventsWindow(project: Project) : Disposable { lateinit var eventsTab: EventsTab private fun addEventsTab() { - eventsTab = EventsTab() + eventsTab = EventsTab(project) val content = layoutUi.createContent( LiveBreakpointConstants.LIVE_RECORDER_STACK_FRAMES, eventsTab.component, "Events", AllIcons.Debugger.Console, null diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/settings/SourceMarkerConfig.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/settings/SourceMarkerConfig.kt index 9c45c8f38..13170b10e 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/settings/SourceMarkerConfig.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/settings/SourceMarkerConfig.kt @@ -26,7 +26,6 @@ data class SourceMarkerConfig( var rootSourcePackages: List = emptyList(), var autoResolveEndpointNames: Boolean = true, var localMentorEnabled: Boolean = true, - var pluginConsoleEnabled: Boolean = false, var serviceHost: String? = null, var accessToken: String? = null, var certificatePins: List = emptyList(), diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/settings/SourceMarkerConfigurable.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/settings/SourceMarkerConfigurable.kt index 734ddf1d7..692f16b3b 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/settings/SourceMarkerConfigurable.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/settings/SourceMarkerConfigurable.kt @@ -19,13 +19,13 @@ package spp.jetbrains.sourcemarker.settings import com.intellij.ide.util.PropertiesComponent import com.intellij.openapi.options.Configurable import com.intellij.openapi.project.DumbService -import com.intellij.openapi.project.ProjectManager +import com.intellij.openapi.project.Project import io.vertx.core.json.Json import io.vertx.kotlin.coroutines.await import kotlinx.coroutines.runBlocking +import spp.jetbrains.monitor.skywalking.SkywalkingMonitor.Companion.LIVE_SERVICE import spp.jetbrains.sourcemarker.PluginBundle.message import spp.jetbrains.sourcemarker.SourceMarkerPlugin -import spp.protocol.SourceServices import javax.swing.JComponent /** @@ -34,32 +34,31 @@ import javax.swing.JComponent * @since 0.1.0 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ -class SourceMarkerConfigurable : Configurable { +class SourceMarkerConfigurable(val project: Project) : Configurable { private var form: PluginConfigurationPanel? = null override fun getDisplayName(): String = message("plugin_name") - override fun isModified(): Boolean = form!!.isModified + override fun isModified(): Boolean = form?.isModified == true override fun apply() { val updatedConfig = form!!.pluginConfig - val projectSettings = PropertiesComponent.getInstance(ProjectManager.getInstance().openProjects[0]) + val projectSettings = PropertiesComponent.getInstance(project) projectSettings.setValue("sourcemarker_plugin_config", Json.encode(updatedConfig)) form!!.applySourceMarkerConfig(updatedConfig) - val activeProject = ProjectManager.getInstance().openProjects[0] - DumbService.getInstance(activeProject).smartInvokeLater { + DumbService.getInstance(project).smartInvokeLater { runBlocking { - SourceMarkerPlugin.init(activeProject) + SourceMarkerPlugin.getInstance(project).init() } } } override fun createComponent(): JComponent { if (form == null) { - val config = SourceMarkerPlugin.getConfig(ProjectManager.getInstance().openProjects[0]) + val config = SourceMarkerPlugin.getInstance(project).getConfig() val availServices = runBlocking { - SourceServices.Instance.liveService?.getServices()?.let { it.await() } ?: emptyList() + project.getUserData(LIVE_SERVICE)?.getServices()?.await() ?: emptyList() } form = PluginConfigurationPanel(config, availServices) form!!.applySourceMarkerConfig(config) diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/LiveStatusManager.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/LiveStatusManagerImpl.kt similarity index 86% rename from plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/LiveStatusManager.kt rename to plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/LiveStatusManagerImpl.kt index 4440b8827..d735fb0a5 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/LiveStatusManager.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/LiveStatusManagerImpl.kt @@ -17,13 +17,15 @@ package spp.jetbrains.sourcemarker.status import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.Editor import com.intellij.openapi.fileEditor.FileEditorManager +import com.intellij.openapi.project.Project import com.intellij.psi.PsiDocumentManager import io.vertx.core.json.Json import io.vertx.core.json.JsonObject import kotlinx.coroutines.runBlocking -import org.slf4j.LoggerFactory +import liveplugin.implementation.plugin.LiveStatusManager import spp.jetbrains.marker.impl.ArtifactCreationService import spp.jetbrains.marker.impl.ArtifactNamingService import spp.jetbrains.marker.impl.ArtifactScopeService @@ -36,8 +38,8 @@ import spp.jetbrains.marker.source.mark.api.event.SourceMarkEvent import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventListener import spp.jetbrains.marker.source.mark.inlay.InlayMark +import spp.jetbrains.monitor.skywalking.SkywalkingMonitor.Companion.LIVE_VIEW_SERVICE import spp.jetbrains.sourcemarker.SourceMarkerPlugin -import spp.jetbrains.sourcemarker.SourceMarkerPlugin.vertx import spp.jetbrains.sourcemarker.icons.SourceMarkerIcons.LIVE_METER_COUNT_ICON import spp.jetbrains.sourcemarker.icons.SourceMarkerIcons.LIVE_METER_GAUGE_ICON import spp.jetbrains.sourcemarker.icons.SourceMarkerIcons.LIVE_METER_HISTOGRAM_ICON @@ -46,15 +48,14 @@ import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.INSTRUMENT_EVENT_LISTENERS import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.INSTRUMENT_ID import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.VIEW_EVENT_LISTENERS import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.VIEW_SUBSCRIPTION_ID -import spp.jetbrains.sourcemarker.service.InstrumentEventListener -import spp.jetbrains.sourcemarker.service.ViewEventListener import spp.jetbrains.sourcemarker.status.util.CircularList -import spp.protocol.SourceServices import spp.protocol.SourceServices.Provide.toLiveViewSubscriberAddress import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.ArtifactType import spp.protocol.instrument.* import spp.protocol.instrument.meter.MeterType +import spp.protocol.service.listen.LiveInstrumentEventListener +import spp.protocol.service.listen.LiveViewEventListener import spp.protocol.view.LiveViewConfig import spp.protocol.view.LiveViewEvent import spp.protocol.view.LiveViewSubscription @@ -73,9 +74,11 @@ import javax.swing.JPanel * @since 0.3.0 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ -object LiveStatusManager : SourceMarkEventListener { +class LiveStatusManagerImpl(val project: Project) : LiveStatusManager, SourceMarkEventListener { - private val log = LoggerFactory.getLogger(LiveStatusManager::class.java) + companion object { + private val log = logger() + } private val activeStatusBars = CopyOnWriteArrayList() private val logData = ConcurrentHashMap>() @@ -119,11 +122,11 @@ object LiveStatusManager : SourceMarkEventListener { * Invoked via control bar. Force visible. */ @Suppress("unused") - fun showBreakpointStatusBar(editor: Editor, lineNumber: Int) { + override fun showBreakpointStatusBar(editor: Editor, lineNumber: Int) { val fileMarker = PsiDocumentManager.getInstance(editor.project!!).getPsiFile(editor.document)!! .getUserData(SourceFileMarker.KEY) if (fileMarker == null) { - log.warn("Could not find file marker for file: {}", editor.document) + log.warn("Could not find file marker for file: ${editor.document}") return } @@ -132,7 +135,7 @@ object LiveStatusManager : SourceMarkEventListener { val wrapperPanel = JPanel() wrapperPanel.layout = BorderLayout() - val config = SourceMarkerPlugin.getConfig(editor.project!!) + val config = SourceMarkerPlugin.getInstance(editor.project!!).getConfig() val statusBar = BreakpointStatusBar( LiveSourceLocation( ArtifactNamingService.getQualifiedClassNames(fileMarker.psiFile)[0].identifier, lineNumber, @@ -163,11 +166,11 @@ object LiveStatusManager : SourceMarkEventListener { * Invoked via control bar. Force visible. */ @Suppress("unused") - fun showLogStatusBar(editor: Editor, lineNumber: Int, watchExpression: Boolean) { + override fun showLogStatusBar(editor: Editor, lineNumber: Int, watchExpression: Boolean) { val fileMarker = PsiDocumentManager.getInstance(editor.project!!).getPsiFile(editor.document)!! .getUserData(SourceFileMarker.KEY) if (fileMarker == null) { - log.warn("Could not find file marker for file: {}", editor.document) + log.warn("Could not find file marker for file: ${editor.document}") return } @@ -176,7 +179,7 @@ object LiveStatusManager : SourceMarkEventListener { val wrapperPanel = JPanel() wrapperPanel.layout = BorderLayout() - val config = SourceMarkerPlugin.getConfig(editor.project!!) + val config = SourceMarkerPlugin.getInstance(editor.project!!).getConfig() val statusBar = LogStatusBar( LiveSourceLocation( ArtifactNamingService.getQualifiedClassNames(fileMarker.psiFile)[0].identifier, @@ -204,7 +207,7 @@ object LiveStatusManager : SourceMarkEventListener { } } - SourceServices.Instance.liveView!!.addLiveViewSubscription( + project.getUserData(LIVE_VIEW_SERVICE)!!.addLiveViewSubscription( LiveViewSubscription( null, logPatterns, @@ -223,12 +226,13 @@ object LiveStatusManager : SourceMarkEventListener { if (it.succeeded()) { val subscriptionId = it.result().subscriptionId!! inlayMark.putUserData(VIEW_SUBSCRIPTION_ID, subscriptionId) - vertx.eventBus().consumer(toLiveViewSubscriberAddress(subscriptionId)) { - statusBar.accept(Json.decodeValue(it.body().toString(), LiveViewEvent::class.java)) - } + SourceMarkerPlugin.getInstance(editor.project!!).vertx.eventBus() + .consumer(toLiveViewSubscriberAddress(subscriptionId)) { + statusBar.accept(Json.decodeValue(it.body().toString(), LiveViewEvent::class.java)) + } inlayMark.addEventListener { event -> if (event.eventCode == SourceMarkEventCode.MARK_REMOVED) { - SourceServices.Instance.liveView!!.removeLiveViewSubscription(subscriptionId) + project.getUserData(LIVE_VIEW_SERVICE)!!.removeLiveViewSubscription(subscriptionId) } } } else { @@ -257,11 +261,11 @@ object LiveStatusManager : SourceMarkEventListener { } @Suppress("unused") - fun showMeterStatusBar(editor: Editor, lineNumber: Int) { + override fun showMeterStatusBar(editor: Editor, lineNumber: Int) { val fileMarker = PsiDocumentManager.getInstance(editor.project!!).getPsiFile(editor.document)!! .getUserData(SourceFileMarker.KEY) if (fileMarker == null) { - log.warn("Could not find file marker for file: {}", editor.document) + log.warn("Could not find file marker for file: ${editor.document}") return } @@ -270,7 +274,7 @@ object LiveStatusManager : SourceMarkEventListener { val wrapperPanel = JPanel() wrapperPanel.layout = BorderLayout() - val config = SourceMarkerPlugin.getConfig(editor.project!!) + val config = SourceMarkerPlugin.getInstance(editor.project!!).getConfig() val statusBar = MeterStatusBar( LiveSourceLocation( ArtifactNamingService.getQualifiedClassNames(fileMarker.psiFile)[0].identifier, lineNumber, @@ -296,11 +300,11 @@ object LiveStatusManager : SourceMarkEventListener { } @Suppress("unused") - fun showSpanStatusBar(editor: Editor, lineNumber: Int) { + override fun showSpanStatusBar(editor: Editor, lineNumber: Int) { val fileMarker = PsiDocumentManager.getInstance(editor.project!!).getPsiFile(editor.document)!! .getUserData(SourceFileMarker.KEY) if (fileMarker == null) { - log.warn("Could not find file marker for file: {}", editor.document) + log.warn("Could not find file marker for file: ${editor.document}") return } @@ -309,7 +313,7 @@ object LiveStatusManager : SourceMarkEventListener { val wrapperPanel = JPanel() wrapperPanel.layout = BorderLayout() - val config = SourceMarkerPlugin.getConfig(editor.project!!) + val config = SourceMarkerPlugin.getInstance(editor.project!!).getConfig() val statusBar = SpanStatusBar( LiveSourceLocation( inlayMark.artifactQualifiedName.identifier.substringBefore("#"), lineNumber, @@ -334,7 +338,7 @@ object LiveStatusManager : SourceMarkEventListener { } } - fun showBreakpointStatusBar(liveBreakpoint: LiveBreakpoint, fileMarker: SourceFileMarker) { + override fun showBreakpointStatusBar(liveBreakpoint: LiveBreakpoint, fileMarker: SourceFileMarker) { ApplicationManager.getApplication().invokeLater { val editor = FileEditorManager.getInstance(fileMarker.project).selectedTextEditor!! val findInlayMark = ArtifactCreationService.getOrCreateExpressionInlayMark(fileMarker, liveBreakpoint.location.line) @@ -366,12 +370,12 @@ object LiveStatusManager : SourceMarkEventListener { addStatusBar(inlayMark, statusBar) } } else { - log.warn("No detected expression at line {}. Inlay mark ignored", liveBreakpoint.location.line) + log.warn("No detected expression at line ${liveBreakpoint.location.line}. Inlay mark ignored") } } } - fun showLogStatusBar(liveLog: LiveLog, fileMarker: SourceFileMarker) { + override fun showLogStatusBar(liveLog: LiveLog, fileMarker: SourceFileMarker) { ApplicationManager.getApplication().invokeLater { val editor = FileEditorManager.getInstance(fileMarker.project).selectedTextEditor!! val findInlayMark = ArtifactCreationService.getOrCreateExpressionInlayMark(fileMarker, liveLog.location.line) @@ -406,13 +410,12 @@ object LiveStatusManager : SourceMarkEventListener { detector.addLiveLog(editor, inlayMark, liveLog.logFormat, liveLog.location.line) } } else { - log.warn("No detected expression at line {}. Inlay mark ignored", liveLog.location.line) + log.warn("No detected expression at line ${liveLog.location.line}. Inlay mark ignored") } } } - @JvmStatic - fun showMeterStatusIcon(liveMeter: LiveMeter, sourceFileMarker: SourceFileMarker) { + override fun showMeterStatusIcon(liveMeter: LiveMeter, sourceFileMarker: SourceFileMarker) { //create gutter popup ApplicationManager.getApplication().runReadAction { val gutterMark = ArtifactCreationService.getOrCreateExpressionGutterMark( @@ -441,7 +444,7 @@ object LiveStatusManager : SourceMarkEventListener { gutterMark.get().apply(true) addStatusBar(gutterMark.get(), statusBar) - SourceServices.Instance.liveView!!.addLiveViewSubscription( + project.getUserData(LIVE_VIEW_SERVICE)!!.addLiveViewSubscription( LiveViewSubscription( null, listOf(liveMeter.toMetricId()), @@ -462,31 +465,29 @@ object LiveStatusManager : SourceMarkEventListener { } } - @JvmStatic - fun addStatusBar(sourceMark: SourceMark, listener: InstrumentEventListener) { + override fun addStatusBar(sourceMark: SourceMark, listener: LiveInstrumentEventListener) { if (sourceMark.getUserData(INSTRUMENT_EVENT_LISTENERS) == null) { sourceMark.putUserData(INSTRUMENT_EVENT_LISTENERS, mutableSetOf()) } sourceMark.getUserData(INSTRUMENT_EVENT_LISTENERS)!!.add(listener) } - @JvmStatic - fun addViewEventListener(sourceMark: SourceMark, listener: ViewEventListener) { + override fun addViewEventListener(sourceMark: SourceMark, listener: LiveViewEventListener) { if (sourceMark.getUserData(VIEW_EVENT_LISTENERS) == null) { sourceMark.putUserData(VIEW_EVENT_LISTENERS, mutableSetOf()) } sourceMark.getUserData(VIEW_EVENT_LISTENERS)!!.add(listener) } - fun addActiveLiveInstrument(instrument: LiveInstrument) { + override fun addActiveLiveInstrument(instrument: LiveInstrument) { activeStatusBars.add(instrument) } - fun addActiveLiveInstruments(instruments: List) { + override fun addActiveLiveInstruments(instruments: List) { activeStatusBars.addAll(instruments) } - fun removeActiveLiveInstrument(instrument: LiveInstrument) { + override fun removeActiveLiveInstrument(instrument: LiveInstrument) { activeStatusBars.remove(instrument) } @@ -494,12 +495,12 @@ object LiveStatusManager : SourceMarkEventListener { activeStatusBars.removeIf { it.id == instrumentId } } - fun getLogData(inlayMark: InlayMark): List<*> { + override fun getLogData(inlayMark: InlayMark): List<*> { val logId = inlayMark.getUserData(INSTRUMENT_ID) return logData.getOrPut(logId) { CircularList(1000) } } - fun removeLogData(inlayMark: InlayMark) { + override fun removeLogData(inlayMark: InlayMark) { val logId = inlayMark.getUserData(INSTRUMENT_ID) logData.remove(logId) } diff --git a/plugin/src/main/resources/META-INF/plugin.xml b/plugin/src/main/resources/META-INF/plugin.xml index 3d7587826..865eacd6b 100644 --- a/plugin/src/main/resources/META-INF/plugin.xml +++ b/plugin/src/main/resources/META-INF/plugin.xml @@ -16,7 +16,7 @@ serviceImplementation="spp.jetbrains.sourcemarker.service.instrument.breakpoint.BreakpointHitWindowService"/> - - - - @@ -57,7 +52,6 @@ - diff --git a/plugin/src/main/resources/logback.xml b/plugin/src/main/resources/logback.xml deleted file mode 100644 index b32833033..000000000 --- a/plugin/src/main/resources/logback.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} %-5level %logger{5} - %msg%n - - - - - %d{HH:mm:ss.SSS} %-5level %logger{5} - %msg%n - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/GroovyEndpointDetectorTest.kt b/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/GroovyEndpointDetectorTest.kt index 65de924bf..1ba9bfac3 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/GroovyEndpointDetectorTest.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/GroovyEndpointDetectorTest.kt @@ -44,7 +44,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -69,7 +69,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -94,7 +94,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/", result.get().name) @@ -120,7 +120,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/todos", result.get().name) @@ -146,7 +146,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/todos", result.get().name) @@ -172,7 +172,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/todos/doGet", result.get().name) @@ -196,7 +196,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/", result.get().name) @@ -220,7 +220,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -244,7 +244,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -268,7 +268,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("doGet", result.get().name) @@ -292,7 +292,7 @@ class GroovyEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("TestController.doGet", result.get().name) diff --git a/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/JavaEndpointDetectorTest.kt b/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/JavaEndpointDetectorTest.kt index e00632c72..5ae8f9d9c 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/JavaEndpointDetectorTest.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/JavaEndpointDetectorTest.kt @@ -44,7 +44,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -69,7 +69,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -94,7 +94,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/", result.get().name) @@ -120,7 +120,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/todos", result.get().name) @@ -146,7 +146,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/todos", result.get().name) @@ -172,7 +172,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/todos/doGet", result.get().name) @@ -196,7 +196,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/", result.get().name) @@ -220,7 +220,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -244,7 +244,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -268,7 +268,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("doGet", result.get().name) @@ -292,7 +292,7 @@ class JavaEndpointDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("TestController.doGet", result.get().name) diff --git a/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/KotlinEndpointDetectorTest.kt b/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/KotlinEndpointDetectorTest.kt index 5ecbc83e5..bf4969d82 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/KotlinEndpointDetectorTest.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/KotlinEndpointDetectorTest.kt @@ -44,7 +44,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -69,7 +69,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -94,7 +94,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/", result.get().name) @@ -120,7 +120,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/todos", result.get().name) @@ -146,7 +146,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/todos", result.get().name) @@ -172,7 +172,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/todos/doGet", result.get().name) @@ -196,7 +196,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -220,7 +220,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -244,7 +244,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -268,7 +268,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/", result.get().name) @@ -292,7 +292,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("doGet", result.get().name) @@ -316,7 +316,7 @@ class KotlinEndpointDetectorTest : EndpointDetectorTest() { assertEquals(2, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("TestController.doGet", result.get().name) diff --git a/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/ScalaEndpointNameDetectorTest.kt b/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/ScalaEndpointNameDetectorTest.kt index 4cd6be784..0237a118f 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/ScalaEndpointNameDetectorTest.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/psi/endpoint/ScalaEndpointNameDetectorTest.kt @@ -44,7 +44,7 @@ class ScalaEndpointNameDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -68,7 +68,7 @@ class ScalaEndpointNameDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/", result.get().name) @@ -92,7 +92,7 @@ class ScalaEndpointNameDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -116,7 +116,7 @@ class ScalaEndpointNameDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("GET:/doGet", result.get().name) @@ -140,7 +140,7 @@ class ScalaEndpointNameDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("doGet", result.get().name) @@ -164,7 +164,7 @@ class ScalaEndpointNameDetectorTest : EndpointDetectorTest() { assertEquals(1, uFile.classes[0].methods.size) runBlocking { - val result = JVMEndpointDetector(SourceMarkerPlugin.vertx) + val result = JVMEndpointDetector(SourceMarkerPlugin.getInstance(project).vertx) .determineEndpointName(uFile.classes[0].methods[0]).await() assertTrue(result.isPresent) assertEquals("TestController.doGet", result.get().name)