Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/detekt/detekt/blob/master/detekt-core/src/main/resources/default-detekt-config.yml

build:
maxIssues: 26 #todo: zero out
maxIssues: 38 #todo: zero out

formatting:
Indentation:
Expand Down
1 change: 0 additions & 1 deletion marker/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies {
compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compileOnly("com.google.guava:guava:31.1-jre")
compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly("org.slf4j:slf4j-api:$slf4jVersion")
compileOnly("org.jetbrains.intellij.deps.jcef:jcef:97.2.22-g6779618-chromium-97.0.4692.45-api-1.6")
compileOnly("com.jetbrains.intellij.platform:ide:$intellijVersion")
compileOnly("com.jetbrains.intellij.platform:ide-impl:$intellijVersion")
Expand Down
1 change: 0 additions & 1 deletion marker/jvm-marker/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies {
compileOnly("io.vertx:vertx-core:$vertxVersion")
compileOnly("io.vertx:vertx-lang-kotlin:$vertxVersion")
compileOnly("io.vertx:vertx-lang-kotlin-coroutines:$vertxVersion")
compileOnly("org.slf4j:slf4j-api:$slf4jVersion")
compileOnly("org.jooq:joor:$joorVersion")
compileOnly("org.apache.commons:commons-lang3:3.12.0")
compileOnly("com.android.tools.external.org-jetbrains:uast:30.2.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package spp.jetbrains.marker.jvm

import com.intellij.ide.util.PsiNavigationSupport
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.editor.Document
import com.intellij.openapi.project.Project
import com.intellij.psi.JavaPsiFacade
Expand All @@ -29,7 +30,6 @@ import io.vertx.core.*
import io.vertx.kotlin.coroutines.await
import org.jetbrains.uast.UMethod
import org.jetbrains.uast.toUElement
import org.slf4j.LoggerFactory
import spp.jetbrains.marker.source.JVMMarkerUtils
import spp.protocol.artifact.ArtifactQualifiedName
import spp.protocol.artifact.exception.LiveStackTraceElement
Expand All @@ -44,7 +44,7 @@ import spp.protocol.artifact.exception.sourceAsLineNumber
*/
object ArtifactNavigator {

private val log = LoggerFactory.getLogger(ArtifactNavigator::class.java)
private val log = logger<ArtifactNavigator>()

//todo: remove method from method names and support navigating to classes?

Expand Down Expand Up @@ -77,7 +77,7 @@ object ArtifactNavigator {
handler.handle(Future.succeededFuture(true))
}
} else {
log.warn("Could not find artifact: {}", artifactQualifiedName)
log.warn("Could not find artifact: $artifactQualifiedName")
handler.handle(Future.succeededFuture(false))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ object ArtifactSearch {
@Suppress("UnstableApiUsage")
suspend fun findArtifact(vertx: Vertx, artifact: ArtifactQualifiedName): PsiElement? {
val promise = Promise.promise<Optional<PsiElement>>()
val project = ProjectManager.getInstance().openProjects[0]
val project = ProjectManager.getInstance().openProjects[0] //todo: support multiple projects

ApplicationManager.getApplication().runReadAction {
if (artifact.type == ArtifactType.CLASS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package spp.jetbrains.marker.jvm

import com.intellij.codeInsight.daemon.GutterIconNavigationHandler
import com.intellij.codeInsight.daemon.LineMarkerInfo
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.editor.markup.GutterIconRenderer
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
Expand All @@ -29,7 +30,6 @@ import org.jetbrains.uast.UClass
import org.jetbrains.uast.UMethod
import org.jetbrains.uast.toUElement
import org.jetbrains.uast.toUElementOfType
import org.slf4j.LoggerFactory
import spp.jetbrains.marker.SourceMarker
import spp.jetbrains.marker.impl.ArtifactCreationService
import spp.jetbrains.marker.plugin.SourceLineMarkerProvider
Expand All @@ -50,7 +50,7 @@ import spp.jetbrains.marker.source.mark.gutter.MethodGutterMark
abstract class JVMLineMarkerProvider : SourceLineMarkerProvider() {

companion object {
private val log = LoggerFactory.getLogger(JVMLineMarkerProvider::class.java)
private val log = logger<JVMLineMarkerProvider>()
}

override fun getLineMarkerInfo(
Expand All @@ -65,9 +65,9 @@ abstract class JVMLineMarkerProvider : SourceLineMarkerProvider() {
}

private fun getClassGutterMark(element: PsiIdentifier): LineMarkerInfo<PsiElement>? {
val fileMarker = SourceMarker.getSourceFileMarker(element.containingFile) ?: return null
val fileMarker = SourceMarker.getInstance(element.project).getSourceFileMarker(element.containingFile) ?: return null
val artifactQualifiedName = JVMMarkerUtils.getFullyQualifiedName(element.parent.toUElement() as UClass)
if (!SourceMarker.configuration.createSourceMarkFilter.test(artifactQualifiedName)) return null
if (!SourceMarker.getInstance(element.project).configuration.createSourceMarkFilter.test(artifactQualifiedName)) return null

//check by artifact name first due to user can erroneously name same class twice
var gutterMark = fileMarker.getSourceMark(artifactQualifiedName, SourceMark.Type.GUTTER) as ClassGutterMark?
Expand Down Expand Up @@ -95,14 +95,14 @@ abstract class JVMLineMarkerProvider : SourceLineMarkerProvider() {
}

private fun getMethodGutterMark(element: PsiElement): LineMarkerInfo<PsiElement>? {
val fileMarker = SourceMarker.getSourceFileMarker(element.containingFile) ?: return null
val fileMarker = SourceMarker.getInstance(element.project).getSourceFileMarker(element.containingFile) ?: return null
val uMethod = element.parent.toUElementOfType<UMethod>()
if (uMethod == null) {
log.warn("Unable to transform to UMethod: {}", element.parent)
log.warn("Unable to transform to UMethod: ${element.parent}")
return null
}
val artifactQualifiedName = JVMMarkerUtils.getFullyQualifiedName(uMethod)
if (!SourceMarker.configuration.createSourceMarkFilter.test(artifactQualifiedName)) return null
if (!SourceMarker.getInstance(element.project).configuration.createSourceMarkFilter.test(artifactQualifiedName)) return null

//check by artifact name first due to user can erroneously name same method twice
var gutterMark = fileMarker.getSourceMark(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ class JVMSourceInlayHintProvider : SourceInlayHintProvider() {
if ((parent is PsiMethod && element === parent.nameIdentifier)
|| (JVMMarkerUtils.getNameIdentifier(parent) === element)
) {
val fileMarker = SourceMarker.getSourceFileMarker(element.containingFile)!!
val fileMarker = SourceMarker.getInstance(element.project).getSourceFileMarker(element.containingFile)!!
val artifactQualifiedName = JVMMarkerUtils.getFullyQualifiedName(parent.toUElement() as UMethod)
return if (!SourceMarker.configuration.createSourceMarkFilter.test(artifactQualifiedName)) null else {
return if (!SourceMarker.getInstance(element.project).configuration.createSourceMarkFilter.test(artifactQualifiedName)) null else {
JVMMarkerUtils.getOrCreateMethodInlayMark(fileMarker, element)
}
} else if (element is PsiStatement) {
val fileMarker = SourceMarker.getSourceFileMarker(element.containingFile)!!
val fileMarker = SourceMarker.getInstance(element.project).getSourceFileMarker(element.containingFile)!!
val artifactQualifiedName = JVMMarkerUtils.getFullyQualifiedName(
JVMMarkerUtils.getUniversalExpression(element).toUElement() as UExpression
)
return if (!SourceMarker.configuration.createSourceMarkFilter.test(artifactQualifiedName)) null else {
return if (!SourceMarker.getInstance(element.project).configuration.createSourceMarkFilter.test(artifactQualifiedName)) null else {
JVMMarkerUtils.getOrCreateExpressionInlayMark(fileMarker, element)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package spp.jetbrains.marker.jvm.psi

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.LogicalPosition
import com.intellij.openapi.util.TextRange
Expand All @@ -33,7 +34,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.jetbrains.uast.UMethod
import org.jetbrains.uast.toUElementOfType
import org.slf4j.LoggerFactory
import spp.jetbrains.marker.source.SourceFileMarker
import spp.jetbrains.marker.source.mark.api.MethodSourceMark
import spp.jetbrains.marker.source.mark.api.key.SourceKey
Expand All @@ -48,7 +48,7 @@ import spp.jetbrains.marker.source.mark.inlay.InlayMark
class LoggerDetector(val vertx: Vertx) {

companion object {
private val log = LoggerFactory.getLogger(LoggerDetector::class.java)
private val log = logger<LoggerDetector>()
val LOGGER_STATEMENTS = SourceKey<List<DetectedLogger>>("LOGGER_STATEMENTS")

private val LOGGER_CLASSES = setOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
package spp.jetbrains.marker.source

import com.intellij.openapi.diagnostic.logger
import com.intellij.psi.*
import com.intellij.psi.util.PsiUtil
import org.jetbrains.uast.*
import org.joor.Reflect
import org.slf4j.LoggerFactory
import spp.jetbrains.marker.SourceMarkerUtils
import spp.jetbrains.marker.source.mark.api.SourceMark
import spp.jetbrains.marker.source.mark.api.key.SourceKey
Expand All @@ -42,7 +42,7 @@ import java.util.*
@Suppress("TooManyFunctions")
object JVMMarkerUtils {

private val log = LoggerFactory.getLogger(JVMMarkerUtils::class.java)
private val log = logger<JVMMarkerUtils>()

/**
* todo: description.
Expand Down Expand Up @@ -445,7 +445,7 @@ object JVMMarkerUtils {
if (gutterMark == null) {
val uClass = element.parent.toUElement() as UClass
if (uClass.qualifiedName == null) {
log.warn("Could not determine qualified name of class: {}", uClass)
log.warn("Could not determine qualified name of class: $uClass")
return null
}
gutterMark = fileMarker.createClassSourceMark(
Expand Down Expand Up @@ -611,7 +611,7 @@ object JVMMarkerUtils {
it.type.canonicalText
}
} else {
log.warn("Unable to detect element type: {}", it)
log.warn("Unable to detect element type: $it")
}
}
return "$methodName($methodParams)"
Expand Down
1 change: 0 additions & 1 deletion marker/py-marker/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.google.guava:guava:31.1-jre")
implementation("org.jetbrains:annotations:23.0.0")
compileOnly("org.slf4j:slf4j-api:$slf4jVersion")
compileOnly("com.jetbrains.intellij.platform:ide:$intellijVersion")
compileOnly("com.jetbrains.intellij.platform:ide-impl:$intellijVersion")
compileOnly("com.jetbrains.intellij.platform:core:$intellijVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package spp.jetbrains.marker.py
import com.intellij.codeInsight.daemon.LineMarkerInfo
import com.intellij.psi.PsiElement
import com.jetbrains.python.psi.PyFile
import org.slf4j.LoggerFactory
import spp.jetbrains.marker.SourceMarker
import spp.jetbrains.marker.plugin.SourceLineMarkerProvider
import spp.jetbrains.marker.source.SourceFileMarker
Expand All @@ -33,16 +32,14 @@ import spp.jetbrains.marker.source.mark.gutter.GutterMark
*/
class PythonLineMarkerProvider : SourceLineMarkerProvider() {

private val log = LoggerFactory.getLogger(PythonLineMarkerProvider::class.java)

companion object {
init {
SourceFileMarker.SUPPORTED_FILE_TYPES.add(PyFile::class.java)
}
}

override fun getLineMarkerInfo(parent: PsiElement?, element: PsiElement): LineMarkerInfo<PsiElement>? {
val fileMarker = SourceMarker.getSourceFileMarker(element.containingFile)
val fileMarker = SourceMarker.getInstance(element.project).getSourceFileMarker(element.containingFile)
return null //todo: this
}

Expand Down
31 changes: 24 additions & 7 deletions marker/src/main/kotlin/spp/jetbrains/marker/SourceMarker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ package spp.jetbrains.marker
import com.google.common.collect.ImmutableList
import com.google.common.collect.Lists
import com.google.common.collect.Maps
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import com.intellij.psi.PsiFile
import io.vertx.core.Vertx
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.slf4j.LoggerFactory
import spp.jetbrains.marker.impl.ArtifactNamingService
import spp.jetbrains.marker.impl.SourceGuideProvider
import spp.jetbrains.marker.source.SourceFileMarker
Expand All @@ -39,14 +42,28 @@ import spp.protocol.artifact.ArtifactType
* @author [Brandon Fergerson](mailto:bfergerson@apache.org)
*/
@Suppress("TooManyFunctions")
object SourceMarker {
class SourceMarker {

var PLUGIN_NAME = "SourceMarker"
companion object {
var PLUGIN_NAME = "SourceMarker"

private val log = logger<SourceMarker>()
private val KEY = Key.create<SourceMarker>("SPP_SOURCE_MARKER")
val VERTX_KEY = Key.create<Vertx>("SPP_VERTX")

@Synchronized
fun getInstance(project: Project): SourceMarker {
if (project.getUserData(KEY) == null) {
val sourceMarker = SourceMarker()
project.putUserData(KEY, sourceMarker)
}
return project.getUserData(KEY)!!
}
}

@Volatile
var enabled = true
val configuration: SourceMarkerConfiguration = SourceMarkerConfiguration()
private val log = LoggerFactory.getLogger(javaClass)
private val availableSourceFileMarkers = Maps.newConcurrentMap<Int, SourceFileMarker>()
private val globalSourceMarkEventListeners = Lists.newArrayList<SourceMarkEventListener>()

Expand All @@ -65,7 +82,7 @@ object SourceMarker {
if (availableSourceFileMarkers.remove(sourceFileMarker.hashCode()) != null) {
sourceFileMarker.clearSourceMarks()
sourceFileMarker.psiFile.putUserData(SourceFileMarker.KEY, null)
log.info("Deactivated source file marker: {}", sourceFileMarker)
log.info("Deactivated source file marker: $sourceFileMarker")
return true
}
return false
Expand Down Expand Up @@ -120,12 +137,12 @@ object SourceMarker {
}

fun addGlobalSourceMarkEventListener(sourceMarkEventListener: SourceMarkEventListener) {
log.info("Adding global source mark event listener: {}", sourceMarkEventListener)
log.info("Adding global source mark event listener: $sourceMarkEventListener")
globalSourceMarkEventListeners.add(sourceMarkEventListener)
}

fun removeGlobalSourceMarkEventListener(sourceMarkEventListener: SourceMarkEventListener) {
log.info("Removing global source mark event listener: {}", sourceMarkEventListener)
log.info("Removing global source mark event listener: $sourceMarkEventListener")
globalSourceMarkEventListeners.remove(sourceMarkEventListener)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package spp.jetbrains.marker.plugin

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.event.EditorMouseEvent
Expand All @@ -30,7 +31,6 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiManager
import kotlinx.coroutines.runBlocking
import org.slf4j.LoggerFactory
import spp.jetbrains.marker.SourceMarker
import spp.jetbrains.marker.source.SourceFileMarker
import spp.jetbrains.marker.source.mark.gutter.GutterMark
Expand Down Expand Up @@ -61,15 +61,14 @@ class FileActivityListener : FileEditorManagerListener {
val fileMarker = psiFile?.getUserData(SourceFileMarker.KEY)
if (fileMarker != null) {
runBlocking {
SourceMarker.deactivateSourceFileMarker(fileMarker)
SourceMarker.getInstance(source.project).deactivateSourceFileMarker(fileMarker)
}
}
}
}

companion object {

private val log = LoggerFactory.getLogger(FileActivityListener::class.java)
private val log = logger<FileActivityListener>()

@JvmStatic
fun triggerFileOpened(source: FileEditorManager, file: VirtualFile) {
Expand Down
Loading