generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
86 additions
and
31 deletions.
There are no files selected for viewing
28 changes: 0 additions & 28 deletions
28
src/main/kotlin/cc/unitmesh/devti/language/DisplayStoryLineMarkerContributor.kt
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/cc/unitmesh/devti/language/FindBugLineMarkerContributor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package cc.unitmesh.devti.language | ||
|
||
import cc.unitmesh.devti.DevtiIcons | ||
import cc.unitmesh.devti.runconfig.command.FindBugConfigurationProducer | ||
import com.intellij.execution.lineMarker.ExecutorAction | ||
import com.intellij.execution.lineMarker.RunLineMarkerContributor | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.PsiMethod | ||
|
||
class FindBugLineMarkerContributor : RunLineMarkerContributor() { | ||
override fun getInfo(element: PsiElement): Info? { | ||
if (element !is PsiMethod) return null | ||
val actions = ExecutorAction.getActions(0) | ||
val state = FindBugConfigurationProducer().findConfig(listOf(element)) ?: return null | ||
return Info( | ||
DevtiIcons.STORY, | ||
{ state.configurationName }, | ||
*actions | ||
) | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/main/kotlin/cc/unitmesh/devti/runconfig/command/FindBugConfigurationProducer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cc.unitmesh.devti.runconfig.command | ||
|
||
import cc.unitmesh.devti.runconfig.DtRunConfiguration | ||
import cc.unitmesh.devti.runconfig.config.FindBugConfigure | ||
import com.intellij.execution.actions.ConfigurationContext | ||
import com.intellij.openapi.util.Ref | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.PsiMethod | ||
|
||
class FindBugConfigurationProducer : BaseLazyRunConfigurationProducer<FindBugConfigure>() { | ||
init { | ||
registerConfigProvider { elements -> createConfigFor(elements) } | ||
} | ||
|
||
private fun createConfigFor( | ||
elements: List<PsiElement> | ||
): FindBugConfigure? { | ||
if (elements.isEmpty()) return null | ||
val methods = elements.filterIsInstance<PsiMethod>() | ||
if (methods.isEmpty()) return null | ||
|
||
val method = methods.first() | ||
|
||
return FindBugConfigure(method.name) | ||
} | ||
|
||
override fun isConfigurationFromContext(configuration: DtRunConfiguration, context: ConfigurationContext): Boolean { | ||
val config = findConfig(context.location?.psiElement?.let { listOf(it) } ?: return false) ?: return false | ||
configuration.name = config.configurationName | ||
|
||
return true | ||
} | ||
|
||
override fun setupConfigurationFromContext( | ||
configuration: DtRunConfiguration, | ||
context: ConfigurationContext, | ||
sourceElement: Ref<PsiElement> | ||
): Boolean { | ||
val config = findConfig(context.location?.psiElement?.let { listOf(it) } ?: return false) ?: return false | ||
configuration.name = config.configurationName | ||
|
||
return true | ||
} | ||
|
||
private fun registerConfigProvider(provider: (List<PsiElement>) -> FindBugConfigure?) { | ||
runConfigProviders.add(provider) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/cc/unitmesh/devti/runconfig/config/FindBugConfigure.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package cc.unitmesh.devti.runconfig.config | ||
|
||
import cc.unitmesh.devti.runconfig.command.BaseConfig | ||
|
||
class FindBugConfigure( | ||
private val methodName: String, | ||
) : BaseConfig() { | ||
override var configurationName = "Find Bug" | ||
|
||
init { | ||
configurationName += " $methodName" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters