Skip to content

Commit 2156c26

Browse files
committed
refactor: re-use run producer
1 parent a85a01f commit 2156c26

File tree

4 files changed

+22
-38
lines changed

4 files changed

+22
-38
lines changed
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
package com.github.tempest.framework.console.run
22

3+
import com.github.tempest.framework.TempestBundle
34
import com.github.tempest.framework.php.getConsoleCommandName
5+
import com.intellij.execution.lineMarker.ExecutorAction
46
import com.intellij.execution.lineMarker.RunLineMarkerContributor
7+
import com.intellij.icons.AllIcons
8+
import com.intellij.openapi.util.text.StringUtil
59
import com.intellij.psi.PsiElement
610
import com.jetbrains.php.lang.psi.elements.Method
711

812
class ConsoleCommandLineMarkerProvider : RunLineMarkerContributor() {
913
override fun getInfo(element: PsiElement) = when {
1014
element !is Method -> null
11-
element.getConsoleCommandName() == null -> null
12-
else -> Info(TempestRunTargetAction(element))
15+
else -> {
16+
val commandName = element.getConsoleCommandName() ?: return null
17+
Info(
18+
AllIcons.Actions.Execute,
19+
ExecutorAction.getActions(1),
20+
) {
21+
TempestBundle.message(
22+
"action.run.target.text",
23+
StringUtil.wrapWithDoubleQuote(TempestBundle.message("action.run.target.command", commandName)),
24+
)
25+
}
26+
}
1327
}
1428
}

src/main/kotlin/com/github/tempest/framework/console/run/TempestRunConfigurationProducer.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.tempest.framework.console.run
22

3+
import com.github.tempest.framework.TempestBundle
34
import com.github.tempest.framework.php.getConsoleCommandName
45
import com.intellij.execution.actions.ConfigurationContext
56
import com.intellij.execution.actions.LazyRunConfigurationProducer
@@ -14,9 +15,10 @@ class TempestRunConfigurationProducer : LazyRunConfigurationProducer<TempestCons
1415
sourceElement: Ref<PsiElement>
1516
): Boolean {
1617
val element = context.psiLocation as? Method ?: return false
18+
val commandName = element.getConsoleCommandName() ?: return false
1719

18-
configuration.settings.commandName = element.getConsoleCommandName() ?: return false
19-
configuration.name = "tempest ${configuration.settings.commandName}"
20+
configuration.settings.commandName = commandName
21+
configuration.name = TempestBundle.message("action.run.target.command", commandName)
2022

2123
return true
2224
}

src/main/kotlin/com/github/tempest/framework/console/run/TempestRunTargetAction.kt

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/main/resources/META-INF/plugin.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<runLineMarkerContributor
1616
language="PHP"
1717
implementationClass="com.github.tempest.framework.console.run.ConsoleCommandLineMarkerProvider" />
18+
<runConfigurationProducer
19+
implementation="com.github.tempest.framework.console.run.TempestRunConfigurationProducer" />
1820
<runAnything.executionProvider
1921
implementation="com.github.tempest.framework.console.run.TempestRunAnythingProvider" />
2022
<multiHostInjector

0 commit comments

Comments
 (0)