diff --git a/gradle.properties b/gradle.properties index 9654654bb..b7511be51 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ kotlin.code.style=official pluginGroup = spp.jetbrains pluginName = Source++ -projectVersion=0.3.1 +projectVersion=0.4.0 pluginSinceBuild = 202.4357 # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions @@ -21,7 +21,7 @@ platformPlugins = java, Groovy, Kotlin, PythonCore:213.5744.223, org.intellij.sc # See https://kotlinlang.org/docs/reference/using-gradle.html#dependency-on-the-standard-library for details. kotlin.stdlib.default.dependency = true -apolloVersion=3.0.0 +apolloVersion=3.1.0 vertxVersion=4.2.4 slf4jVersion=1.7.33 jacksonVersion=2.13.1 diff --git a/mapper/src/main/kotlin/spp/jetbrains/mapper/api/impl/SourceMapperImpl.kt b/mapper/src/main/kotlin/spp/jetbrains/mapper/api/impl/SourceMapperImpl.kt index 3274951d9..edf50d779 100644 --- a/mapper/src/main/kotlin/spp/jetbrains/mapper/api/impl/SourceMapperImpl.kt +++ b/mapper/src/main/kotlin/spp/jetbrains/mapper/api/impl/SourceMapperImpl.kt @@ -17,12 +17,12 @@ */ package spp.jetbrains.mapper.api.impl +import org.slf4j.LoggerFactory import spp.jetbrains.mapper.api.SourceMapper import spp.jetbrains.mapper.vcs.git.GitRepositoryMapper import spp.jetbrains.mapper.vcs.git.LogFollowCommand import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.LocalArtifact -import org.slf4j.LoggerFactory import java.util.* /** diff --git a/mapper/src/main/kotlin/spp/jetbrains/mapper/vcs/git/GitRepositoryMapper.kt b/mapper/src/main/kotlin/spp/jetbrains/mapper/vcs/git/GitRepositoryMapper.kt index 2aa24aa02..550ad7483 100644 --- a/mapper/src/main/kotlin/spp/jetbrains/mapper/vcs/git/GitRepositoryMapper.kt +++ b/mapper/src/main/kotlin/spp/jetbrains/mapper/vcs/git/GitRepositoryMapper.kt @@ -18,7 +18,6 @@ package spp.jetbrains.mapper.vcs.git import com.google.common.base.Preconditions -import spp.jetbrains.mapper.extend.SourceCodeTokenizer import jp.ac.titech.c.se.stein.PorcelainAPI import jp.ac.titech.c.se.stein.core.Context import jp.ac.titech.c.se.stein.core.EntrySet @@ -29,6 +28,7 @@ import org.eclipse.jgit.api.Git import org.eclipse.jgit.internal.storage.file.FileRepository import org.eclipse.jgit.lib.Repository import org.slf4j.LoggerFactory +import spp.jetbrains.mapper.extend.SourceCodeTokenizer import java.io.File import java.nio.charset.StandardCharsets import java.util.* diff --git a/mapper/src/main/kotlin/spp/jetbrains/mapper/vcs/git/LogFollowCommand.kt b/mapper/src/main/kotlin/spp/jetbrains/mapper/vcs/git/LogFollowCommand.kt index 4a33d2b2f..72ee91365 100644 --- a/mapper/src/main/kotlin/spp/jetbrains/mapper/vcs/git/LogFollowCommand.kt +++ b/mapper/src/main/kotlin/spp/jetbrains/mapper/vcs/git/LogFollowCommand.kt @@ -17,10 +17,6 @@ */ package spp.jetbrains.mapper.vcs.git -import spp.jetbrains.mapper.api.impl.SourceMapperImpl -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.ArtifactType -import spp.protocol.artifact.LocalArtifact import org.eclipse.jgit.api.Git import org.eclipse.jgit.api.errors.GitAPIException import org.eclipse.jgit.diff.DiffEntry @@ -33,6 +29,10 @@ import org.eclipse.jgit.lib.Repository import org.eclipse.jgit.revwalk.RevCommit import org.eclipse.jgit.treewalk.TreeWalk import org.slf4j.LoggerFactory +import spp.jetbrains.mapper.api.impl.SourceMapperImpl +import spp.protocol.artifact.ArtifactQualifiedName +import spp.protocol.artifact.ArtifactType +import spp.protocol.artifact.LocalArtifact import java.io.IOException /** diff --git a/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/GroovyModificationTest.kt b/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/GroovyModificationTest.kt index 9966e013c..69d914876 100644 --- a/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/GroovyModificationTest.kt +++ b/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/GroovyModificationTest.kt @@ -17,11 +17,6 @@ */ package spp.jetbrains.mapper.integration -import spp.jetbrains.mapper.api.impl.SourceMapperImpl -import spp.jetbrains.mapper.extend.SourceCodeTokenizer -import spp.jetbrains.mapper.vcs.git.GitRepositoryMapper -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.ArtifactType import org.eclipse.jgit.api.Git import org.eclipse.jgit.internal.storage.file.FileRepository import org.eclipse.jgit.lib.Constants @@ -29,6 +24,11 @@ import org.intellij.lang.annotations.Language import org.junit.Assert.* import org.junit.Ignore import org.junit.Test +import spp.jetbrains.mapper.api.impl.SourceMapperImpl +import spp.jetbrains.mapper.extend.SourceCodeTokenizer +import spp.jetbrains.mapper.vcs.git.GitRepositoryMapper +import spp.protocol.artifact.ArtifactQualifiedName +import spp.protocol.artifact.ArtifactType import java.io.File import java.nio.file.Files import java.util.* diff --git a/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/JavaModificationTest.kt b/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/JavaModificationTest.kt index 2fbacf4a5..94eddf0a2 100644 --- a/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/JavaModificationTest.kt +++ b/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/JavaModificationTest.kt @@ -17,11 +17,6 @@ */ package spp.jetbrains.mapper.integration -import spp.jetbrains.mapper.api.impl.SourceMapperImpl -import spp.jetbrains.mapper.extend.SourceCodeTokenizer -import spp.jetbrains.mapper.vcs.git.GitRepositoryMapper -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.ArtifactType import org.eclipse.jgit.api.Git import org.eclipse.jgit.internal.storage.file.FileRepository import org.eclipse.jgit.lib.Constants @@ -29,6 +24,11 @@ import org.intellij.lang.annotations.Language import org.junit.Assert.* import org.junit.Ignore import org.junit.Test +import spp.jetbrains.mapper.api.impl.SourceMapperImpl +import spp.jetbrains.mapper.extend.SourceCodeTokenizer +import spp.jetbrains.mapper.vcs.git.GitRepositoryMapper +import spp.protocol.artifact.ArtifactQualifiedName +import spp.protocol.artifact.ArtifactType import java.io.File import java.nio.file.Files import java.util.* diff --git a/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/KotlinModificationTest.kt b/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/KotlinModificationTest.kt index ee9ac3caf..33faa1d71 100644 --- a/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/KotlinModificationTest.kt +++ b/mapper/src/test/kotlin/spp/jetbrains/mapper/integration/KotlinModificationTest.kt @@ -17,11 +17,6 @@ */ package spp.jetbrains.mapper.integration -import spp.jetbrains.mapper.api.impl.SourceMapperImpl -import spp.jetbrains.mapper.extend.SourceCodeTokenizer -import spp.jetbrains.mapper.vcs.git.GitRepositoryMapper -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.ArtifactType import org.eclipse.jgit.api.Git import org.eclipse.jgit.internal.storage.file.FileRepository import org.eclipse.jgit.lib.Constants @@ -29,6 +24,11 @@ import org.intellij.lang.annotations.Language import org.junit.Assert.* import org.junit.Ignore import org.junit.Test +import spp.jetbrains.mapper.api.impl.SourceMapperImpl +import spp.jetbrains.mapper.extend.SourceCodeTokenizer +import spp.jetbrains.mapper.vcs.git.GitRepositoryMapper +import spp.protocol.artifact.ArtifactQualifiedName +import spp.protocol.artifact.ArtifactType import java.io.File import java.nio.file.Files import java.util.* 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 5f10d7f9c..00077ff85 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 @@ -26,10 +26,6 @@ import com.intellij.psi.* import com.intellij.psi.search.FileTypeIndex import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.ProjectScope -import spp.jetbrains.marker.jvm.psi.EndpointDetector -import spp.jetbrains.marker.source.JVMMarkerUtils -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.ArtifactType import io.vertx.core.Promise import io.vertx.core.Vertx import io.vertx.kotlin.coroutines.await @@ -42,7 +38,11 @@ import org.jetbrains.uast.UMethod import org.jetbrains.uast.toUElement import org.jetbrains.uast.toUElementOfType import org.slf4j.LoggerFactory -import spp.protocol.utils.ArtifactNameUtils +import spp.jetbrains.marker.jvm.psi.EndpointDetector +import spp.jetbrains.marker.source.JVMMarkerUtils +import spp.protocol.artifact.ArtifactNameUtils +import spp.protocol.artifact.ArtifactQualifiedName +import spp.protocol.artifact.ArtifactType import java.util.* /** diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMArtifactNamingService.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMArtifactNamingService.kt index b7d661c21..cad9a12fa 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMArtifactNamingService.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMArtifactNamingService.kt @@ -20,12 +20,12 @@ package spp.jetbrains.marker.jvm import com.intellij.psi.PsiClassOwner import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile -import spp.jetbrains.marker.ArtifactNamingService -import spp.jetbrains.marker.source.JVMMarkerUtils import org.jetbrains.uast.UClass import org.jetbrains.uast.UExpression import org.jetbrains.uast.UMethod import org.jetbrains.uast.toUElement +import spp.jetbrains.marker.ArtifactNamingService +import spp.jetbrains.marker.source.JVMMarkerUtils import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.ArtifactType 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 e7a33320e..92bbec284 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 @@ -23,17 +23,17 @@ import com.intellij.openapi.editor.BlockInlayPriority import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethod import com.intellij.psi.PsiStatement -import spp.jetbrains.marker.SourceMarker -import spp.jetbrains.marker.plugin.SourceInlayHintProvider -import spp.jetbrains.marker.source.JVMMarkerUtils -import spp.jetbrains.marker.source.mark.inlay.InlayMark -import spp.jetbrains.marker.source.mark.inlay.config.InlayMarkVirtualText import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.psi.psiUtil.getParentOfType import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod import org.jetbrains.uast.UExpression import org.jetbrains.uast.UMethod import org.jetbrains.uast.toUElement +import spp.jetbrains.marker.SourceMarker +import spp.jetbrains.marker.plugin.SourceInlayHintProvider +import spp.jetbrains.marker.source.JVMMarkerUtils +import spp.jetbrains.marker.source.mark.inlay.InlayMark +import spp.jetbrains.marker.source.mark.inlay.config.InlayMarkVirtualText /** * todo: description. diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMVariableSimpleNode.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMVariableSimpleNode.kt index fc45b7520..183ab6ef2 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMVariableSimpleNode.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/JVMVariableSimpleNode.kt @@ -24,9 +24,9 @@ import com.intellij.ui.SimpleTextAttributes import com.intellij.ui.treeStructure.SimpleNode import com.intellij.xdebugger.impl.ui.DebuggerUIUtil import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants -import spp.protocol.instrument.LiveVariable -import spp.protocol.instrument.LiveVariableScope import org.apache.commons.lang3.EnumUtils +import spp.protocol.instrument.variable.LiveVariable +import spp.protocol.instrument.variable.LiveVariableScope /** * todo: description. diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/EndpointDetector.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/EndpointDetector.kt index 78c36de21..41bd2b306 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/EndpointDetector.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/EndpointDetector.kt @@ -19,12 +19,6 @@ package spp.jetbrains.marker.jvm.psi import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.util.Computable -import spp.jetbrains.marker.jvm.psi.endpoint.SkywalkingTraceEndpoint -import spp.jetbrains.marker.jvm.psi.endpoint.SpringMVCEndpoint -import spp.jetbrains.marker.source.mark.api.MethodSourceMark -import spp.jetbrains.marker.source.mark.api.SourceMark -import spp.jetbrains.marker.source.mark.api.key.SourceKey -import spp.jetbrains.monitor.skywalking.bridge.EndpointBridge import io.vertx.core.Future import io.vertx.core.Promise import io.vertx.core.Vertx @@ -39,6 +33,12 @@ import kotlinx.coroutines.withContext import org.jetbrains.uast.UMethod import org.jetbrains.uast.toUElement import org.slf4j.LoggerFactory +import spp.jetbrains.marker.jvm.psi.endpoint.SkywalkingTraceEndpoint +import spp.jetbrains.marker.jvm.psi.endpoint.SpringMVCEndpoint +import spp.jetbrains.marker.source.mark.api.MethodSourceMark +import spp.jetbrains.marker.source.mark.api.SourceMark +import spp.jetbrains.marker.source.mark.api.key.SourceKey +import spp.jetbrains.monitor.skywalking.bridge.EndpointBridge import java.util.* /** 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 197065958..3cc3f5d50 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 @@ -27,10 +27,6 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethodCallExpression import com.intellij.refactoring.suggested.endOffset import com.intellij.refactoring.suggested.startOffset -import spp.jetbrains.marker.source.SourceFileMarker -import spp.jetbrains.marker.source.mark.api.MethodSourceMark -import spp.jetbrains.marker.source.mark.api.key.SourceKey -import spp.jetbrains.marker.source.mark.inlay.InlayMark import io.vertx.core.Future import io.vertx.core.Promise import io.vertx.core.Vertx @@ -43,6 +39,10 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.stringValue import org.jetbrains.uast.UMethod import org.jetbrains.uast.toUElement 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 +import spp.jetbrains.marker.source.mark.inlay.InlayMark /** * Detects the presence of log statements within methods and saves log patterns. diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/PluginSqlProducerSearch.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/PluginSqlProducerSearch.kt deleted file mode 100644 index 50904504c..000000000 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/PluginSqlProducerSearch.kt +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.jetbrains.marker.jvm.psi - -import com.intellij.openapi.application.ApplicationManager -import com.intellij.psi.PsiMethod -import com.intellij.psi.impl.compiled.ClsMethodImpl -import com.intellij.psi.search.searches.OverridingMethodsSearch -import spp.jetbrains.marker.jvm.ArtifactSearch -import spp.jetbrains.marker.source.JVMMarkerUtils -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.ArtifactType -import spp.protocol.extend.SqlProducerSearch -import spp.jetbrains.marker.jvm.psi.sqlsource.SpringDataSqlSource -import io.vertx.core.Promise -import io.vertx.core.Vertx -import io.vertx.kotlin.coroutines.await -import io.vertx.kotlin.coroutines.dispatcher -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import org.jetbrains.uast.UCallExpression -import org.jetbrains.uast.UMethod -import org.jetbrains.uast.toUElementOfType -import org.jetbrains.uast.visitor.AbstractUastVisitor -import org.jooq.Query -import org.slf4j.LoggerFactory -import java.util.* - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class PluginSqlProducerSearch(val vertx: Vertx) : SqlProducerSearch { - - companion object { - private val log = LoggerFactory.getLogger(PluginSqlProducerSearch::class.java) - } - - private val detectorSet = setOf( - SpringDataSqlSource() - ) - - val possibleRegressionSources = mutableListOf() - - override suspend fun determineSource( - query: Query, - searchPoint: ArtifactQualifiedName - ): Optional { - val promise = Promise.promise>() - val searchArtifact = ArtifactSearch.findArtifact(vertx ,searchPoint) - if (searchArtifact == null) { - promise.fail("Could not determine search point artifact") - return promise.future().await() - } - - ApplicationManager.getApplication().runReadAction { - dependencySearch(searchArtifact.toUElementOfType()!!) - - GlobalScope.launch(vertx.dispatcher()) { - var keepSearching = true - for (method in possibleRegressionSources) { //todo: fix dupes - for (detector in detectorSet) { - try { - if (detector.isSqlSource(query, method)) { - promise.complete(Optional.of(JVMMarkerUtils.getFullyQualifiedName(method.method))) - keepSearching = false - } - } catch (throwable: Throwable) { - promise.fail(throwable) - } - if (!keepSearching) break - } - if (!keepSearching) break - } - promise.tryComplete(Optional.empty()) - } - } - return promise.future().await() - } - - private fun dependencySearch(method: UMethod) { - method.accept(object : AbstractUastVisitor() { - override fun visitCallExpression(node: UCallExpression): Boolean { - val calledMethod = node.resolve() - if (calledMethod != null) { - if (calledMethod.body == null) { - possibleRegressionSources.add(CalledMethod(node, calledMethod)) - - if (calledMethod !is ClsMethodImpl) { - //interface/abstract method; search implementations - val implMethods = OverridingMethodsSearch.search(calledMethod).toList() - implMethods.forEach { - dependencySearch(it.toUElementOfType()!!) - } - } - } - } else { - log.warn("Failed to resolve: $node") - } - return super.visitCallExpression(node) - } - }) - } - - /** - * todo: description. - */ - interface SqlSourceDeterminer { - fun isSqlSource(query: Query, calledMethod: CalledMethod): Boolean - } - - /** - * todo: description. - */ - data class CalledMethod( - val call: UCallExpression, - val method: PsiMethod - ) -} diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/endpoint/SkywalkingTraceEndpoint.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/endpoint/SkywalkingTraceEndpoint.kt index 0bfc78f64..8b5a905c1 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/endpoint/SkywalkingTraceEndpoint.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/endpoint/SkywalkingTraceEndpoint.kt @@ -18,12 +18,12 @@ package spp.jetbrains.marker.jvm.psi.endpoint import com.intellij.openapi.application.ApplicationManager -import spp.jetbrains.marker.jvm.psi.EndpointDetector -import spp.jetbrains.marker.jvm.psi.EndpointDetector.DetectedEndpoint import io.vertx.core.Future import io.vertx.core.Promise import org.jetbrains.uast.UMethod import org.jetbrains.uast.expressions.UInjectionHost +import spp.jetbrains.marker.jvm.psi.EndpointDetector +import spp.jetbrains.marker.jvm.psi.EndpointDetector.DetectedEndpoint import java.util.* /** diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/endpoint/SpringMVCEndpoint.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/endpoint/SpringMVCEndpoint.kt index 1a504bd27..f219ee4a0 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/endpoint/SpringMVCEndpoint.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/endpoint/SpringMVCEndpoint.kt @@ -19,8 +19,6 @@ package spp.jetbrains.marker.jvm.psi.endpoint import com.intellij.lang.Language import com.intellij.openapi.application.ApplicationManager -import spp.jetbrains.marker.jvm.psi.EndpointDetector -import spp.jetbrains.marker.jvm.psi.EndpointDetector.DetectedEndpoint import io.vertx.core.Future import io.vertx.core.Promise import org.jetbrains.plugins.groovy.lang.psi.uast.GrUReferenceExpression @@ -31,6 +29,8 @@ import org.jetbrains.uast.kotlin.KotlinStringULiteralExpression import org.jetbrains.uast.kotlin.KotlinUQualifiedReferenceExpression import org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression import org.jetbrains.uast.kotlin.expressions.KotlinUCollectionLiteralExpression +import spp.jetbrains.marker.jvm.psi.EndpointDetector +import spp.jetbrains.marker.jvm.psi.EndpointDetector.DetectedEndpoint import java.util.* /** diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/sqlsource/SpringDataSqlSource.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/sqlsource/SpringDataSqlSource.kt deleted file mode 100644 index 9233d5d26..000000000 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/psi/sqlsource/SpringDataSqlSource.kt +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.jetbrains.marker.jvm.psi.sqlsource - -import com.intellij.psi.impl.compiled.ClsMethodImpl -import com.intellij.psi.util.PsiUtil -import spp.jetbrains.marker.jvm.psi.PluginSqlProducerSearch -import spp.jetbrains.marker.jvm.psi.PluginSqlProducerSearch.CalledMethod -import org.jooq.Query - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class SpringDataSqlSource : PluginSqlProducerSearch.SqlSourceDeterminer { - - private val findAll = "org.springframework.data.repository.CrudRepository.findAll" - - override fun isSqlSource(query: Query, calledMethod: CalledMethod): Boolean { - if (calledMethod.method is ClsMethodImpl) { - if (PsiUtil.getMemberQualifiedName(calledMethod.method) == findAll) { - //todo: more strict verification - //java.lang.Iterable - val iterableType = calledMethod.call.returnType!!.canonicalText - val queryType = iterableType.substring(0, iterableType.length - 1) - .replace("java.lang.Iterable<", "") - var tableName = queryType - if (tableName.contains(".")) { - tableName = tableName.substring(tableName.lastIndexOf(".") + 1).toUpperCase() - } - val tableNames = query.tableNames() - if (tableNames.size == 1) { - return tableNames[0] == tableName - } - return false - } else { - return false - } - } else { - return false - } - } - - //todo: remove when jooq offers public access to parsed queries - private fun Query.tableNames(): List { - val fromField = javaClass.getDeclaredField("from") - fromField.isAccessible = true - val fromTables = fromField.get(this) as List<*> - return fromTables.map { - val aliasField = it!!.javaClass.getDeclaredField("alias") - aliasField.isAccessible = true - val alias = aliasField.get(it) - val wrappedField = alias.javaClass.getDeclaredField("wrapped") - wrappedField.isAccessible = true - val wrapped = wrappedField.get(alias) - wrapped.toString() - } - } -} 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 e0b4ae34e..f62219db5 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 @@ -20,11 +20,11 @@ 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 import spp.jetbrains.marker.source.mark.gutter.GutterMark -import org.slf4j.LoggerFactory /** * Associates Python [GutterMark]s to PSI elements. diff --git a/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonVariableRootNode.kt b/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonVariableRootNode.kt index 5ec1babf1..4ed35a812 100644 --- a/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonVariableRootNode.kt +++ b/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonVariableRootNode.kt @@ -22,8 +22,8 @@ import com.intellij.openapi.editor.DefaultLanguageHighlighterColors import com.intellij.ui.SimpleTextAttributes import com.intellij.ui.treeStructure.SimpleNode import com.intellij.xdebugger.impl.ui.DebuggerUIUtil -import spp.protocol.instrument.LiveVariable -import spp.protocol.instrument.LiveVariableScope +import spp.protocol.instrument.variable.LiveVariable +import spp.protocol.instrument.variable.LiveVariableScope /** * todo: description. diff --git a/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonVariableSimpleNode.kt b/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonVariableSimpleNode.kt index 4b6f5bc7e..abe75d497 100644 --- a/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonVariableSimpleNode.kt +++ b/marker/py-marker/src/main/kotlin/spp/jetbrains/marker/py/PythonVariableSimpleNode.kt @@ -24,7 +24,7 @@ import com.intellij.ui.treeStructure.SimpleNode import com.intellij.xdebugger.impl.ui.DebuggerUIUtil import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants import io.vertx.core.json.JsonObject -import spp.protocol.instrument.LiveVariable +import spp.protocol.instrument.variable.LiveVariable /** * todo: description. 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 1510afe5c..070b2da31 100644 --- a/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceLineMarkerProvider.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/plugin/SourceLineMarkerProvider.kt @@ -22,10 +22,10 @@ import com.intellij.codeInsight.daemon.LineMarkerInfo import com.intellij.codeInsight.daemon.LineMarkerProviderDescriptor import com.intellij.openapi.editor.markup.GutterIconRenderer.Alignment.CENTER import com.intellij.psi.PsiElement +import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.source.mark.api.key.SourceKey import spp.jetbrains.marker.source.mark.gutter.GutterMark -import org.slf4j.LoggerFactory /** * Used to associate [GutterMark]s with IntelliJ PSI elements. 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 df9ae9579..8b093e294 100755 --- a/marker/src/main/kotlin/spp/jetbrains/marker/source/SourceFileMarker.kt +++ b/marker/src/main/kotlin/spp/jetbrains/marker/source/SourceFileMarker.kt @@ -26,6 +26,7 @@ import com.intellij.openapi.util.Key import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.PsiNameIdentifierOwner +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 @@ -35,7 +36,6 @@ import spp.jetbrains.marker.source.mark.gutter.ExpressionGutterMark import spp.jetbrains.marker.source.mark.gutter.MethodGutterMark import spp.jetbrains.marker.source.mark.inlay.ExpressionInlayMark import spp.jetbrains.marker.source.mark.inlay.MethodInlayMark -import org.slf4j.LoggerFactory import spp.protocol.artifact.ArtifactQualifiedName import java.util.* 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 3c4d98954..a890ab2bd 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 @@ -23,6 +23,8 @@ import com.intellij.openapi.actionSystem.CommonDataKeys 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 @@ -30,8 +32,6 @@ import spp.jetbrains.marker.source.mark.api.MethodSourceMark import spp.jetbrains.marker.source.mark.api.SourceMark import spp.jetbrains.marker.source.mark.api.event.SourceMarkEvent import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode -import org.jetbrains.annotations.NotNull -import org.slf4j.LoggerFactory /** * todo: description. 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 2feb65aca..6711dcbd7 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingClient.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingClient.kt @@ -20,9 +20,6 @@ package spp.jetbrains.monitor.skywalking import com.apollographql.apollo3.ApolloClient import com.apollographql.apollo3.api.Optional import com.codahale.metrics.MetricRegistry -import spp.jetbrains.monitor.skywalking.model.GetEndpointMetrics -import spp.jetbrains.monitor.skywalking.model.GetEndpointTraces -import spp.jetbrains.monitor.skywalking.model.GetMultipleEndpointMetrics import io.vertx.core.Vertx import monitor.skywalking.protocol.log.QueryLogsQuery import monitor.skywalking.protocol.metadata.GetAllServicesQuery @@ -34,12 +31,14 @@ 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 import spp.protocol.util.LocalMessageCodec import java.io.IOException import java.time.ZoneOffset.ofHours import java.time.ZonedDateTime import java.time.format.DateTimeFormatter -import java.util.* /** * Used to communicate with Apache SkyWalking. diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingExtensions.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingExtensions.kt index 5f23fdbbc..22d6dd1a9 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingExtensions.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingExtensions.kt @@ -17,12 +17,6 @@ */ package spp.jetbrains.monitor.skywalking -import spp.jetbrains.monitor.skywalking.model.GetEndpointMetrics -import spp.protocol.artifact.QueryTimeFrame -import spp.protocol.artifact.metrics.ArtifactMetricResult -import spp.protocol.artifact.metrics.ArtifactMetrics -import spp.protocol.artifact.metrics.MetricType -import spp.protocol.artifact.trace.* import kotlinx.datetime.Instant import monitor.skywalking.protocol.metrics.GetLinearIntValuesQuery import monitor.skywalking.protocol.metrics.GetMultipleLinearIntValuesQuery @@ -30,8 +24,13 @@ import monitor.skywalking.protocol.trace.QueryBasicTracesQuery import monitor.skywalking.protocol.trace.QueryTraceQuery import monitor.skywalking.protocol.type.QueryOrder import monitor.skywalking.protocol.type.TraceState +import spp.jetbrains.monitor.skywalking.model.GetEndpointMetrics import spp.protocol.artifact.ArtifactQualifiedName -import java.math.BigDecimal +import spp.protocol.artifact.QueryTimeFrame +import spp.protocol.artifact.metrics.ArtifactMetricResult +import spp.protocol.artifact.metrics.ArtifactMetrics +import spp.protocol.artifact.metrics.MetricType +import spp.protocol.artifact.trace.* fun toProtocol( artifactQualifiedName: ArtifactQualifiedName, 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 5c0b6772c..c52685b98 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 @@ -17,7 +17,6 @@ */ package spp.jetbrains.monitor.skywalking.bridge -import spp.jetbrains.monitor.skywalking.SkywalkingClient import io.vertx.core.Vertx import io.vertx.core.eventbus.ReplyException import io.vertx.core.eventbus.ReplyFailure @@ -27,6 +26,7 @@ import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.launch import monitor.skywalking.protocol.metadata.SearchEndpointQuery import org.slf4j.LoggerFactory +import spp.jetbrains.monitor.skywalking.SkywalkingClient import spp.protocol.util.LocalMessageCodec /** diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointMetricsBridge.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointMetricsBridge.kt index ff347568d..ce2fdab7f 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointMetricsBridge.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointMetricsBridge.kt @@ -17,9 +17,6 @@ */ package spp.jetbrains.monitor.skywalking.bridge -import spp.jetbrains.monitor.skywalking.SkywalkingClient -import spp.jetbrains.monitor.skywalking.model.GetEndpointMetrics -import spp.jetbrains.monitor.skywalking.model.GetMultipleEndpointMetrics import io.vertx.core.Vertx import io.vertx.kotlin.coroutines.CoroutineVerticle import io.vertx.kotlin.coroutines.await @@ -27,6 +24,9 @@ import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.launch import monitor.skywalking.protocol.metrics.GetLinearIntValuesQuery import monitor.skywalking.protocol.metrics.GetMultipleLinearIntValuesQuery +import spp.jetbrains.monitor.skywalking.SkywalkingClient +import spp.jetbrains.monitor.skywalking.model.GetEndpointMetrics +import spp.jetbrains.monitor.skywalking.model.GetMultipleEndpointMetrics /** * todo: description. diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointTracesBridge.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointTracesBridge.kt index 1e5d39881..9e6f43b5a 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointTracesBridge.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/EndpointTracesBridge.kt @@ -17,18 +17,18 @@ */ package spp.jetbrains.monitor.skywalking.bridge -import spp.jetbrains.monitor.skywalking.SkywalkingClient -import spp.jetbrains.monitor.skywalking.model.GetEndpointTraces -import spp.jetbrains.monitor.skywalking.toProtocol -import spp.protocol.artifact.trace.Trace -import spp.protocol.artifact.trace.TraceResult -import spp.protocol.artifact.trace.TraceSpanStackQueryResult import io.vertx.core.Vertx import io.vertx.kotlin.coroutines.CoroutineVerticle import io.vertx.kotlin.coroutines.await import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.launch import kotlinx.datetime.Instant +import spp.jetbrains.monitor.skywalking.SkywalkingClient +import spp.jetbrains.monitor.skywalking.model.GetEndpointTraces +import spp.jetbrains.monitor.skywalking.toProtocol +import spp.protocol.artifact.trace.Trace +import spp.protocol.artifact.trace.TraceResult +import spp.protocol.artifact.trace.TraceSpanStackQueryResult /** * todo: description. diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/LogsBridge.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/LogsBridge.kt index a3c791eb8..2317c985c 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/LogsBridge.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/LogsBridge.kt @@ -18,12 +18,6 @@ package spp.jetbrains.monitor.skywalking.bridge import com.apollographql.apollo3.api.Optional -import spp.jetbrains.monitor.skywalking.SkywalkingClient -import spp.jetbrains.monitor.skywalking.model.ZonedDuration -import spp.protocol.artifact.exception.LiveStackTrace -import spp.protocol.artifact.log.Log -import spp.protocol.artifact.log.LogOrderType -import spp.protocol.artifact.log.LogResult import io.vertx.core.AsyncResult import io.vertx.core.Future import io.vertx.core.Vertx @@ -35,6 +29,12 @@ import kotlinx.datetime.Clock import kotlinx.datetime.Instant import monitor.skywalking.protocol.type.LogQueryCondition import monitor.skywalking.protocol.type.Pagination +import spp.jetbrains.monitor.skywalking.SkywalkingClient +import spp.jetbrains.monitor.skywalking.model.ZonedDuration +import spp.protocol.artifact.exception.LiveStackTrace +import spp.protocol.artifact.log.Log +import spp.protocol.artifact.log.LogOrderType +import spp.protocol.artifact.log.LogResult import spp.protocol.util.LocalMessageCodec /** 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 dabaf68cf..806b204c3 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 @@ -17,8 +17,6 @@ */ package spp.jetbrains.monitor.skywalking.bridge -import spp.jetbrains.monitor.skywalking.SkywalkingClient -import spp.jetbrains.monitor.skywalking.SkywalkingClient.DurationStep import io.vertx.core.Vertx import io.vertx.core.eventbus.MessageConsumer import io.vertx.kotlin.coroutines.CoroutineVerticle @@ -26,6 +24,8 @@ import io.vertx.kotlin.coroutines.await import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.launch import monitor.skywalking.protocol.metadata.GetAllServicesQuery +import spp.jetbrains.monitor.skywalking.SkywalkingClient +import spp.jetbrains.monitor.skywalking.SkywalkingClient.DurationStep import java.time.ZonedDateTime /** diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/ServiceInstanceBridge.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/ServiceInstanceBridge.kt index 934246abf..feed39454 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/ServiceInstanceBridge.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/bridge/ServiceInstanceBridge.kt @@ -17,8 +17,6 @@ */ package spp.jetbrains.monitor.skywalking.bridge -import spp.jetbrains.monitor.skywalking.SkywalkingClient -import spp.jetbrains.monitor.skywalking.SkywalkingClient.DurationStep import io.vertx.core.Vertx import io.vertx.core.eventbus.MessageConsumer import io.vertx.kotlin.coroutines.CoroutineVerticle @@ -26,6 +24,8 @@ import io.vertx.kotlin.coroutines.await import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.launch import monitor.skywalking.protocol.metadata.GetServiceInstancesQuery +import spp.jetbrains.monitor.skywalking.SkywalkingClient +import spp.jetbrains.monitor.skywalking.SkywalkingClient.DurationStep import java.time.ZonedDateTime /** diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/GetEndpointMetrics.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/GetEndpointMetrics.kt index d744929de..389b6a05a 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/GetEndpointMetrics.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/GetEndpointMetrics.kt @@ -17,8 +17,8 @@ */ package spp.jetbrains.monitor.skywalking.model -import spp.jetbrains.monitor.skywalking.SkywalkingClient.DurationStep import kotlinx.datetime.Instant +import spp.jetbrains.monitor.skywalking.SkywalkingClient.DurationStep import java.time.Duration import java.time.Period import java.time.ZonedDateTime diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/GetMultipleEndpointMetrics.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/GetMultipleEndpointMetrics.kt index 52e4506ef..4f32aaa18 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/GetMultipleEndpointMetrics.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/GetMultipleEndpointMetrics.kt @@ -17,8 +17,8 @@ */ package spp.jetbrains.monitor.skywalking.model -import spp.jetbrains.monitor.skywalking.SkywalkingClient.DurationStep import kotlinx.datetime.Instant +import spp.jetbrains.monitor.skywalking.SkywalkingClient.DurationStep import java.time.Duration import java.time.Period import java.time.ZonedDateTime diff --git a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/ZonedDuration.kt b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/ZonedDuration.kt index ca7549b56..a3cc7c186 100644 --- a/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/ZonedDuration.kt +++ b/monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/model/ZonedDuration.kt @@ -17,8 +17,8 @@ */ package spp.jetbrains.monitor.skywalking.model -import spp.jetbrains.monitor.skywalking.SkywalkingClient import monitor.skywalking.protocol.type.Duration +import spp.jetbrains.monitor.skywalking.SkywalkingClient import java.time.ZonedDateTime /** diff --git a/plugin/.ext/vertx-service-discovery-4.0.3-SNAPSHOT.jar b/plugin/.ext/vertx-service-discovery-4.0.3-SNAPSHOT.jar deleted file mode 100644 index 451d90e89..000000000 Binary files a/plugin/.ext/vertx-service-discovery-4.0.3-SNAPSHOT.jar and /dev/null differ diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index da467fb0c..617245ca5 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -77,7 +77,7 @@ dependencies { implementation("io.vertx:vertx-lang-kotlin:$vertxVersion") implementation("io.vertx:vertx-lang-kotlin-coroutines:$vertxVersion") implementation("io.vertx:vertx-web:$vertxVersion") - implementation(files(".ext/vertx-service-discovery-4.0.3-SNAPSHOT.jar")) + implementation("io.vertx:vertx-service-discovery:$vertxVersion") implementation("io.vertx:vertx-service-proxy:$vertxVersion") implementation("io.vertx:vertx-tcp-eventbus-bridge:$vertxVersion") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.1") diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/ControlBar.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/ControlBar.java index 2b4ecba56..3e868fa28 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/ControlBar.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/ControlBar.java @@ -12,7 +12,7 @@ import spp.jetbrains.sourcemarker.command.LiveControlCommand; import spp.jetbrains.sourcemarker.status.util.AutocompleteField; import spp.jetbrains.sourcemarker.status.util.ControlBarCellRenderer; -import spp.protocol.utils.ArtifactNameUtils; +import spp.protocol.artifact.ArtifactNameUtils; import javax.swing.*; import javax.swing.border.CompoundBorder; @@ -24,10 +24,7 @@ import java.util.function.Function; import java.util.stream.Collectors; -import static spp.jetbrains.sourcemarker.PluginUI.ROBOTO_LIGHT_PLAIN_17; -import static spp.jetbrains.sourcemarker.PluginUI.SELECT_COLOR_RED; -import static spp.jetbrains.sourcemarker.PluginUI.STATUS_BAR_TXT_BG_COLOR; -import static spp.jetbrains.sourcemarker.PluginUI.DFLT_BGND_COLOR; +import static spp.jetbrains.sourcemarker.PluginUI.*; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; public class ControlBar extends JPanel implements VisibleAreaListener { diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/element/LiveControlBarRow.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/element/LiveControlBarRow.java index df7bbe2fb..72edad976 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/element/LiveControlBarRow.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/element/LiveControlBarRow.java @@ -2,27 +2,14 @@ import com.intellij.util.ui.UIUtil; import com.jgoodies.forms.factories.FormFactory; -import com.jgoodies.forms.layout.CellConstraints; -import com.jgoodies.forms.layout.ColumnSpec; -import com.jgoodies.forms.layout.FormLayout; -import com.jgoodies.forms.layout.FormSpec; -import com.jgoodies.forms.layout.RowSpec; -import com.jgoodies.forms.layout.Sizes; +import com.jgoodies.forms.layout.*; import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static spp.jetbrains.sourcemarker.PluginUI.CONTROL_BAR_CMD_FOREGROUND; -import static spp.jetbrains.sourcemarker.PluginUI.PANEL_BACKGROUND_COLOR; -import static spp.jetbrains.sourcemarker.PluginUI.ROBOTO_PLAIN_11; -import static spp.jetbrains.sourcemarker.PluginUI.ROBOTO_PLAIN_15; -import static spp.jetbrains.sourcemarker.PluginUI.SELECT_COLOR_RED; +import java.util.*; + +import static spp.jetbrains.sourcemarker.PluginUI.*; public class LiveControlBarRow extends JPanel { diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/LiveBreakpointConfigurationPanel.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/LiveBreakpointConfigurationPanel.java index 3adfa139a..a9e065b7b 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/LiveBreakpointConfigurationPanel.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/LiveBreakpointConfigurationPanel.java @@ -1,11 +1,10 @@ package spp.jetbrains.sourcemarker.settings; +import net.miginfocom.swing.MigLayout; import spp.jetbrains.sourcemarker.PluginUI; import spp.jetbrains.sourcemarker.status.util.AutocompleteField; -import net.miginfocom.swing.MigLayout; import javax.swing.*; -import javax.swing.border.LineBorder; import java.awt.*; import java.util.Objects; diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/LiveLogConfigurationPanel.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/LiveLogConfigurationPanel.java index db859a3c1..c3114b324 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/LiveLogConfigurationPanel.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/LiveLogConfigurationPanel.java @@ -6,28 +6,27 @@ import com.intellij.openapi.editor.event.DocumentListener; import com.intellij.psi.PsiFile; import com.intellij.ui.EditorTextField; -import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.XDebuggerUtil; import com.intellij.xdebugger.XExpression; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl; import com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox; +import net.miginfocom.swing.MigLayout; +import org.jetbrains.annotations.NotNull; import spp.jetbrains.marker.source.mark.inlay.InlayMark; import spp.jetbrains.sourcemarker.PluginUI; import spp.jetbrains.sourcemarker.status.util.AutocompleteField; -import net.miginfocom.swing.MigLayout; -import org.jetbrains.annotations.NotNull; import javax.swing.*; -import javax.swing.border.LineBorder; import java.awt.*; import java.util.Objects; import static spp.jetbrains.marker.SourceMarker.conditionParser; import static spp.jetbrains.sourcemarker.PluginUI.DFLT_BGND_COLOR; import static spp.jetbrains.sourcemarker.PluginUI.ROBOTO_LIGHT_PLAIN_15; -import static spp.jetbrains.sourcemarker.activities.PluginSourceMarkerStartupActivity.*; +import static spp.jetbrains.sourcemarker.activities.PluginSourceMarkerStartupActivity.INTELLIJ_PRODUCT_CODES; +import static spp.jetbrains.sourcemarker.activities.PluginSourceMarkerStartupActivity.PYCHARM_PRODUCT_CODES; public class LiveLogConfigurationPanel extends JPanel { 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 9bf8acbd8..4a3971224 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.java @@ -22,7 +22,7 @@ import java.util.stream.Collectors; import static spp.jetbrains.sourcemarker.PluginBundle.message; -import static spp.protocol.SourceMarkerServices.Instance.INSTANCE; +import static spp.protocol.SourceServices.Instance.INSTANCE; public class PluginConfigurationPanel { private JPanel myWholePanel; @@ -46,7 +46,7 @@ public PluginConfigurationPanel(SourceMarkerConfig config) { myGlobalSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder(message("plugin_settings"))); if (INSTANCE.getLiveService() != null) { - INSTANCE.getLiveService().getServices(it -> { + INSTANCE.getLiveService().getServices().onComplete(it -> { if (it.succeeded()) { it.result().forEach(service -> serviceComboBox.addItem(service.getName())); 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 d84e2d03f..e9faf22ae 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/BreakpointStatusBar.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/BreakpointStatusBar.java @@ -13,6 +13,7 @@ import com.intellij.util.ui.ListTableModel; import com.intellij.util.ui.UIUtil; import io.vertx.core.json.Json; +import io.vertx.core.json.JsonObject; import net.miginfocom.swing.MigLayout; import org.apache.commons.lang.StringUtils; import spp.jetbrains.marker.source.mark.api.SourceMark; @@ -25,16 +26,14 @@ import spp.jetbrains.sourcemarker.service.breakpoint.BreakpointHitWindowService; import spp.jetbrains.sourcemarker.settings.LiveBreakpointConfigurationPanel; import spp.jetbrains.sourcemarker.status.util.AutocompleteField; -import spp.protocol.SourceMarkerServices; -import spp.protocol.instrument.InstrumentThrottle; +import spp.protocol.instrument.LiveBreakpoint; import spp.protocol.instrument.LiveInstrument; -import spp.protocol.instrument.LiveInstrumentEvent; import spp.protocol.instrument.LiveSourceLocation; -import spp.protocol.instrument.ThrottleStep; -import spp.protocol.instrument.breakpoint.LiveBreakpoint; -import spp.protocol.instrument.breakpoint.event.LiveBreakpointHit; -import spp.protocol.instrument.breakpoint.event.LiveBreakpointRemoved; -import spp.protocol.service.live.LiveInstrumentService; +import spp.protocol.instrument.event.LiveBreakpointHit; +import spp.protocol.instrument.event.LiveInstrumentEvent; +import spp.protocol.instrument.event.LiveInstrumentRemoved; +import spp.protocol.instrument.throttle.InstrumentThrottle; +import spp.protocol.instrument.throttle.ThrottleStep; import javax.swing.*; import javax.swing.border.CompoundBorder; @@ -42,18 +41,11 @@ import javax.swing.border.LineBorder; import javax.swing.event.DocumentEvent; import java.awt.*; -import java.awt.event.ComponentEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; +import java.awt.event.*; import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Objects; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; @@ -62,8 +54,10 @@ import static spp.jetbrains.marker.SourceMarker.conditionParser; import static spp.jetbrains.sourcemarker.PluginUI.*; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; -import static spp.protocol.instrument.LiveInstrumentEventType.BREAKPOINT_HIT; -import static spp.protocol.instrument.LiveInstrumentEventType.BREAKPOINT_REMOVED; +import static spp.protocol.ProtocolMarshaller.deserializeLiveInstrumentRemoved; +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; public class BreakpointStatusBar extends JPanel implements StatusBar, VisibleAreaListener { @@ -182,7 +176,7 @@ private void setupAsActive() { } else if (event.getEventType() == BREAKPOINT_REMOVED) { configLabel.setIcon(PluginIcons.eyeSlash); - LiveBreakpointRemoved removed = Json.decodeValue(event.getData(), LiveBreakpointRemoved.class); + LiveInstrumentRemoved removed = deserializeLiveInstrumentRemoved(new JsonObject(event.getData())); if (removed.getCause() == null) { statusPanel.setStatus("Complete", COMPLETE_COLOR_PURPLE); } else { @@ -444,7 +438,6 @@ private void saveLiveBreakpoint() { HashMap meta = new HashMap<>(); meta.put("original_source_mark", inlayMark.getId()); - LiveInstrumentService instrumentService = Objects.requireNonNull(SourceMarkerServices.Instance.INSTANCE.getLiveInstrument()); LiveBreakpoint instrument = new LiveBreakpoint( sourceLocation, condition, @@ -457,7 +450,7 @@ private void saveLiveBreakpoint() { throttle, meta ); - instrumentService.addLiveInstrument(instrument, it -> { + INSTANCE.getLiveInstrument().addLiveInstrument(instrument).onComplete(it -> { if (it.succeeded()) { liveBreakpoint = (LiveBreakpoint) it.result(); inlayMark.putUserData(SourceMarkKeys.INSTANCE.getBREAKPOINT_ID(), liveBreakpoint.getId()); @@ -481,7 +474,7 @@ private void dispose() { if (groupedMarks != null) groupedMarks.forEach(SourceMark::dispose); if (liveBreakpoint != null) { - SourceMarkerServices.Instance.INSTANCE.getLiveInstrument().removeLiveInstrument(liveBreakpoint.getId(), it -> { + INSTANCE.getLiveInstrument().removeLiveInstrument(liveBreakpoint.getId()).onComplete(it -> { if (it.succeeded()) { LiveStatusManager.INSTANCE.removeActiveLiveInstrument(liveBreakpoint); } else { diff --git a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LiveBreakpointStatusPanel.java b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LiveBreakpointStatusPanel.java index ab53b3640..b89311e38 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LiveBreakpointStatusPanel.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LiveBreakpointStatusPanel.java @@ -2,12 +2,7 @@ import com.codahale.metrics.Meter; import com.jgoodies.forms.factories.FormFactory; -import com.jgoodies.forms.layout.CellConstraints; -import com.jgoodies.forms.layout.ColumnSpec; -import com.jgoodies.forms.layout.FormLayout; -import com.jgoodies.forms.layout.FormSpec; -import com.jgoodies.forms.layout.RowSpec; -import com.jgoodies.forms.layout.Sizes; +import com.jgoodies.forms.layout.*; import spp.jetbrains.sourcemarker.PluginUI; import spp.protocol.utils.TimeUtilsKt; @@ -17,10 +12,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import static spp.jetbrains.sourcemarker.PluginUI.EXPIRY_FOREGROUND_COLOR; -import static spp.jetbrains.sourcemarker.PluginUI.LABEL_FOREGROUND_COLOR1; -import static spp.jetbrains.sourcemarker.PluginUI.ROBOTO_LIGHT_PLAIN_15; -import static spp.jetbrains.sourcemarker.PluginUI.SELECT_COLOR_RED; +import static spp.jetbrains.sourcemarker.PluginUI.*; public class LiveBreakpointStatusPanel extends JPanel { 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 368dae66c..42566efc7 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LiveMeterStatusPanel.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LiveMeterStatusPanel.java @@ -3,15 +3,14 @@ import com.intellij.util.ui.UIUtil; import com.jgoodies.forms.factories.FormFactory; import com.jgoodies.forms.layout.*; +import io.vertx.core.json.JsonObject; +import org.jetbrains.annotations.NotNull; import spp.jetbrains.marker.source.mark.gutter.GutterMark; import spp.jetbrains.sourcemarker.PluginIcons; import spp.jetbrains.sourcemarker.PluginUI; import spp.jetbrains.sourcemarker.service.InstrumentEventListener; -import io.vertx.core.json.JsonObject; -import org.jetbrains.annotations.NotNull; -import spp.protocol.SourceMarkerServices; -import spp.protocol.instrument.LiveInstrumentEvent; -import spp.protocol.instrument.meter.LiveMeter; +import spp.protocol.instrument.LiveMeter; +import spp.protocol.instrument.event.LiveInstrumentEvent; import spp.protocol.instrument.meter.MeterType; import javax.swing.*; @@ -23,6 +22,7 @@ import static spp.jetbrains.sourcemarker.PluginUI.LABEL_FOREGROUND_COLOR; import static spp.jetbrains.sourcemarker.PluginUI.ROBOTO_LIGHT_PLAIN_15; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; +import static spp.protocol.SourceServices.Instance.INSTANCE; public class LiveMeterStatusPanel extends JPanel implements InstrumentEventListener { @@ -96,7 +96,7 @@ public void mouseMoved(MouseEvent e) { addRecursiveMouseListener(closeLabel, new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - SourceMarkerServices.Instance.INSTANCE.getLiveInstrument().removeLiveInstrument(liveMeter.getId(), it -> { + INSTANCE.getLiveInstrument().removeLiveInstrument(liveMeter.getId()).onComplete(it -> { if (it.succeeded()) { gutterMark.dispose(); LiveStatusManager.INSTANCE.removeActiveLiveInstrument(liveMeter); 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 9773078d1..d25d861d2 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LogStatusBar.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/LogStatusBar.java @@ -12,29 +12,27 @@ import com.intellij.util.ui.ColumnInfo; import com.intellij.util.ui.ListTableModel; import com.intellij.util.ui.UIUtil; -import io.vertx.core.json.Json; +import io.vertx.core.json.JsonObject; import net.miginfocom.swing.MigLayout; import org.jetbrains.annotations.NotNull; import spp.jetbrains.marker.source.mark.inlay.InlayMark; import spp.jetbrains.sourcemarker.PluginIcons; import spp.jetbrains.sourcemarker.PluginUI; -import spp.jetbrains.sourcemarker.service.log.VariableParser; import spp.jetbrains.sourcemarker.command.AutocompleteFieldRow; import spp.jetbrains.sourcemarker.mark.SourceMarkKeys; import spp.jetbrains.sourcemarker.service.InstrumentEventListener; import spp.jetbrains.sourcemarker.service.log.LogHitColumnInfo; +import spp.jetbrains.sourcemarker.service.log.VariableParser; import spp.jetbrains.sourcemarker.settings.LiveLogConfigurationPanel; import spp.jetbrains.sourcemarker.status.util.AutocompleteField; -import spp.protocol.SourceMarkerServices; import spp.protocol.artifact.log.Log; -import spp.protocol.instrument.InstrumentThrottle; import spp.protocol.instrument.LiveInstrument; -import spp.protocol.instrument.LiveInstrumentEvent; +import spp.protocol.instrument.LiveLog; import spp.protocol.instrument.LiveSourceLocation; -import spp.protocol.instrument.ThrottleStep; -import spp.protocol.instrument.log.LiveLog; -import spp.protocol.instrument.log.event.LiveLogRemoved; -import spp.protocol.service.live.LiveInstrumentService; +import spp.protocol.instrument.event.LiveInstrumentEvent; +import spp.protocol.instrument.event.LiveInstrumentRemoved; +import spp.protocol.instrument.throttle.InstrumentThrottle; +import spp.protocol.instrument.throttle.ThrottleStep; import javax.swing.*; import javax.swing.border.CompoundBorder; @@ -43,22 +41,13 @@ import javax.swing.event.DocumentEvent; import javax.swing.text.StyleContext; import java.awt.*; -import java.awt.event.ComponentEvent; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; +import java.awt.event.*; import java.time.Instant; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Function; @@ -67,18 +56,12 @@ import java.util.stream.Collectors; import static spp.jetbrains.marker.SourceMarker.conditionParser; -import static spp.jetbrains.sourcemarker.PluginUI.BGND_FOCUS_COLOR; -import static spp.jetbrains.sourcemarker.PluginUI.CNFG_PANEL_BGND_COLOR; -import static spp.jetbrains.sourcemarker.PluginUI.CNFG_PANEL_FOCUS_COLOR; -import static spp.jetbrains.sourcemarker.PluginUI.COMPLETE_COLOR_PURPLE; -import static spp.jetbrains.sourcemarker.PluginUI.ROBOTO_LIGHT_PLAIN_14; -import static spp.jetbrains.sourcemarker.PluginUI.ROBOTO_LIGHT_PLAIN_17; -import static spp.jetbrains.sourcemarker.PluginUI.SELECT_COLOR_RED; -import static spp.jetbrains.sourcemarker.PluginUI.STATUS_BAR_TXT_BG_COLOR; -import static spp.jetbrains.sourcemarker.PluginUI.DFLT_BGND_COLOR; +import static spp.jetbrains.sourcemarker.PluginUI.*; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; -import static spp.protocol.instrument.LiveInstrumentEventType.LOG_HIT; -import static spp.protocol.instrument.LiveInstrumentEventType.LOG_REMOVED; +import static spp.protocol.ProtocolMarshaller.deserializeLiveInstrumentRemoved; +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; public class LogStatusBar extends JPanel implements StatusBar, VisibleAreaListener, InstrumentEventListener { @@ -195,7 +178,7 @@ public void setLatestLog(Instant time, Log latestLog) { this.latestLog = latestLog; String formattedTime = time.atZone(ZoneId.systemDefault()).format(TIME_FORMATTER); - String formattedMessage = latestLog.getFormattedMessage(); + String formattedMessage = latestLog.toFormattedMessage(); if (!timeLabel.getText().equals(formattedTime) || !liveLogTextField.getText().equals(formattedMessage)) { SwingUtilities.invokeLater(() -> { if (liveLogTextField.getEditMode()) { @@ -246,7 +229,7 @@ public void accept(@NotNull LiveInstrumentEvent event) { } else if (event.getEventType() == LOG_REMOVED) { removed = true; - LiveLogRemoved removed = Json.decodeValue(event.getData(), LiveLogRemoved.class); + LiveInstrumentRemoved removed = deserializeLiveInstrumentRemoved(new JsonObject(event.getData())); if (removed.getCause() != null) { commandModel.insertRow(0, event); @@ -562,7 +545,7 @@ private void saveLiveLog() { latestTime = null; latestLog = null; - SourceMarkerServices.Instance.INSTANCE.getLiveInstrument().removeLiveInstrument(oldLiveLog.getId(), it -> { + INSTANCE.getLiveInstrument().removeLiveInstrument(oldLiveLog.getId()).onComplete(it -> { if (it.succeeded()) { LiveStatusManager.INSTANCE.removeActiveLiveInstrument(oldLiveLog); } else { @@ -598,7 +581,6 @@ private void saveLiveLog() { HashMap meta = new HashMap<>(); meta.put("original_source_mark", inlayMark.getId()); - LiveInstrumentService instrumentService = Objects.requireNonNull(SourceMarkerServices.Instance.INSTANCE.getLiveInstrument()); LiveLog instrument = new LiveLog( finalLogPattern, resp.second.stream().map(it -> it.substring(1)).collect(Collectors.toList()), @@ -621,7 +603,7 @@ private void saveLiveLog() { displayTimeField(); wrapper.grabFocus(); - instrumentService.addLiveInstrument(instrument, it -> { + INSTANCE.getLiveInstrument().addLiveInstrument(instrument).onComplete(it -> { if (it.succeeded()) { liveLog = (LiveLog) it.result(); inlayMark.putUserData(SourceMarkKeys.INSTANCE.getLOG_ID(), it.result().getId()); @@ -646,7 +628,7 @@ private void dispose() { inlayMark.dispose(true); if (liveLog != null) { - SourceMarkerServices.Instance.INSTANCE.getLiveInstrument().removeLiveInstrument(liveLog.getId(), it -> { + INSTANCE.getLiveInstrument().removeLiveInstrument(liveLog.getId()).onComplete(it -> { if (it.succeeded()) { LiveStatusManager.INSTANCE.removeActiveLiveInstrument(liveLog); } else { 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 ba2d19216..5d9446197 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/MeterStatusBar.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/MeterStatusBar.java @@ -11,7 +11,7 @@ import com.intellij.util.ui.ColumnInfo; import com.intellij.util.ui.ListTableModel; import com.intellij.util.ui.UIUtil; -import io.vertx.core.json.Json; +import io.vertx.core.json.JsonObject; import net.miginfocom.swing.MigLayout; import spp.jetbrains.marker.source.mark.api.SourceMark; import spp.jetbrains.marker.source.mark.inlay.InlayMark; @@ -21,15 +21,13 @@ import spp.jetbrains.sourcemarker.service.breakpoint.BreakpointHitColumnInfo; import spp.jetbrains.sourcemarker.settings.LiveMeterConfigurationPanel; import spp.jetbrains.sourcemarker.status.util.AutocompleteField; -import spp.protocol.SourceMarkerServices; import spp.protocol.instrument.LiveInstrument; +import spp.protocol.instrument.LiveMeter; import spp.protocol.instrument.LiveSourceLocation; -import spp.protocol.instrument.meter.LiveMeter; +import spp.protocol.instrument.event.LiveInstrumentRemoved; import spp.protocol.instrument.meter.MeterType; import spp.protocol.instrument.meter.MetricValue; import spp.protocol.instrument.meter.MetricValueType; -import spp.protocol.instrument.meter.event.LiveMeterRemoved; -import spp.protocol.service.live.LiveInstrumentService; import javax.swing.*; import javax.swing.border.CompoundBorder; @@ -39,14 +37,18 @@ import java.awt.*; import java.awt.event.*; import java.time.Instant; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; import java.util.List; -import java.util.*; import java.util.concurrent.atomic.AtomicLong; import static spp.jetbrains.marker.SourceMarker.conditionParser; import static spp.jetbrains.sourcemarker.PluginUI.*; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; -import static spp.protocol.instrument.LiveInstrumentEventType.METER_REMOVED; +import static spp.protocol.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 { @@ -127,7 +129,7 @@ private void setupAsActive() { if (event.getEventType() == METER_REMOVED) { configLabel.setIcon(PluginIcons.eyeSlash); - LiveMeterRemoved removed = Json.decodeValue(event.getData(), LiveMeterRemoved.class); + LiveInstrumentRemoved removed = deserializeLiveInstrumentRemoved(new JsonObject(event.getData())); if (removed.getCause() == null) { statusPanel.setStatus("Complete", COMPLETE_COLOR_PURPLE); } else { @@ -357,7 +359,6 @@ private void saveLiveMeter() { HashMap meta = new HashMap<>(); meta.put("original_source_mark", inlayMark.getId()); - LiveInstrumentService instrumentService = Objects.requireNonNull(SourceMarkerServices.Instance.INSTANCE.getLiveInstrument()); LiveMeter instrument = new LiveMeter( meterNameField.getText(), MeterType.valueOf(meterTypeComboBox.getSelectedItem().toString().toUpperCase()), @@ -373,7 +374,7 @@ private void saveLiveMeter() { null, meta ); - instrumentService.addLiveInstrument(instrument, it -> { + INSTANCE.getLiveInstrument().addLiveInstrument(instrument).onComplete(it -> { if (it.succeeded()) { liveMeter = (LiveMeter) it.result(); LiveStatusManager.INSTANCE.addActiveLiveInstrument(liveMeter); @@ -404,7 +405,7 @@ private void dispose() { if (groupedMarks != null) groupedMarks.forEach(SourceMark::dispose); if (liveMeter != null) { - SourceMarkerServices.Instance.INSTANCE.getLiveInstrument().removeLiveInstrument(liveMeter.getId(), it -> { + INSTANCE.getLiveInstrument().removeLiveInstrument(liveMeter.getId()).onComplete(it -> { if (it.succeeded()) { LiveStatusManager.INSTANCE.removeActiveLiveInstrument(liveMeter); } else { 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 cc33d8549..f4780a969 100644 --- a/plugin/src/main/java/spp/jetbrains/sourcemarker/status/SpanStatusBar.java +++ b/plugin/src/main/java/spp/jetbrains/sourcemarker/status/SpanStatusBar.java @@ -11,7 +11,7 @@ import com.intellij.util.ui.ColumnInfo; import com.intellij.util.ui.ListTableModel; import com.intellij.util.ui.UIUtil; -import io.vertx.core.json.Json; +import io.vertx.core.json.JsonObject; import net.miginfocom.swing.MigLayout; import spp.jetbrains.marker.source.mark.api.SourceMark; import spp.jetbrains.marker.source.mark.inlay.InlayMark; @@ -21,12 +21,10 @@ import spp.jetbrains.sourcemarker.service.breakpoint.BreakpointHitColumnInfo; import spp.jetbrains.sourcemarker.settings.LiveMeterConfigurationPanel; import spp.jetbrains.sourcemarker.status.util.AutocompleteField; -import spp.protocol.SourceMarkerServices; import spp.protocol.instrument.LiveInstrument; import spp.protocol.instrument.LiveSourceLocation; -import spp.protocol.instrument.meter.event.LiveMeterRemoved; -import spp.protocol.instrument.span.LiveSpan; -import spp.protocol.service.live.LiveInstrumentService; +import spp.protocol.instrument.LiveSpan; +import spp.protocol.instrument.event.LiveInstrumentRemoved; import javax.swing.*; import javax.swing.border.CompoundBorder; @@ -36,14 +34,18 @@ import java.awt.*; import java.awt.event.*; import java.time.Instant; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; import java.util.List; -import java.util.*; import java.util.concurrent.atomic.AtomicLong; import static spp.jetbrains.marker.SourceMarker.conditionParser; import static spp.jetbrains.sourcemarker.PluginUI.*; import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener; -import static spp.protocol.instrument.LiveInstrumentEventType.METER_REMOVED; +import static spp.protocol.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 { @@ -124,7 +126,7 @@ private void setupAsActive() { if (event.getEventType() == METER_REMOVED) { configLabel.setIcon(PluginIcons.eyeSlash); - LiveMeterRemoved removed = Json.decodeValue(event.getData(), LiveMeterRemoved.class); + LiveInstrumentRemoved removed = deserializeLiveInstrumentRemoved(new JsonObject(event.getData())); if (removed.getCause() == null) { statusPanel.setStatus("Complete", COMPLETE_COLOR_PURPLE); } else { @@ -344,7 +346,6 @@ private void saveLiveSpan() { HashMap meta = new HashMap<>(); meta.put("original_source_mark", inlayMark.getId()); - LiveInstrumentService instrumentService = Objects.requireNonNull(SourceMarkerServices.Instance.INSTANCE.getLiveInstrument()); LiveSpan instrument = new LiveSpan( spanOperationNameField.getText(), sourceLocation, @@ -358,7 +359,7 @@ private void saveLiveSpan() { null, meta ); - instrumentService.addLiveInstrument(instrument, it -> { + INSTANCE.getLiveInstrument().addLiveInstrument(instrument).onComplete(it -> { if (it.succeeded()) { liveSpan = (LiveSpan) it.result(); LiveStatusManager.INSTANCE.addActiveLiveInstrument(liveSpan); @@ -385,7 +386,7 @@ private void dispose() { if (groupedMarks != null) groupedMarks.forEach(SourceMark::dispose); if (liveSpan != null) { - SourceMarkerServices.Instance.INSTANCE.getLiveInstrument().removeLiveInstrument(liveSpan.getId(), it -> { + INSTANCE.getLiveInstrument().removeLiveInstrument(liveSpan.getId()).onComplete(it -> { if (it.succeeded()) { LiveStatusManager.INSTANCE.removeActiveLiveInstrument(liveSpan); } else { diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/SourceMarkerPlugin.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/SourceMarkerPlugin.kt index 7f32694d1..3aeced3ea 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/SourceMarkerPlugin.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/SourceMarkerPlugin.kt @@ -17,6 +17,7 @@ */ package spp.jetbrains.sourcemarker +import com.apollographql.apollo3.exception.ApolloHttpException import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializationFeature @@ -95,8 +96,8 @@ 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.protocol.SourceMarkerServices -import spp.protocol.SourceMarkerServices.Instance +import spp.protocol.SourceServices +import spp.protocol.SourceServices.Instance import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.endpoint.EndpointResult import spp.protocol.artifact.exception.LiveStackTraceElement @@ -106,11 +107,10 @@ import spp.protocol.artifact.trace.TraceResult import spp.protocol.artifact.trace.TraceSpan import spp.protocol.artifact.trace.TraceSpanStackQueryResult import spp.protocol.artifact.trace.TraceStack +import spp.protocol.service.LiveInstrumentService import spp.protocol.service.LiveService -import spp.protocol.service.live.LiveInstrumentService -import spp.protocol.service.live.LiveViewService -import spp.protocol.service.logging.LogCountIndicatorService -import spp.protocol.service.tracing.LocalTracingService +import spp.protocol.service.LiveViewService +import spp.protocol.service.LogCountIndicatorService import spp.protocol.util.KSerializers import spp.protocol.util.LocalMessageCodec import java.awt.Color @@ -258,6 +258,29 @@ object SourceMarkerPlugin { initMonitor(config) connectedMonitor = true } catch (ignored: CancellationException) { + } catch (throwable: ApolloHttpException) { + val pluginName = message("plugin_name") + if (throwable.statusCode == 401) { + Notifications.Bus.notify( + Notification( + pluginName, "Connection unauthorized", + "Failed to authenticate with $pluginName. " + + "Please ensure the correct configuration " + + "is set at: Settings -> Tools -> $pluginName", + NotificationType.ERROR + ) + ) + } else { + Notifications.Bus.notify( + Notification( + pluginName, "Connection failed", + "Failed to connect to $pluginName. " + + "Please ensure the correct configuration " + + "is set at: Settings -> Tools -> $pluginName", + NotificationType.ERROR + ) + ) + } } catch (throwable: Throwable) { //todo: if first time bring up config panel automatically instead of notification val pluginName = message("plugin_name") @@ -285,8 +308,8 @@ object SourceMarkerPlugin { log.error("Connection failed. Reason: {}", throwable.message) } - discoverAvailableServices(config, project) if (connectedMonitor) { + discoverAvailableServices(config, project) initPortal(config) initMarker(config, project) initMapper() @@ -305,26 +328,33 @@ object SourceMarkerPlugin { throw RuntimeException(e) } - val discovery: ServiceDiscovery = DiscoveryImpl( - vertx, - ServiceDiscoveryOptions().setBackendConfiguration( - JsonObject() - .put("backend-name", "tcp-service-discovery") - .put("hardcoded_config", hardcodedConfig) - .put("sourcemarker_plugin_config", JsonObject.mapFrom(config)) + val discovery: ServiceDiscovery + val originalClassLoader = Thread.currentThread().contextClassLoader + try { + Thread.currentThread().contextClassLoader = javaClass.classLoader + discovery = DiscoveryImpl( + vertx, + ServiceDiscoveryOptions().setBackendConfiguration( + JsonObject() + .put("backend-name", "tcp-service-discovery") + .put("hardcoded_config", hardcodedConfig) + .put("sourcemarker_plugin_config", JsonObject.mapFrom(config)) + ) ) - ) + } finally { + Thread.currentThread().contextClassLoader = originalClassLoader + } log.info("Discovering available services") val availableRecords = discovery.getRecords { true }.await() //live service - if (availableRecords.any { it.name == SourceMarkerServices.Utilize.LIVE_SERVICE }) { + if (availableRecords.any { it.name == SourceServices.Utilize.LIVE_SERVICE }) { log.info("Live service available") Instance.liveService = ServiceProxyBuilder(vertx) .apply { config.serviceToken?.let { setToken(it) } } - .setAddress(SourceMarkerServices.Utilize.LIVE_SERVICE) + .setAddress(SourceServices.Utilize.LIVE_SERVICE) .build(LiveService::class.java) } else { log.warn("Live service unavailable") @@ -332,18 +362,18 @@ object SourceMarkerPlugin { //live instrument if (hardcodedConfig.getJsonObject("services").getBoolean("live_instrument")) { - if (availableRecords.any { it.name == SourceMarkerServices.Utilize.LIVE_INSTRUMENT }) { + if (availableRecords.any { it.name == SourceServices.Utilize.LIVE_INSTRUMENT }) { log.info("Live instruments available") SourceMarker.addGlobalSourceMarkEventListener(LiveStatusManager) Instance.liveInstrument = ServiceProxyBuilder(vertx) .apply { config.serviceToken?.let { setToken(it) } } - .setAddress(SourceMarkerServices.Utilize.LIVE_INSTRUMENT) + .setAddress(SourceServices.Utilize.LIVE_INSTRUMENT) .build(LiveInstrumentService::class.java) ApplicationManager.getApplication().invokeLater { BreakpointHitWindowService.getInstance(project).showEventsWindow() } - val breakpointListener = LiveInstrumentManager(project) + val breakpointListener = LiveInstrumentManager(project, config) GlobalScope.launch(vertx.dispatcher()) { deploymentIds.add(vertx.deployVerticle(breakpointListener).await()) } @@ -356,11 +386,11 @@ object SourceMarkerPlugin { //live view if (hardcodedConfig.getJsonObject("services").getBoolean("live_view")) { - if (availableRecords.any { it.name == SourceMarkerServices.Utilize.LIVE_VIEW }) { + if (availableRecords.any { it.name == SourceServices.Utilize.LIVE_VIEW }) { log.info("Live views available") Instance.liveView = ServiceProxyBuilder(vertx) .apply { config.serviceToken?.let { setToken(it) } } - .setAddress(SourceMarkerServices.Utilize.LIVE_VIEW) + .setAddress(SourceServices.Utilize.LIVE_VIEW) .build(LiveViewService::class.java) val viewListener = LiveViewManager(config) @@ -374,28 +404,13 @@ object SourceMarkerPlugin { log.info("Live views disabled") } - //local tracing - if (hardcodedConfig.getJsonObject("services").getBoolean("local_tracing")) { - if (availableRecords.any { it.name == SourceMarkerServices.Utilize.LOCAL_TRACING }) { - log.info("Local tracing available") - Instance.localTracing = ServiceProxyBuilder(vertx) - .apply { config.serviceToken?.let { setToken(it) } } - .setAddress(SourceMarkerServices.Utilize.LOCAL_TRACING) - .build(LocalTracingService::class.java) - } else { - log.warn("Local tracing unavailable") - } - } else { - log.info("Local tracing disabled") - } - //log count indicator if (hardcodedConfig.getJsonObject("services").getBoolean("log_count_indicator")) { - if (availableRecords.any { it.name == SourceMarkerServices.Utilize.LOG_COUNT_INDICATOR }) { + if (availableRecords.any { it.name == SourceServices.Utilize.LOG_COUNT_INDICATOR }) { log.info("Log count indicator available") Instance.logCountIndicator = ServiceProxyBuilder(vertx) .apply { config.serviceToken?.let { setToken(it) } } - .setAddress(SourceMarkerServices.Utilize.LOG_COUNT_INDICATOR) + .setAddress(SourceServices.Utilize.LOG_COUNT_INDICATOR) .build(LogCountIndicatorService::class.java) GlobalScope.launch(vertx.dispatcher()) { @@ -481,15 +496,6 @@ object SourceMarkerPlugin { } } else { config.serviceToken = null - - log.error("Invalid access token") - Notifications.Bus.notify( - Notification( - message("plugin_name"), "Invalid access token", - "Failed to validate access token", - NotificationType.ERROR - ) - ) } } else { //try default local access 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 bdf325791..2cc4ae22c 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/activities/PluginSourceMarkerStartupActivity.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/activities/PluginSourceMarkerStartupActivity.kt @@ -23,13 +23,13 @@ import com.intellij.notification.Notifications import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.Project -import spp.jetbrains.marker.plugin.SourceMarkerStartupActivity -import spp.jetbrains.sourcemarker.PluginBundle -import spp.jetbrains.sourcemarker.SourceMarkerPlugin import kotlinx.coroutines.runBlocking import org.apache.log4j.FileAppender import org.apache.log4j.Logger import org.apache.log4j.PatternLayout +import spp.jetbrains.marker.plugin.SourceMarkerStartupActivity +import spp.jetbrains.sourcemarker.PluginBundle +import spp.jetbrains.sourcemarker.SourceMarkerPlugin /** * todo: description. 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 7dc1ebdea..6ca38a637 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/ControlBarController.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/ControlBarController.kt @@ -21,7 +21,6 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiDocumentManager -import io.vertx.core.Promise import io.vertx.kotlin.coroutines.await import kotlinx.coroutines.runBlocking import org.slf4j.LoggerFactory @@ -40,8 +39,8 @@ import spp.jetbrains.sourcemarker.command.LiveControlCommand.* import spp.jetbrains.sourcemarker.mark.SourceMarkKeys import spp.jetbrains.sourcemarker.status.LiveStatusManager import spp.protocol.ProtocolAddress.Global.SetCurrentPage -import spp.protocol.SourceMarkerServices -import spp.protocol.developer.SelfInfo +import spp.protocol.SourceServices +import spp.protocol.instrument.LiveInstrumentType.* import spp.protocol.portal.PageType import java.awt.BorderLayout import javax.swing.JComponent @@ -59,9 +58,7 @@ object ControlBarController { private var previousControlBar: InlayMark? = null private val availableCommands by lazy { runBlocking { - val future = Promise.promise() - SourceMarkerServices.Instance.liveService!!.getSelf(future) - val selfInfo = future.future().await() + val selfInfo = SourceServices.Instance.liveService!!.getSelf().await() LiveControlCommand.values().toList().filter { @Suppress("UselessCallOnCollection") //unknown enums are null selfInfo.permissions.filterNotNull().map { it.name }.contains(it.name) @@ -119,7 +116,7 @@ object ControlBarController { previousControlBar!!.dispose() previousControlBar = null - SourceMarkerServices.Instance.liveInstrument!!.clearLiveBreakpoints { + SourceServices.Instance.liveInstrument!!.clearLiveInstruments(BREAKPOINT).onComplete { if (it.failed()) { log.error("Failed to clear live breakpoints", it.cause()) } @@ -129,17 +126,37 @@ object ControlBarController { previousControlBar!!.dispose() previousControlBar = null - SourceMarkerServices.Instance.liveInstrument!!.clearLiveLogs { + SourceServices.Instance.liveInstrument!!.clearLiveInstruments(LOG).onComplete { if (it.failed()) { log.error("Failed to clear live logs", it.cause()) } } } + CLEAR_LIVE_METERS.command -> { + previousControlBar!!.dispose() + previousControlBar = null + + SourceServices.Instance.liveInstrument!!.clearLiveInstruments(METER).onComplete { + if (it.failed()) { + log.error("Failed to clear live meters", it.cause()) + } + } + } + CLEAR_LIVE_SPANS.command -> { + previousControlBar!!.dispose() + previousControlBar = null + + SourceServices.Instance.liveInstrument!!.clearLiveInstruments(SPAN).onComplete { + if (it.failed()) { + log.error("Failed to clear live spans", it.cause()) + } + } + } CLEAR_LIVE_INSTRUMENTS.command -> { previousControlBar!!.dispose() previousControlBar = null - SourceMarkerServices.Instance.liveInstrument!!.clearLiveInstruments { + SourceServices.Instance.liveInstrument!!.clearLiveInstruments(null).onComplete { if (it.failed()) { log.error("Failed to clear live instruments", it.cause()) } diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/LiveControlCommand.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/LiveControlCommand.kt index 70682babf..e24fc939b 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/LiveControlCommand.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/LiveControlCommand.kt @@ -107,6 +107,12 @@ enum class LiveControlCommand( "Clear all self-created live meters", PluginIcons.Command.clearInstrumentSelected, PluginIcons.Command.clearInstrumentUnSelected + ), + CLEAR_LIVE_SPANS( + "Clear Spans", + "Clear all self-created live spans", + PluginIcons.Command.clearInstrumentSelected, + PluginIcons.Command.clearInstrumentUnSelected ); override fun getText(): String { diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerToolWindowFactory.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerToolWindowFactory.kt index 767bc480b..2c7fbb05d 100755 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerToolWindowFactory.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/console/SourceMarkerToolWindowFactory.kt @@ -23,10 +23,10 @@ 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 spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import io.vertx.core.json.DecodeException import io.vertx.core.json.Json import org.slf4j.LoggerFactory +import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig /** * Displays logs from the SourceMarker plugin to a console window. diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/discover/TCPServiceDiscoveryBackend.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/discover/TCPServiceDiscoveryBackend.kt index 77accb813..d70db245c 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/discover/TCPServiceDiscoveryBackend.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/discover/TCPServiceDiscoveryBackend.kt @@ -20,6 +20,7 @@ package spp.jetbrains.sourcemarker.discover import eu.geekplace.javapinning.JavaPinning import eu.geekplace.javapinning.pin.Pin import io.vertx.core.* +import io.vertx.core.eventbus.DeliveryOptions import io.vertx.core.eventbus.MessageConsumer import io.vertx.core.json.Json import io.vertx.core.json.JsonArray @@ -42,11 +43,10 @@ import spp.jetbrains.sourcemarker.SourceMarkerPlugin import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import spp.jetbrains.sourcemarker.settings.isSsl import spp.jetbrains.sourcemarker.settings.serviceHostNormalized -import spp.protocol.SourceMarkerServices -import spp.protocol.SourceMarkerServices.Utilize +import spp.protocol.SourceServices.Utilize import spp.protocol.extend.TCPServiceFrameParser import spp.protocol.platform.PlatformAddress -import spp.protocol.status.MarkerConnection +import spp.protocol.platform.status.InstanceConnection import java.util.* /** @@ -65,18 +65,18 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend { private lateinit var vertx: Vertx private lateinit var client: NetClient + private lateinit var pluginConfig: SourceMarkerConfig private val setupPromise = Promise.promise() private val setupFuture = setupPromise.future() override fun init(vertx: Vertx, config: JsonObject) { this.vertx = vertx - - val hardcodedConfig = config.getJsonObject("hardcoded_config") - val pluginConfig = Json.decodeValue( + pluginConfig = Json.decodeValue( config.getJsonObject("sourcemarker_plugin_config").toString(), SourceMarkerConfig::class.java ) val serviceHost = pluginConfig.serviceHostNormalized!! + val hardcodedConfig = config.getJsonObject("hardcoded_config") val servicePort = hardcodedConfig.getInteger("tcp_service_port") val certificatePins = mutableListOf() certificatePins.addAll(pluginConfig.certificatePins) @@ -123,13 +123,12 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend { setupHandler(vertx, Utilize.LIVE_SERVICE) setupHandler(vertx, Utilize.LIVE_INSTRUMENT) setupHandler(vertx, Utilize.LIVE_VIEW) - setupHandler(vertx, Utilize.LOCAL_TRACING) setupHandler(vertx, Utilize.LOG_COUNT_INDICATOR) //setup connection val replyAddress = UUID.randomUUID().toString() - val pc = MarkerConnection(SourceMarkerPlugin.INSTANCE_ID, System.currentTimeMillis()) - val consumer: MessageConsumer = vertx.eventBus().localConsumer("local.$replyAddress") + val pc = InstanceConnection(SourceMarkerPlugin.INSTANCE_ID, System.currentTimeMillis()) + val consumer: MessageConsumer = vertx.eventBus().localConsumer(replyAddress) val promise = Promise.promise() consumer.handler { @@ -140,11 +139,10 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend { setupPromise.complete() } } - val headers = JsonObject() - pluginConfig.serviceToken?.let { headers.put("token", it) } + val headers = JsonObject().apply { pluginConfig.serviceToken?.let { put("auth-token", it) } } FrameHelper.sendFrame( BridgeEventType.SEND.name.toLowerCase(), - PlatformAddress.MARKER_CONNECTED.address, + PlatformAddress.MARKER_CONNECTED, replyAddress, headers, true, JsonObject.mapFrom(pc), socket!! ) } @@ -154,7 +152,7 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend { private fun setupHandler(vertx: Vertx, address: String) { vertx.eventBus().localConsumer(address) { resp -> val replyAddress = UUID.randomUUID().toString() - val tempConsumer = vertx.eventBus().localConsumer("local.$replyAddress") + val tempConsumer = vertx.eventBus().localConsumer(replyAddress) tempConsumer.handler { resp.reply(it.body()) tempConsumer.unregister() @@ -188,7 +186,9 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend { override fun getRecords(resultHandler: Handler>>) { if (setupFuture.isComplete) { if (setupFuture.succeeded()) { - vertx.eventBus().request("get-records", null) { + val deliveryOptions = DeliveryOptions() + .apply { pluginConfig.serviceToken?.let { addHeader("auth-token", it) } } + vertx.eventBus().request("get-records", null, deliveryOptions) { resultHandler.handle(Future.succeededFuture(mutableListOf(Record(it.result().body())))) } } else { @@ -197,7 +197,9 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend { } else { setupFuture.onComplete { if (it.succeeded()) { - vertx.eventBus().request("get-records", null) { + val deliveryOptions = DeliveryOptions() + .apply { pluginConfig.serviceToken?.let { addHeader("auth-token", it) } } + vertx.eventBus().request("get-records", null, deliveryOptions) { val records = mutableListOf() it.result().body().forEach { record -> records.add(Record(record as JsonObject)) diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/icons/SourceMarkerIcons.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/icons/SourceMarkerIcons.kt index 8c7987465..19ec2c364 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/icons/SourceMarkerIcons.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/icons/SourceMarkerIcons.kt @@ -21,9 +21,6 @@ import com.intellij.ui.scale.ScaleContext import com.intellij.util.SVGLoader import com.intellij.util.ui.JBImageIcon import spp.jetbrains.sourcemarker.PluginIcons -import spp.protocol.advice.ArtifactAdvice -import spp.protocol.advice.cautionary.RampDetectionAdvice -import spp.protocol.advice.informative.ActiveExceptionAdvice import java.io.ByteArrayInputStream import javax.swing.Icon @@ -47,14 +44,6 @@ object SourceMarkerIcons { val LIVE_BREAKPOINT_PENDING_ICON = PluginIcons.Breakpoint.pending val LIVE_BREAKPOINT_ERROR_ICON = PluginIcons.Breakpoint.error - fun getGutterMarkIcon(advice: ArtifactAdvice): Icon? { - return when (advice) { - is ActiveExceptionAdvice -> exclamationTriangle - is RampDetectionAdvice -> performanceRamp - else -> null - } - } - fun getNumericGutterMarkIcon(value: Int, color: String = "#182d34"): Icon { return JBImageIcon( SVGLoader.loadHiDPI( diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/ArtifactAdviceListener.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/ArtifactAdviceListener.kt deleted file mode 100644 index 99eda0ff4..000000000 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/ArtifactAdviceListener.kt +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.jetbrains.sourcemarker.listeners - -import com.intellij.openapi.application.ApplicationManager -import spp.jetbrains.marker.SourceMarker -import spp.jetbrains.marker.source.mark.api.MethodSourceMark -import spp.jetbrains.marker.source.mark.api.SourceMark -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.protocol.advice.AdviceListener -import spp.protocol.advice.ArtifactAdvice -import spp.protocol.artifact.ArtifactType -import spp.jetbrains.sourcemarker.SourceMarkerPlugin -import spp.jetbrains.sourcemarker.mark.SourceMarkConstructor -import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.ARTIFACT_ADVICE -import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.ENDPOINT_DETECTOR -import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.SOURCE_PORTAL -import io.vertx.kotlin.coroutines.dispatcher -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import org.slf4j.LoggerFactory - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class ArtifactAdviceListener : AdviceListener, SourceMarkEventListener { - - companion object { - private val log = LoggerFactory.getLogger(ArtifactAdviceListener::class.java) - } - - private val pendingAdvice = mutableSetOf() - - override suspend fun advised(advice: ArtifactAdvice) { - when (advice.artifact.type) { - ArtifactType.ENDPOINT -> createEndpointAdvice(advice) - ArtifactType.STATEMENT -> ApplicationManager.getApplication() - .runReadAction { createExpressionAdvice(advice) } - else -> TODO("impl") - } - } - - override fun handleEvent(event: SourceMarkEvent) { - if (event.eventCode == SourceMarkEventCode.MARK_ADDED) { - GlobalScope.launch(SourceMarkerPlugin.vertx.dispatcher()) { - pendingAdvice.toList().forEach { - advised(it) - } - } - } - } - - private suspend fun createEndpointAdvice(advice: ArtifactAdvice) { - val operationName = advice.artifact.identifier - val sourceMark = SourceMarker.getSourceMarks() - .filterIsInstance() - .firstOrNull { it.getUserData(ENDPOINT_DETECTOR)!!.getOrFindEndpointName(it) == operationName } - if (sourceMark != null) { - SourceMarkConstructor.attachAdvice(sourceMark, advice) - addAdviceData(sourceMark, advice) - } else { - pendingAdvice.add(advice) - } - } - - private fun createExpressionAdvice(advice: ArtifactAdvice) { - val qualifiedClassName = advice.artifact.identifier - .substring(0, advice.artifact.identifier.lastIndexOf(".")) - val fileMarker = SourceMarker.getSourceFileMarker(qualifiedClassName) - if (fileMarker != null) { - val sourceMark = SourceMarkConstructor.getOrSetupSourceMark(fileMarker, advice) - if (sourceMark != null) { - addAdviceData(sourceMark, advice) - } - } else { - pendingAdvice.add(advice) - } - } - - private fun addAdviceData(sourceMark: SourceMark, advice: ArtifactAdvice) { - pendingAdvice.remove(advice) - if (sourceMark.getUserData(ARTIFACT_ADVICE) == null) { - sourceMark.putUserData(ARTIFACT_ADVICE, mutableListOf()) - } - - val activeAdvice = sourceMark.getUserData(ARTIFACT_ADVICE)!! - val updatedAdvice = activeAdvice.any { - if (it.isSameArtifactAdvice(advice)) { - it.updateArtifactAdvice(advice) - true - } else { - false - } - } - if (updatedAdvice) { - log.trace("Updated artifact advice: $advice") - } else { - activeAdvice.add(advice) - sourceMark.getUserData(SOURCE_PORTAL)?.advice?.add(advice) - log.debug("Added artifact advice: $advice") - } - } -} diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/PluginSourceMarkEventListener.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/PluginSourceMarkEventListener.kt index 9c51b6985..daf71cbb9 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/PluginSourceMarkEventListener.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/PluginSourceMarkEventListener.kt @@ -30,7 +30,6 @@ import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode import spp.jetbrains.marker.source.mark.api.event.SynchronousSourceMarkEventListener import spp.jetbrains.portal.SourcePortal import spp.jetbrains.sourcemarker.SourceMarkerPlugin.vertx -import spp.jetbrains.sourcemarker.mark.SourceMarkConstructor import spp.jetbrains.sourcemarker.mark.SourceMarkKeys import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.ENDPOINT_DETECTOR import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.LOGGER_DETECTOR @@ -105,7 +104,6 @@ class PluginSourceMarkEventListener : SynchronousSourceMarkEventListener { sourceMark.putUserData(LOGGER_DETECTOR, loggerDetector) } else if (event.eventCode == SourceMarkEventCode.MARK_REMOVED) { event.sourceMark.getUserData(SourceMarkKeys.SOURCE_PORTAL)!!.close() - SourceMarkConstructor.tearDownSourceMark(event.sourceMark) } } } diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/PortalEventListener.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/PortalEventListener.kt index dd59396a6..3c5fb59ca 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/PortalEventListener.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/listeners/PortalEventListener.kt @@ -25,7 +25,6 @@ import com.intellij.psi.PsiNameIdentifierOwner import com.intellij.util.PsiNavigateUtil import io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND import io.vertx.core.eventbus.ReplyException -import io.vertx.core.eventbus.ReplyFailure import io.vertx.core.json.Json import io.vertx.core.json.JsonObject import io.vertx.kotlin.coroutines.CoroutineVerticle @@ -33,7 +32,6 @@ import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.datetime.Instant -import kotlinx.datetime.toKotlinInstant import org.slf4j.LoggerFactory import spp.jetbrains.marker.SourceMarker import spp.jetbrains.marker.SourceMarker.creationService @@ -81,7 +79,8 @@ import spp.protocol.ProtocolAddress.Global.RefreshTraces import spp.protocol.ProtocolAddress.Global.SetCurrentPage import spp.protocol.ProtocolAddress.Global.TraceSpanUpdated import spp.protocol.ProtocolAddress.Portal.UpdateEndpoints -import spp.protocol.SourceMarkerServices.Instance +import spp.protocol.SourceServices.Instance +import spp.protocol.artifact.ArtifactNameUtils import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.ArtifactType import spp.protocol.artifact.endpoint.EndpointResult @@ -92,10 +91,8 @@ import spp.protocol.artifact.metrics.ArtifactSummarizedResult import spp.protocol.artifact.metrics.MetricType import spp.protocol.artifact.trace.TraceResult import spp.protocol.artifact.trace.TraceSpan -import spp.protocol.error.AccessDenied import spp.protocol.instrument.LiveSourceLocation import spp.protocol.portal.PageType -import spp.protocol.utils.ArtifactNameUtils import spp.protocol.view.LiveViewConfig import spp.protocol.view.LiveViewSubscription import java.net.URI @@ -268,7 +265,7 @@ class PortalEventListener( //update subscriptions if (Instance.liveView != null) { - Instance.liveView!!.clearLiveViewSubscriptions { + Instance.liveView!!.clearLiveViewSubscriptions().onComplete { if (it.succeeded()) { GlobalScope.launch(vertx.dispatcher()) { val sourceMark = SourceMarker.getSourceMark( @@ -284,14 +281,9 @@ class PortalEventListener( listOf(endpointName), portal.viewingArtifact, LiveSourceLocation(portal.viewingArtifact.identifier, 0), //todo: fix - LiveViewConfig( - "ACTIVITY", - false, - listOf("endpoint_cpm", "endpoint_avg", "endpoint_sla"), - 0 - ) + LiveViewConfig("ACTIVITY", listOf("endpoint_cpm", "endpoint_avg", "endpoint_sla")) ) - ) { + ).onComplete { if (it.failed()) { log.error("Failed to add live view subscription", it.cause()) } @@ -312,7 +304,7 @@ class PortalEventListener( //update subscriptions if (Instance.liveView != null) { - Instance.liveView!!.clearLiveViewSubscriptions { + Instance.liveView!!.clearLiveViewSubscriptions().onComplete { if (it.succeeded()) { GlobalScope.launch(vertx.dispatcher()) { val sourceMark = SourceMarker.getSourceMark( @@ -328,14 +320,9 @@ class PortalEventListener( listOf(endpointName), portal.viewingArtifact, LiveSourceLocation(portal.viewingArtifact.identifier, 0), //todo: fix - LiveViewConfig( - "TRACES", - false, - listOf("endpoint_traces"), - 0 - ) + LiveViewConfig("TRACES", listOf("endpoint_traces")) ) - ) { + ).onComplete { if (it.failed()) { log.error("Failed to add live view subscription", it.cause()) } @@ -356,7 +343,7 @@ class PortalEventListener( //update subscriptions if (Instance.liveView != null) { - Instance.liveView!!.clearLiveViewSubscriptions { + Instance.liveView!!.clearLiveViewSubscriptions().onComplete { if (it.succeeded()) { GlobalScope.launch(vertx.dispatcher()) { val sourceMark = SourceMarker.getSourceMark( @@ -382,14 +369,9 @@ class PortalEventListener( logPatterns, portal.viewingArtifact, LiveSourceLocation(portal.viewingArtifact.identifier, 0), //todo: fix - LiveViewConfig( - "LOGS", - false, - listOf("endpoint_logs"), - 0 - ) + LiveViewConfig("LOGS", listOf("endpoint_logs")) ) - ) { + ).onComplete { if (it.failed()) { log.error("Failed to add live view subscription", it.cause()) } @@ -467,33 +449,6 @@ class PortalEventListener( handleTraceResult(traceResult, portal, portal.viewingArtifact) } - } else if (Instance.localTracing != null) { - portal.tracesView.localTracing = true - Instance.localTracing!!.getTraceResult( - artifactQualifiedName = portal.viewingArtifact, - start = ZonedDateTime.now().minusHours(24).toInstant().toKotlinInstant(), - stop = ZonedDateTime.now().toInstant().toKotlinInstant(), - orderType = portal.tracesView.orderType, - pageSize = portal.tracesView.viewTraceAmount, - pageNumber = portal.tracesView.pageNumber, - ) { - if (it.succeeded()) { - handleTraceResult(it.result(), portal, portal.viewingArtifact) - } else { - val replyException = it.cause() as ReplyException - if (replyException.failureType() == ReplyFailure.TIMEOUT) { - log.warn("Timed out getting local trace results") - } else { - val actualException = replyException.cause!! - if (actualException is AccessDenied) { - log.error("Access denied. Reason: " + actualException.reason) - } else { - it.cause().printStackTrace() - log.error("Failed to get local trace results", it.cause()) - } - } - } - } } } } @@ -679,8 +634,6 @@ class PortalEventListener( portal.configuration.visibleActivity = true portal.configuration.visibleTraces = true portal.configuration.visibleLogs = true //todo: can hide based on if there is logs - } else if (Instance.localTracing != null) { - portal.configuration.visibleTraces = true } else { //non-endpoint artifact; hide activity/traces till manually shown portal.configuration.visibleActivity = false diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkConstructor.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkConstructor.kt deleted file mode 100644 index 856dd8b14..000000000 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkConstructor.kt +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.jetbrains.sourcemarker.mark - -import com.intellij.psi.PsiElement -import spp.jetbrains.marker.SourceMarker.creationService -import spp.jetbrains.marker.source.SourceFileMarker -import spp.jetbrains.marker.source.mark.api.SourceMark -import spp.jetbrains.marker.source.mark.api.key.SourceKey -import spp.jetbrains.marker.source.mark.gutter.GutterMark -import spp.jetbrains.marker.source.mark.inlay.ExpressionInlayMark -import spp.jetbrains.marker.source.mark.inlay.InlayMark -import spp.jetbrains.marker.source.mark.inlay.config.InlayMarkVirtualText -import spp.protocol.advice.AdviceType -import spp.protocol.advice.ArtifactAdvice -import spp.protocol.advice.informative.ActiveExceptionAdvice -import spp.protocol.utils.toPrettyDuration -import spp.jetbrains.sourcemarker.PluginBundle.message -import spp.jetbrains.sourcemarker.SourceMarkerPlugin -import spp.jetbrains.sourcemarker.SourceMarkerPlugin.SOURCE_RED -import spp.jetbrains.sourcemarker.icons.SourceMarkerIcons -import kotlinx.datetime.Clock -import org.slf4j.LoggerFactory - -/** - * Sets up the appropriate [SourceMark] display configuration based on [AdviceType]. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -object SourceMarkConstructor { - - private val log = LoggerFactory.getLogger(SourceMarkConstructor::class.java) - private val ADVICE_TIMER = SourceKey("ADVICE_TIMER") - - fun tearDownSourceMark(sourceMark: SourceMark) { - val artifactAdvice = sourceMark.getUserData(SourceMarkKeys.ARTIFACT_ADVICE) - if (artifactAdvice == null || artifactAdvice.isEmpty()) { - return - } - - artifactAdvice.forEach { - when (it.type) { - AdviceType.ActiveExceptionAdvice -> { - val timerId = sourceMark.getUserData(ADVICE_TIMER) - if (timerId != null) { - SourceMarkerPlugin.vertx.cancelTimer(timerId) - sourceMark.putUserData(ADVICE_TIMER, null) - } - } - else -> { - //no additional tear down necessary - } - } - } - artifactAdvice.clear() - } - - fun getOrSetupSourceMark(fileMarker: SourceFileMarker, advice: ArtifactAdvice): SourceMark? { - when (advice.type) { - AdviceType.RampDetectionAdvice -> { - val gutterMark = creationService.getOrCreateExpressionGutterMark(fileMarker, advice.artifact.lineNumber!!) - return if (gutterMark.isPresent) { - if (!fileMarker.containsSourceMark(gutterMark.get())) { - attachAdvice(gutterMark.get(), advice) - gutterMark.get().apply() - } - gutterMark.get() - } else { - log.warn("No detected expression at line {}. Gutter mark ignored", advice.artifact.lineNumber!!) - null - } - } - AdviceType.ActiveExceptionAdvice -> { - val inlayMark = creationService.getOrCreateExpressionInlayMark(fileMarker, advice.artifact.lineNumber!!) - return if (inlayMark.isPresent) { - if (!fileMarker.containsSourceMark(inlayMark.get())) { - attachAdvice(inlayMark.get(), advice) - inlayMark.get().apply() - } - inlayMark.get() - } else { - log.warn("No detected expression at line {}. Inlay mark ignored", advice.artifact.lineNumber!!) - null - } - } - } - } - - fun attachAdvice(sourceMark: SourceMark, advice: ArtifactAdvice) = when (sourceMark.type) { - SourceMark.Type.GUTTER -> attachAdvice(sourceMark as GutterMark, advice) - SourceMark.Type.INLAY -> attachAdvice(sourceMark as InlayMark, advice) - } - - private fun attachAdvice(gutterMark: GutterMark, advice: ArtifactAdvice) { - gutterMark.configuration.icon = SourceMarkerIcons.getGutterMarkIcon(advice) - gutterMark.setVisible(true) - gutterMark.sourceFileMarker.refresh() - } - - @Suppress("MagicNumber") - private fun attachAdvice(inlayMark: InlayMark, advice: ArtifactAdvice) { - when (advice) { - is ActiveExceptionAdvice -> { - val expressionMark = inlayMark as ExpressionInlayMark - val prettyTimeAgo = if (isThrows(expressionMark.getPsiExpression())) { - { - val occurred = (Clock.System.now() - .toEpochMilliseconds() - advice.occurredAt.toEpochMilliseconds()).toPrettyDuration() + - " " + message("ago") - " //${message("last_occurred")} $occurred " - } - } else { - { - val exceptionType = advice.stackTrace.exceptionType.substringAfterLast(".") - val occurred = (Clock.System.now() - .toEpochMilliseconds() - advice.occurredAt.toEpochMilliseconds()).toPrettyDuration() + - " " + message("ago") - " //${message("threw")} $exceptionType $occurred " - } - } - - inlayMark.configuration.virtualText = InlayMarkVirtualText(inlayMark, prettyTimeAgo.invoke()) - inlayMark.configuration.virtualText!!.textAttributes.foregroundColor = SOURCE_RED - inlayMark.configuration.virtualText!!.useInlinePresentation = true - inlayMark.configuration.activateOnMouseClick = false - - inlayMark.putUserData(ADVICE_TIMER, SourceMarkerPlugin.vertx.setPeriodic(1000) { - inlayMark.configuration.virtualText!!.updateVirtualText(prettyTimeAgo.invoke()) - }) - - //todo: shouldn't be creating gutter mark here - val gutterMark = creationService.getOrCreateExpressionGutterMark( - inlayMark.sourceFileMarker, advice.artifact.lineNumber!! - ).get() - if (!gutterMark.sourceFileMarker.containsSourceMark(gutterMark)) { - gutterMark.configuration.icon = SourceMarkerIcons.activeException - gutterMark.apply() - } - } - } - } - - private fun isThrows(psiExpression: PsiElement): Boolean { - TODO() - } -} 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 b626086c6..b1df1a0b5 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkKeys.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/mark/SourceMarkKeys.kt @@ -17,12 +17,11 @@ */ package spp.jetbrains.sourcemarker.mark +import spp.jetbrains.marker.jvm.psi.EndpointDetector +import spp.jetbrains.marker.jvm.psi.LoggerDetector import spp.jetbrains.marker.source.mark.api.SourceMark import spp.jetbrains.marker.source.mark.api.key.SourceKey import spp.jetbrains.portal.SourcePortal -import spp.protocol.advice.ArtifactAdvice -import spp.jetbrains.marker.jvm.psi.EndpointDetector -import spp.jetbrains.marker.jvm.psi.LoggerDetector import spp.jetbrains.sourcemarker.service.InstrumentEventListener import spp.jetbrains.sourcemarker.status.StatusBar @@ -36,7 +35,6 @@ object SourceMarkKeys { val SOURCE_PORTAL = SourceKey("SOURCE_PORTAL") val ENDPOINT_DETECTOR = SourceKey("ENDPOINT_DETECTOR") val LOGGER_DETECTOR = SourceKey("LOGGER_DETECTOR") - val ARTIFACT_ADVICE = SourceKey>("ARTIFACT_ADVICE") val BREAKPOINT_ID = SourceKey("BREAKPOINT_ID") val LOG_ID = SourceKey("LOG_ID") val METER_ID = SourceKey("METER_ID") 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 8e245e3a1..6e3e4309c 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 @@ -45,8 +45,6 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.util.SystemInfo import com.intellij.util.Consumer import com.intellij.util.io.decodeBase64 -import spp.jetbrains.sourcemarker.PluginBundle -import spp.jetbrains.sourcemarker.SourceMarkerPlugin import io.vertx.core.json.JsonObject import org.eclipse.egit.github.core.Issue import org.eclipse.egit.github.core.Label @@ -54,6 +52,8 @@ 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 spp.jetbrains.sourcemarker.SourceMarkerPlugin import java.awt.Component import java.io.IOException import java.io.PrintWriter diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/InstrumentEventListener.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/InstrumentEventListener.kt index 80d469981..089e3fe85 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/InstrumentEventListener.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/InstrumentEventListener.kt @@ -17,7 +17,7 @@ */ package spp.jetbrains.sourcemarker.service -import spp.protocol.instrument.LiveInstrumentEvent +import spp.protocol.instrument.event.LiveInstrumentEvent /** * todo: description. 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 7371c8674..947f344e0 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveInstrumentManager.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveInstrumentManager.kt @@ -21,30 +21,31 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.editor.EditorFactory 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 spp.jetbrains.marker.SourceMarker -import spp.protocol.ProtocolAddress.Global.ArtifactLogUpdated -import spp.protocol.SourceMarkerServices.Instance -import spp.protocol.SourceMarkerServices.Provide -import spp.protocol.instrument.LiveInstrumentEvent -import spp.protocol.instrument.LiveInstrumentEventType -import spp.protocol.instrument.breakpoint.LiveBreakpoint -import spp.protocol.instrument.breakpoint.event.LiveBreakpointHit -import spp.protocol.instrument.breakpoint.event.LiveBreakpointRemoved -import spp.protocol.instrument.log.LiveLog -import spp.protocol.instrument.log.event.LiveLogHit -import spp.protocol.instrument.log.event.LiveLogRemoved import spp.jetbrains.sourcemarker.discover.TCPServiceDiscoveryBackend import spp.jetbrains.sourcemarker.mark.SourceMarkKeys import spp.jetbrains.sourcemarker.search.SourceMarkSearch import spp.jetbrains.sourcemarker.service.breakpoint.BreakpointHitWindowService import spp.jetbrains.sourcemarker.service.breakpoint.BreakpointTriggerListener +import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import spp.jetbrains.sourcemarker.status.LiveStatusManager -import io.vertx.core.json.Json -import io.vertx.core.json.JsonObject -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.protocol.ProtocolAddress.Global.ArtifactLogUpdated +import spp.protocol.ProtocolMarshaller.deserializeLiveInstrumentRemoved +import spp.protocol.SourceServices.Instance +import spp.protocol.SourceServices.Provide.toLiveInstrumentSubscriberAddress +import spp.protocol.instrument.LiveBreakpoint +import spp.protocol.instrument.LiveLog +import spp.protocol.instrument.event.LiveBreakpointHit +import spp.protocol.instrument.event.LiveInstrumentEvent +import spp.protocol.instrument.event.LiveInstrumentEventType +import spp.protocol.instrument.event.LiveLogHit /** * todo: description. @@ -53,17 +54,24 @@ import org.slf4j.LoggerFactory * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ @Suppress("UNCHECKED_CAST") -class LiveInstrumentManager(private val project: Project) : CoroutineVerticle() { +class LiveInstrumentManager( + private val project: Project, + private val pluginConfig: SourceMarkerConfig +) : CoroutineVerticle() { companion object { private val log = LoggerFactory.getLogger(LiveInstrumentManager::class.java) } override suspend fun start() { - log.debug("LiveInstrumentManager started") + var developer = "system" + if (pluginConfig.serviceToken != null) { + val json = JWT.parse(pluginConfig.serviceToken) + developer = json.getJsonObject("payload").getString("developer_id") + } EditorFactory.getInstance().eventMulticaster.addEditorMouseListener(BreakpointTriggerListener, project) - vertx.eventBus().consumer("local." + Provide.LIVE_INSTRUMENT_SUBSCRIBER) { + vertx.eventBus().consumer(toLiveInstrumentSubscriberAddress(developer)) { val liveEvent = Json.decodeValue(it.body().toString(), LiveInstrumentEvent::class.java) log.debug("Received instrument event. Type: {}", liveEvent.eventType) @@ -81,13 +89,13 @@ class LiveInstrumentManager(private val project: Project) : CoroutineVerticle() //register listener FrameHelper.sendFrame( BridgeEventType.REGISTER.name.toLowerCase(), - Provide.LIVE_INSTRUMENT_SUBSCRIBER, - JsonObject(), - TCPServiceDiscoveryBackend.socket!! + toLiveInstrumentSubscriberAddress(developer), null, + JsonObject().apply { pluginConfig.serviceToken?.let { put("auth-token", it) } }, + null, null, TCPServiceDiscoveryBackend.socket!! ) //show live status bars - Instance.liveInstrument!!.getLiveInstruments { + Instance.liveInstrument!!.getLiveInstruments(null).onComplete { if (it.succeeded()) { log.info("Found {} active live status bars", it.result().size) LiveStatusManager.addActiveLiveInstruments(it.result()) @@ -98,9 +106,9 @@ class LiveInstrumentManager(private val project: Project) : CoroutineVerticle() } private fun handleLogRemovedEvent(liveEvent: LiveInstrumentEvent) { - val logRemoved = Json.decodeValue(liveEvent.data, LiveLogRemoved::class.java) + val logRemoved = deserializeLiveInstrumentRemoved(JsonObject(liveEvent.data)) ApplicationManager.getApplication().invokeLater { - val inlayMark = SourceMarkSearch.findByLogId(logRemoved.logId) + val inlayMark = SourceMarkSearch.findByLogId(logRemoved.liveInstrument.id!!) if (inlayMark != null) { val eventListeners = inlayMark.getUserData(SourceMarkKeys.INSTRUMENT_EVENT_LISTENERS) if (eventListeners?.isNotEmpty() == true) { @@ -144,9 +152,9 @@ class LiveInstrumentManager(private val project: Project) : CoroutineVerticle() } private fun handleBreakpointRemovedEvent(liveEvent: LiveInstrumentEvent) { - val bpRemoved = Json.decodeValue(liveEvent.data, LiveBreakpointRemoved::class.java) + val bpRemoved = deserializeLiveInstrumentRemoved(JsonObject(liveEvent.data)) ApplicationManager.getApplication().invokeLater { - val inlayMark = SourceMarkSearch.findByBreakpointId(bpRemoved.breakpointId) + val inlayMark = SourceMarkSearch.findByBreakpointId(bpRemoved.liveInstrument.id!!) if (inlayMark != null) { val eventListeners = inlayMark.getUserData(SourceMarkKeys.INSTRUMENT_EVENT_LISTENERS) if (eventListeners?.isNotEmpty() == true) { 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 6dd1af2d7..099464c68 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveViewManager.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LiveViewManager.kt @@ -25,7 +25,6 @@ import io.vertx.ext.bridge.BridgeEventType import io.vertx.ext.eventbus.bridge.tcp.impl.protocol.FrameHelper import io.vertx.kotlin.coroutines.CoroutineVerticle import io.vertx.kotlin.coroutines.dispatcher -import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.datetime.toJavaInstant import kotlinx.datetime.toKotlinInstant @@ -40,7 +39,7 @@ import spp.protocol.ProtocolAddress import spp.protocol.ProtocolAddress.Global.ArtifactMetricsUpdated import spp.protocol.ProtocolAddress.Global.ArtifactTracesUpdated import spp.protocol.ProtocolAddress.Global.TraceSpanUpdated -import spp.protocol.SourceMarkerServices.Provide +import spp.protocol.SourceServices.Provide.toLiveViewSubscriberAddress import spp.protocol.artifact.QueryTimeFrame import spp.protocol.artifact.log.Log import spp.protocol.artifact.log.LogOrderType @@ -52,8 +51,8 @@ import spp.protocol.artifact.trace.Trace import spp.protocol.artifact.trace.TraceOrderType import spp.protocol.artifact.trace.TraceResult import spp.protocol.artifact.trace.TraceSpan -import spp.protocol.instrument.LiveInstrumentEvent -import spp.protocol.instrument.LiveInstrumentEventType.METER_UPDATED +import spp.protocol.instrument.event.LiveInstrumentEvent +import spp.protocol.instrument.event.LiveInstrumentEventType.METER_UPDATED import spp.protocol.instrument.meter.MeterType import spp.protocol.view.LiveViewEvent import java.net.URI @@ -61,7 +60,7 @@ import java.time.Instant import java.time.ZoneOffset import java.time.format.DateTimeFormatterBuilder -class LiveViewManager(val markerConfig: SourceMarkerConfig) : CoroutineVerticle() { +class LiveViewManager(private val pluginConfig: SourceMarkerConfig) : CoroutineVerticle() { private val log = LoggerFactory.getLogger(LiveViewManager::class.java) @@ -73,18 +72,18 @@ class LiveViewManager(val markerConfig: SourceMarkerConfig) : CoroutineVerticle( override suspend fun start() { //register listener var developer = "system" - if (markerConfig.serviceToken != null) { - val json = JWT.parse(markerConfig.serviceToken) + if (pluginConfig.serviceToken != null) { + val json = JWT.parse(pluginConfig.serviceToken) developer = json.getJsonObject("payload").getString("developer_id") } - vertx.eventBus().consumer("local." + Provide.LIVE_VIEW_SUBSCRIBER + "." + developer) { + vertx.eventBus().consumer(toLiveViewSubscriberAddress(developer)) { val event = Json.decodeValue(it.body().toString(), LiveViewEvent::class.java) if (log.isTraceEnabled) log.trace("Received live event: {}", event) when (event.viewConfig.viewName) { - "LIVE_METER" -> GlobalScope.launch(vertx.dispatcher()) { consumeLiveMeterEvent(event) } - "LOGS" -> GlobalScope.launch(vertx.dispatcher()) { consumeLogsViewEvent(event) } + "LIVE_METER" -> launch(vertx.dispatcher()) { consumeLiveMeterEvent(event) } + "LOGS" -> launch(vertx.dispatcher()) { consumeLogsViewEvent(event) } "TRACES" -> { val sourceMark = SourceMarkSearch.findByEndpointName(event.entityId) if (sourceMark == null) { @@ -107,13 +106,13 @@ class LiveViewManager(val markerConfig: SourceMarkerConfig) : CoroutineVerticle( FrameHelper.sendFrame( BridgeEventType.REGISTER.name.toLowerCase(), - Provide.LIVE_VIEW_SUBSCRIBER + "." + developer, - JsonObject(), - TCPServiceDiscoveryBackend.socket!! + toLiveViewSubscriberAddress(developer), null, + JsonObject().apply { pluginConfig.serviceToken?.let { put("auth-token", it) } }, + null, null, TCPServiceDiscoveryBackend.socket!! ) } - private suspend fun consumeLiveMeterEvent(event: LiveViewEvent) { + private fun consumeLiveMeterEvent(event: LiveViewEvent) { val meterTypeStr = event.entityId.substringAfter("spp_").substringBefore("_").toUpperCase() val meterType = MeterType.valueOf(meterTypeStr) val meterId = event.entityId.substringAfter(meterType.name.toLowerCase() + "_").replace("_", "-") diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LogCountIndicators.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LogCountIndicators.kt index fd7135e67..155040e3a 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LogCountIndicators.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/LogCountIndicators.kt @@ -33,7 +33,7 @@ import spp.jetbrains.marker.source.mark.api.MethodSourceMark import spp.jetbrains.sourcemarker.icons.SourceMarkerIcons import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.LOGGER_DETECTOR import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig -import spp.protocol.SourceMarkerServices.Instance +import spp.protocol.SourceServices.Instance import spp.protocol.instrument.DurationStep /** @@ -69,7 +69,7 @@ class LogCountIndicators : CoroutineVerticle() { Clock.System.now().minus(15, DateTimeUnit.MINUTE), Clock.System.now(), DurationStep.MINUTE - ) { + ).onComplete { if (it.succeeded()) { val occurrences = it.result() //log.info("Found ${occurrences} occurrences of log patterns") diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointEventColumnInfo.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointEventColumnInfo.kt index 757ddba29..95f7a8ac4 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointEventColumnInfo.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointEventColumnInfo.kt @@ -19,13 +19,13 @@ package spp.jetbrains.sourcemarker.service.breakpoint import com.intellij.util.ui.ColumnInfo import com.intellij.util.ui.table.IconTableCellRenderer +import kotlinx.datetime.toJavaInstant +import spp.jetbrains.sourcemarker.icons.SourceMarkerIcons import spp.protocol.artifact.exception.methodName import spp.protocol.artifact.exception.qualifiedClassName import spp.protocol.artifact.exception.shortQualifiedClassName import spp.protocol.artifact.exception.sourceAsLineNumber -import spp.protocol.instrument.breakpoint.event.LiveBreakpointHit -import spp.jetbrains.sourcemarker.icons.SourceMarkerIcons -import kotlinx.datetime.toJavaInstant +import spp.protocol.instrument.event.LiveBreakpointHit import java.time.ZoneId import java.time.format.DateTimeFormatter import javax.swing.Icon diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointHitColumnInfo.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointHitColumnInfo.kt index f1ecf4bcf..7c3ee64df 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointHitColumnInfo.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointHitColumnInfo.kt @@ -18,14 +18,15 @@ package spp.jetbrains.sourcemarker.service.breakpoint import com.intellij.util.ui.ColumnInfo -import spp.protocol.instrument.LiveInstrumentEvent -import spp.protocol.instrument.LiveInstrumentEventType -import spp.protocol.instrument.breakpoint.event.LiveBreakpointHit -import spp.protocol.instrument.breakpoint.event.LiveBreakpointRemoved -import spp.protocol.utils.toPrettyDuration -import spp.jetbrains.sourcemarker.PluginBundle.message import io.vertx.core.json.Json +import io.vertx.core.json.JsonObject import kotlinx.datetime.Clock +import spp.jetbrains.sourcemarker.PluginBundle.message +import spp.protocol.ProtocolMarshaller.deserializeLiveInstrumentRemoved +import spp.protocol.instrument.event.LiveBreakpointHit +import spp.protocol.instrument.event.LiveInstrumentEvent +import spp.protocol.instrument.event.LiveInstrumentEventType +import spp.protocol.utils.toPrettyDuration /** * todo: description. @@ -41,14 +42,14 @@ class BreakpointHitColumnInfo(name: String) : ColumnInfo item.toString() } } else { - val item = Json.decodeValue(event.data, LiveBreakpointRemoved::class.java) + val item = deserializeLiveInstrumentRemoved(JsonObject(event.data)) return when (name) { "Breakpoint Data" -> item.cause!!.message ?: item.cause!!.exceptionType "Time" -> (Clock.System.now().toEpochMilliseconds() - item.occurredAt.toEpochMilliseconds()) diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointHitWindowService.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointHitWindowService.kt index 29834a73d..5c6e01d7a 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointHitWindowService.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/BreakpointHitWindowService.kt @@ -30,12 +30,12 @@ import com.intellij.ui.content.ContentManager import com.intellij.ui.content.ContentManagerEvent import com.intellij.ui.content.ContentManagerListener import com.intellij.xdebugger.impl.ui.ExecutionPointHighlighter -import spp.protocol.instrument.breakpoint.event.LiveBreakpointHit +import org.slf4j.LoggerFactory import spp.jetbrains.sourcemarker.icons.SourceMarkerIcons.LIVE_BREAKPOINT_DISABLED_ICON import spp.jetbrains.sourcemarker.service.breakpoint.LiveBreakpointConstants.LIVE_BREAKPOINT_NAME import spp.jetbrains.sourcemarker.service.breakpoint.ui.BreakpointHitWindow import spp.jetbrains.sourcemarker.service.breakpoint.ui.EventsWindow -import org.slf4j.LoggerFactory +import spp.protocol.instrument.event.LiveBreakpointHit /** * todo: description. diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ExecutionPointManager.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ExecutionPointManager.kt index 6e57ced09..8dfb34f2c 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ExecutionPointManager.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ExecutionPointManager.kt @@ -25,10 +25,10 @@ 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 -import org.slf4j.LoggerFactory /** * todo: probably don't need this as the breakpoint bar serves as the execution point indicator diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/painter/VariableEditorLinePainter.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/painter/VariableEditorLinePainter.kt index 726a8fe58..802caca68 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/painter/VariableEditorLinePainter.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/painter/VariableEditorLinePainter.kt @@ -29,7 +29,6 @@ import com.intellij.xdebugger.ui.DebuggerColors import spp.jetbrains.sourcemarker.service.breakpoint.BreakpointHitWindowService import java.awt.Color import java.awt.Font -import java.util.* /** * todo: description. diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/tree/VariableRootSimpleNode.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/tree/VariableRootSimpleNode.kt index fa0665105..82f7cf57d 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/tree/VariableRootSimpleNode.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/tree/VariableRootSimpleNode.kt @@ -24,7 +24,7 @@ import spp.jetbrains.marker.jvm.JVMVariableSimpleNode import spp.jetbrains.marker.py.PythonVariableRootNode import spp.jetbrains.sourcemarker.activities.PluginSourceMarkerStartupActivity.Companion.PYCHARM_PRODUCT_CODES import spp.jetbrains.sourcemarker.service.breakpoint.StackFrameManager -import spp.protocol.instrument.LiveVariableScope +import spp.protocol.instrument.variable.LiveVariableScope /** * todo: description. diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/BreakpointHitWindow.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/BreakpointHitWindow.kt index fe887de0a..a8b0c17c0 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/BreakpointHitWindow.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/BreakpointHitWindow.kt @@ -29,14 +29,14 @@ import com.intellij.openapi.util.Disposer import com.intellij.ui.content.Content import com.intellij.util.concurrency.AppExecutorUtil import com.intellij.xdebugger.impl.ui.ExecutionPointHighlighter -import spp.protocol.artifact.exception.LiveStackTrace -import spp.protocol.artifact.exception.LiveStackTraceElement +import io.vertx.core.json.Json import spp.jetbrains.sourcemarker.service.breakpoint.DebugStackFrameListener import spp.jetbrains.sourcemarker.service.breakpoint.ExecutionPointManager import spp.jetbrains.sourcemarker.service.breakpoint.LiveBreakpointConstants import spp.jetbrains.sourcemarker.service.breakpoint.StackFrameManager import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig -import io.vertx.core.json.Json +import spp.protocol.artifact.exception.LiveStackTrace +import spp.protocol.artifact.exception.LiveStackTraceElement import java.util.concurrent.CopyOnWriteArrayList import javax.swing.JComponent diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/EventsTab.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/EventsTab.kt index 41266d07b..dc5aa5cae 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/EventsTab.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/EventsTab.kt @@ -29,7 +29,7 @@ import spp.jetbrains.sourcemarker.activities.PluginSourceMarkerStartupActivity import spp.jetbrains.sourcemarker.icons.SourceMarkerIcons.LIVE_BREAKPOINT_ACTIVE_ICON import spp.jetbrains.sourcemarker.service.breakpoint.BreakpointEventColumnInfo import spp.jetbrains.sourcemarker.service.breakpoint.BreakpointHitWindowService -import spp.protocol.instrument.breakpoint.event.LiveBreakpointHit +import spp.protocol.instrument.event.LiveBreakpointHit import java.awt.BorderLayout import java.awt.Point import java.awt.event.MouseAdapter diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/EventsWindow.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/EventsWindow.kt index c6705f6e0..288bdff35 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/EventsWindow.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/EventsWindow.kt @@ -23,8 +23,8 @@ import com.intellij.icons.AllIcons import com.intellij.openapi.Disposable import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer -import spp.jetbrains.sourcemarker.service.breakpoint.LiveBreakpointConstants import spp.jetbrains.sourcemarker.service.breakpoint.DebugStackFrameListener +import spp.jetbrains.sourcemarker.service.breakpoint.LiveBreakpointConstants import spp.jetbrains.sourcemarker.service.breakpoint.StackFrameManager import java.util.concurrent.CopyOnWriteArrayList import javax.swing.JComponent diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/FramesTab.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/FramesTab.kt index 38aa5c733..9a461f483 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/FramesTab.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/ui/FramesTab.kt @@ -24,11 +24,11 @@ import com.intellij.ui.ColoredListCellRenderer import com.intellij.ui.SimpleTextAttributes import com.intellij.ui.components.JBList import com.intellij.ui.components.JBScrollPane -import spp.protocol.artifact.exception.LiveStackTraceElement -import spp.protocol.artifact.exception.sourceAsLineNumber import spp.jetbrains.sourcemarker.service.breakpoint.DebugStackFrameListener import spp.jetbrains.sourcemarker.service.breakpoint.StackFrameManager import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig +import spp.protocol.artifact.exception.LiveStackTraceElement +import spp.protocol.artifact.exception.sourceAsLineNumber import java.awt.BorderLayout import javax.swing.JList import javax.swing.JPanel diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/log/LogHitColumnInfo.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/log/LogHitColumnInfo.kt index 8a2f4c129..4bb12dc8e 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/log/LogHitColumnInfo.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/log/LogHitColumnInfo.kt @@ -18,14 +18,15 @@ package spp.jetbrains.sourcemarker.service.log import com.intellij.util.ui.ColumnInfo -import spp.protocol.instrument.LiveInstrumentEvent -import spp.protocol.instrument.LiveInstrumentEventType -import spp.protocol.instrument.log.event.LiveLogHit -import spp.protocol.instrument.log.event.LiveLogRemoved -import spp.protocol.utils.toPrettyDuration -import spp.jetbrains.sourcemarker.PluginBundle.message import io.vertx.core.json.Json +import io.vertx.core.json.JsonObject import kotlinx.datetime.Clock +import spp.jetbrains.sourcemarker.PluginBundle.message +import spp.protocol.ProtocolMarshaller.deserializeLiveInstrumentRemoved +import spp.protocol.instrument.event.LiveInstrumentEvent +import spp.protocol.instrument.event.LiveInstrumentEventType +import spp.protocol.instrument.event.LiveLogHit +import spp.protocol.utils.toPrettyDuration /** * todo: description. @@ -41,14 +42,14 @@ class LogHitColumnInfo(name: String) : ColumnInfo(n val obj1 = if (t.eventType == LiveInstrumentEventType.LOG_HIT) { Json.decodeValue(t.data, LiveLogHit::class.java) } else if (t.eventType == LiveInstrumentEventType.LOG_REMOVED) { - Json.decodeValue(t.data, LiveLogRemoved::class.java) + deserializeLiveInstrumentRemoved(JsonObject(t.data)) } else { throw IllegalArgumentException(t.eventType.name) } val obj2 = if (t2.eventType == LiveInstrumentEventType.LOG_HIT) { Json.decodeValue(t2.data, LiveLogHit::class.java) } else if (t2.eventType == LiveInstrumentEventType.LOG_REMOVED) { - Json.decodeValue(t2.data, LiveLogRemoved::class.java) + deserializeLiveInstrumentRemoved(JsonObject(t2.data)) } else { throw IllegalArgumentException(t2.eventType.name) } @@ -62,14 +63,14 @@ class LogHitColumnInfo(name: String) : ColumnInfo(n if (event.eventType == LiveInstrumentEventType.LOG_HIT) { val item = Json.decodeValue(event.data, LiveLogHit::class.java) return when (name) { - "Message" -> item.logResult.logs.first().getFormattedMessage() + "Message" -> item.logResult.logs.first().toFormattedMessage() "Time" -> (Clock.System.now().toEpochMilliseconds() - item.occurredAt.toEpochMilliseconds()) .toPrettyDuration() + " " + message("ago") else -> item.toString() } } else { - val item = Json.decodeValue(event.data, LiveLogRemoved::class.java) + val item = deserializeLiveInstrumentRemoved(JsonObject(event.data)) return when (name) { "Message" -> item.cause!!.message ?: item.cause!!.exceptionType "Time" -> (Clock.System.now().toEpochMilliseconds() - item.occurredAt.toEpochMilliseconds()) 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 cf6da5ded..39f07ba60 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/settings/SourceMarkerConfigurable.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/settings/SourceMarkerConfigurable.kt @@ -21,12 +21,12 @@ 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 spp.jetbrains.sourcemarker.PluginBundle.message -import spp.jetbrains.sourcemarker.SourceMarkerPlugin import io.vertx.core.json.DecodeException import io.vertx.core.json.Json import kotlinx.coroutines.runBlocking import org.slf4j.LoggerFactory +import spp.jetbrains.sourcemarker.PluginBundle.message +import spp.jetbrains.sourcemarker.SourceMarkerPlugin import javax.swing.JComponent /** diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/LiveStatusManager.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/LiveStatusManager.kt index 2f12a4b27..14aade941 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/LiveStatusManager.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/LiveStatusManager.kt @@ -46,15 +46,11 @@ import spp.jetbrains.sourcemarker.mark.SourceMarkKeys.LOG_ID import spp.jetbrains.sourcemarker.service.InstrumentEventListener import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import spp.protocol.ProtocolAddress.Portal.DisplayLogs -import spp.protocol.SourceMarkerServices +import spp.protocol.SourceServices import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.ArtifactType import spp.protocol.artifact.log.LogResult -import spp.protocol.instrument.LiveInstrument -import spp.protocol.instrument.LiveSourceLocation -import spp.protocol.instrument.breakpoint.LiveBreakpoint -import spp.protocol.instrument.log.LiveLog -import spp.protocol.instrument.meter.LiveMeter +import spp.protocol.instrument.* import spp.protocol.instrument.meter.MeterType import spp.protocol.portal.PageType import spp.protocol.view.LiveViewConfig @@ -400,20 +396,15 @@ object LiveStatusManager : SourceMarkEventListener { @JvmStatic fun showMeterStatusIcon(liveMeter: LiveMeter, sourceFileMarker: SourceFileMarker) { - SourceMarkerServices.Instance.liveView!!.addLiveViewSubscription( + SourceServices.Instance.liveView!!.addLiveViewSubscription( LiveViewSubscription( null, listOf(liveMeter.toMetricId()), ArtifactQualifiedName(liveMeter.location.source, type = ArtifactType.EXPRESSION), liveMeter.location, - LiveViewConfig( - "LIVE_METER", - true, - listOf("last_minute", "last_hour", "last_day"), - 0 - ) + LiveViewConfig("LIVE_METER", listOf("last_minute", "last_hour", "last_day")) ) - ) { + ).onComplete { if (it.failed()) { log.error("Failed to add live view subscription", it.cause()) } diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/AutoCompleteCellRenderer.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/AutoCompleteCellRenderer.kt index 9f350387d..84d481dd2 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/AutoCompleteCellRenderer.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/AutoCompleteCellRenderer.kt @@ -21,8 +21,8 @@ import spp.jetbrains.sourcemarker.PluginUI.BGND_FOCUS_COLOR import spp.jetbrains.sourcemarker.command.AutocompleteFieldRow import spp.jetbrains.sourcemarker.command.LiveControlCommand import spp.jetbrains.sourcemarker.element.AutocompleteRow +import spp.protocol.artifact.ArtifactNameUtils.getShortFunctionSignature import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.utils.ArtifactNameUtils.getShortFunctionSignature import java.awt.Component import javax.swing.DefaultListCellRenderer import javax.swing.JList diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/AutocompleteField.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/AutocompleteField.kt index d1578b7ed..b42dcfc0f 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/AutocompleteField.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/AutocompleteField.kt @@ -24,8 +24,8 @@ import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil import spp.jetbrains.sourcemarker.PluginIcons import spp.jetbrains.sourcemarker.PluginUI.* -import spp.jetbrains.sourcemarker.service.log.VariableParser import spp.jetbrains.sourcemarker.command.AutocompleteFieldRow +import spp.jetbrains.sourcemarker.service.log.VariableParser import spp.protocol.artifact.ArtifactQualifiedName import java.awt.* import java.awt.event.* diff --git a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/ControlBarCellRenderer.kt b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/ControlBarCellRenderer.kt index b96f92de2..a56920ae1 100644 --- a/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/ControlBarCellRenderer.kt +++ b/plugin/src/main/kotlin/spp/jetbrains/sourcemarker/status/util/ControlBarCellRenderer.kt @@ -21,7 +21,7 @@ import spp.jetbrains.sourcemarker.PluginUI import spp.jetbrains.sourcemarker.command.AutocompleteFieldRow import spp.jetbrains.sourcemarker.command.LiveControlCommand import spp.jetbrains.sourcemarker.element.LiveControlBarRow -import spp.protocol.utils.ArtifactNameUtils.getShortFunctionSignature +import spp.protocol.artifact.ArtifactNameUtils.getShortFunctionSignature import java.awt.Component import javax.swing.DefaultListCellRenderer import javax.swing.JList diff --git a/plugin/src/test/kotlin/spp/jetbrains/StandaloneActivityLiveView.kt b/plugin/src/test/kotlin/spp/jetbrains/StandaloneActivityLiveView.kt index f41484b90..013d1060d 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/StandaloneActivityLiveView.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/StandaloneActivityLiveView.kt @@ -49,7 +49,7 @@ import spp.jetbrains.sourcemarker.SourceMarkerPlugin.vertx import spp.jetbrains.sourcemarker.mark.SourceMarkKeys import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import spp.protocol.ProtocolAddress.Global.RefreshActivity -import spp.protocol.SourceMarkerServices +import spp.protocol.SourceServices import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.ArtifactType import spp.protocol.instrument.LiveSourceLocation @@ -145,20 +145,15 @@ class StandaloneActivityLiveView : LightJavaCodeInsightFixtureTestCase() { val endpointName = sourceMark.getUserData( SourceMarkKeys.ENDPOINT_DETECTOR )?.getOrFindEndpointName(sourceMark) ?: return@launch - SourceMarkerServices.Instance.liveView?.addLiveViewSubscription( + SourceServices.Instance.liveView!!.addLiveViewSubscription( LiveViewSubscription( null, listOf(endpointName), sourceMark.artifactQualifiedName, LiveSourceLocation(sourceMark.artifactQualifiedName.identifier, -1), - LiveViewConfig( - "ACTIVITY", - false, - listOf("endpoint_cpm", "endpoint_avg", "endpoint_sla"), - refreshRateLimit = 0 - ) + LiveViewConfig("ACTIVITY", listOf("endpoint_cpm", "endpoint_avg", "endpoint_sla")) ) - ) { + ).onComplete { if (it.succeeded()) { println(it) } else { diff --git a/plugin/src/test/kotlin/spp/jetbrains/StandaloneLogsLiveView.kt b/plugin/src/test/kotlin/spp/jetbrains/StandaloneLogsLiveView.kt index c57c75771..ac6aee7af 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/StandaloneLogsLiveView.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/StandaloneLogsLiveView.kt @@ -30,13 +30,6 @@ import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.PsiTestUtil import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase -import spp.jetbrains.portal.SourcePortal -import spp.protocol.ProtocolAddress.Global.RefreshLogs -import spp.protocol.portal.PageType -import spp.protocol.portal.PortalConfiguration -import spp.jetbrains.sourcemarker.SourceMarkerPlugin -import spp.jetbrains.sourcemarker.SourceMarkerPlugin.vertx -import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import io.vertx.core.Promise import io.vertx.core.json.Json import io.vertx.kotlin.coroutines.await @@ -47,8 +40,15 @@ import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Assumptions.assumeTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import spp.jetbrains.portal.SourcePortal +import spp.jetbrains.sourcemarker.SourceMarkerPlugin +import spp.jetbrains.sourcemarker.SourceMarkerPlugin.vertx +import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig +import spp.protocol.ProtocolAddress.Global.RefreshLogs import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.ArtifactType +import spp.protocol.portal.PageType +import spp.protocol.portal.PortalConfiguration import java.io.File class StandaloneLogsLiveView : LightJavaCodeInsightFixtureTestCase() { diff --git a/plugin/src/test/kotlin/spp/jetbrains/StandaloneTracesLiveView.kt b/plugin/src/test/kotlin/spp/jetbrains/StandaloneTracesLiveView.kt index 9c4ff5e32..d8b5e07f9 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/StandaloneTracesLiveView.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/StandaloneTracesLiveView.kt @@ -30,13 +30,6 @@ import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.PsiTestUtil import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase -import spp.jetbrains.portal.SourcePortal -import spp.protocol.ProtocolAddress.Global.RefreshTraces -import spp.protocol.portal.PageType -import spp.protocol.portal.PortalConfiguration -import spp.jetbrains.sourcemarker.SourceMarkerPlugin -import spp.jetbrains.sourcemarker.SourceMarkerPlugin.vertx -import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig import io.vertx.core.Promise import io.vertx.core.json.Json import io.vertx.kotlin.coroutines.await @@ -47,8 +40,15 @@ import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Assumptions.assumeTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import spp.jetbrains.portal.SourcePortal +import spp.jetbrains.sourcemarker.SourceMarkerPlugin +import spp.jetbrains.sourcemarker.SourceMarkerPlugin.vertx +import spp.jetbrains.sourcemarker.settings.SourceMarkerConfig +import spp.protocol.ProtocolAddress.Global.RefreshTraces import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.ArtifactType +import spp.protocol.portal.PageType +import spp.protocol.portal.PortalConfiguration import java.io.File class StandaloneTracesLiveView : LightJavaCodeInsightFixtureTestCase() { diff --git a/plugin/src/test/kotlin/spp/jetbrains/mapper/vcs/git/GitRepositoryMapperTest.kt b/plugin/src/test/kotlin/spp/jetbrains/mapper/vcs/git/GitRepositoryMapperTest.kt index 08991c990..59a0c1cd7 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/mapper/vcs/git/GitRepositoryMapperTest.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/mapper/vcs/git/GitRepositoryMapperTest.kt @@ -17,12 +17,12 @@ */ package spp.jetbrains.mapper.vcs.git -import spp.jetbrains.mapper.SourceMapperTest import org.eclipse.jgit.api.Git import org.eclipse.jgit.internal.storage.file.FileRepository import org.intellij.lang.annotations.Language import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test +import spp.jetbrains.mapper.SourceMapperTest import java.io.File import java.nio.file.Files import java.util.* diff --git a/plugin/src/test/kotlin/spp/jetbrains/mapper/vcs/git/MethodRenameTest.kt b/plugin/src/test/kotlin/spp/jetbrains/mapper/vcs/git/MethodRenameTest.kt index a5dad64de..114e2b4d1 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/mapper/vcs/git/MethodRenameTest.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/mapper/vcs/git/MethodRenameTest.kt @@ -17,11 +17,6 @@ */ package spp.jetbrains.mapper.vcs.git -import spp.jetbrains.mapper.SourceMapperTest -import spp.jetbrains.mapper.api.impl.SourceMapperImpl -import spp.jetbrains.mapper.vcs.git.GitRepositoryMapper.Companion.originalCommitIdPattern -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.ArtifactType import org.eclipse.jgit.api.Git import org.eclipse.jgit.internal.storage.file.FileRepository import org.eclipse.jgit.lib.AnyObjectId @@ -33,6 +28,11 @@ import org.eclipse.jgit.transport.URIish import org.intellij.lang.annotations.Language import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test +import spp.jetbrains.mapper.SourceMapperTest +import spp.jetbrains.mapper.api.impl.SourceMapperImpl +import spp.jetbrains.mapper.vcs.git.GitRepositoryMapper.Companion.originalCommitIdPattern +import spp.protocol.artifact.ArtifactQualifiedName +import spp.protocol.artifact.ArtifactType import java.io.File import java.nio.file.Files import java.util.* diff --git a/plugin/src/test/kotlin/spp/jetbrains/portal/display/views/ActivityViewTest.kt b/plugin/src/test/kotlin/spp/jetbrains/portal/display/views/ActivityViewTest.kt index bcb9aa432..b394b24af 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/portal/display/views/ActivityViewTest.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/portal/display/views/ActivityViewTest.kt @@ -17,18 +17,18 @@ */ package spp.jetbrains.portal.display.views -import spp.jetbrains.portal.SourcePortal -import spp.protocol.artifact.QueryTimeFrame -import spp.protocol.artifact.metrics.ArtifactMetricResult -import spp.protocol.artifact.metrics.ArtifactMetrics -import spp.protocol.artifact.metrics.MetricType -import spp.protocol.portal.PortalConfiguration import kotlinx.datetime.toKotlinInstant import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test +import spp.jetbrains.portal.SourcePortal import spp.protocol.artifact.ArtifactQualifiedName import spp.protocol.artifact.ArtifactType +import spp.protocol.artifact.QueryTimeFrame +import spp.protocol.artifact.metrics.ArtifactMetricResult +import spp.protocol.artifact.metrics.ArtifactMetrics +import spp.protocol.artifact.metrics.MetricType +import spp.protocol.portal.PortalConfiguration import java.time.ZonedDateTime import java.time.temporal.ChronoUnit 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 8d79faf6f..5233503f9 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 @@ -18,14 +18,14 @@ package spp.jetbrains.sourcemarker.psi.endpoint import com.intellij.openapi.application.ApplicationManager -import spp.jetbrains.marker.jvm.psi.EndpointDetector -import spp.jetbrains.sourcemarker.SourceMarkerPlugin import io.vertx.kotlin.coroutines.await import kotlinx.coroutines.runBlocking import org.intellij.lang.annotations.Language import org.jetbrains.uast.UFile import org.jetbrains.uast.toUElement import org.junit.jupiter.api.Test +import spp.jetbrains.marker.jvm.psi.EndpointDetector +import spp.jetbrains.sourcemarker.SourceMarkerPlugin class GroovyEndpointDetectorTest : EndpointDetectorTest() { 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 bb903a37c..65cd99bf5 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 @@ -18,14 +18,14 @@ package spp.jetbrains.sourcemarker.psi.endpoint import com.intellij.openapi.application.ApplicationManager -import spp.jetbrains.marker.jvm.psi.EndpointDetector -import spp.jetbrains.sourcemarker.SourceMarkerPlugin import io.vertx.kotlin.coroutines.await import kotlinx.coroutines.runBlocking import org.intellij.lang.annotations.Language import org.jetbrains.uast.UFile import org.jetbrains.uast.toUElement import org.junit.jupiter.api.Test +import spp.jetbrains.marker.jvm.psi.EndpointDetector +import spp.jetbrains.sourcemarker.SourceMarkerPlugin class JavaEndpointDetectorTest : EndpointDetectorTest() { 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 92732baf4..5bba95961 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 @@ -18,14 +18,14 @@ package spp.jetbrains.sourcemarker.psi.endpoint import com.intellij.openapi.application.ApplicationManager -import spp.jetbrains.marker.jvm.psi.EndpointDetector -import spp.jetbrains.sourcemarker.SourceMarkerPlugin import io.vertx.kotlin.coroutines.await import kotlinx.coroutines.runBlocking import org.intellij.lang.annotations.Language import org.jetbrains.uast.UFile import org.jetbrains.uast.toUElement import org.junit.jupiter.api.Test +import spp.jetbrains.marker.jvm.psi.EndpointDetector +import spp.jetbrains.sourcemarker.SourceMarkerPlugin class KotlinEndpointDetectorTest : EndpointDetectorTest() { 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 812267aee..1ea6a2300 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 @@ -18,14 +18,14 @@ package spp.jetbrains.sourcemarker.psi.endpoint import com.intellij.openapi.application.ApplicationManager -import spp.jetbrains.marker.jvm.psi.EndpointDetector -import spp.jetbrains.sourcemarker.SourceMarkerPlugin import io.vertx.kotlin.coroutines.await import kotlinx.coroutines.runBlocking import org.intellij.lang.annotations.Language import org.jetbrains.uast.UFile import org.jetbrains.uast.toUElement import org.junit.jupiter.api.Test +import spp.jetbrains.marker.jvm.psi.EndpointDetector +import spp.jetbrains.sourcemarker.SourceMarkerPlugin class ScalaEndpointNameDetectorTest : EndpointDetectorTest() { diff --git a/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/InstrumentConditionParserTest.kt b/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/InstrumentConditionParserTest.kt index f467ca1c4..655d44147 100644 --- a/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/InstrumentConditionParserTest.kt +++ b/plugin/src/test/kotlin/spp/jetbrains/sourcemarker/service/breakpoint/InstrumentConditionParserTest.kt @@ -27,12 +27,12 @@ import com.intellij.psi.PsiJavaFile import com.intellij.testFramework.TestApplicationManager import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl -import spp.jetbrains.marker.InstrumentConditionParser -import spp.jetbrains.marker.jvm.JVMConditionParser import org.intellij.lang.annotations.Language import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import spp.jetbrains.marker.InstrumentConditionParser +import spp.jetbrains.marker.jvm.JVMConditionParser class InstrumentConditionParserTest : LightJavaCodeInsightFixtureTestCase() { diff --git a/settings.gradle b/settings.gradle index 21412fe68..671277dc6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,7 +7,7 @@ pluginManagement { id 'org.jetbrains.kotlin.plugin.serialization' version kotlinVersion apply false id 'com.avast.gradle.docker-compose' version "0.15.0" apply false id 'io.gitlab.arturbosch.detekt' version "1.19.0" apply false - id 'com.apollographql.apollo3' version "3.0.0" apply false + id 'com.apollographql.apollo3' version "3.1.0" apply false id 'com.diffplug.spotless' version '6.2.1' apply false } }