generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shirelang): add SonarLint action and tool window integration
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
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
38 changes: 38 additions & 0 deletions
38
shirelang/src/main/kotlin/com/phodal/shirelang/actions/external/ShireSonarLintAction.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,38 @@ | ||
package com.phodal.shirelang.actions.external | ||
|
||
import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.project.Project | ||
import com.phodal.shirecore.config.ShireActionLocation | ||
import com.phodal.shirecore.variable.template.VariableActionEventDataHolder | ||
import com.phodal.shirelang.actions.ShireRunFileAction | ||
import com.phodal.shirelang.actions.base.DynamicShireActionService | ||
|
||
class ShireSonarLintAction : AnAction() { | ||
override fun getActionUpdateThread() = ActionUpdateThread.EDT | ||
|
||
private fun shireActionConfigs(project: Project) = | ||
DynamicShireActionService.getInstance(project).getActions(ShireActionLocation.EXT_SONARQUBE_MENU) | ||
|
||
override fun update(e: AnActionEvent) { | ||
val project = e.project ?: return | ||
val isOnlyOneConfig = shireActionConfigs(project).size == 1 | ||
|
||
val hobbitHole = shireActionConfigs(project).firstOrNull()?.hole | ||
e.presentation.isVisible = isOnlyOneConfig | ||
e.presentation.isEnabled = hobbitHole != null && hobbitHole.enabled | ||
if (hobbitHole != null) { | ||
e.presentation.text = hobbitHole.name ?: "<Placeholder>" | ||
} | ||
} | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val project = e.project ?: return | ||
|
||
VariableActionEventDataHolder.putData(VariableActionEventDataHolder(e.dataContext)) | ||
|
||
val config = shireActionConfigs(project).firstOrNull() ?: return | ||
ShireRunFileAction.executeShireFile(project, config, null) | ||
} | ||
} |
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