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.
fix: fix action group position issues
- Loading branch information
Showing
4 changed files
with
59 additions
and
18 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
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/cc/unitmesh/devti/intentions/editor/IntentionsActionGroup.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,36 @@ | ||
package cc.unitmesh.devti.intentions.editor | ||
|
||
import cc.unitmesh.devti.AutoDevBundle | ||
import cc.unitmesh.devti.intentions.AIAssistantIntention | ||
import com.intellij.codeInsight.intention.IntentionAction | ||
import com.intellij.openapi.actionSystem.ActionGroup | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import com.intellij.openapi.editor.Editor | ||
import com.intellij.openapi.project.DumbAware | ||
import com.intellij.openapi.project.DumbAwareAction | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.PsiFile | ||
|
||
class IntentionsActionGroup : ActionGroup(), DumbAware { | ||
init { | ||
templatePresentation.text = | ||
AutoDevBundle.message("intentions.assistant.name") | ||
} | ||
|
||
override fun getChildren(e: AnActionEvent?): Array<AnAction> { | ||
val project: Project = e?.project ?: return emptyArray() | ||
val editor: Editor = e.getData(CommonDataKeys.EDITOR) ?: return emptyArray() | ||
val file: PsiFile = e.getData(CommonDataKeys.PSI_FILE) ?: return emptyArray() | ||
|
||
val intentions: List<IntentionAction> = | ||
AIAssistantIntention.getAiAssistantIntentions(project, editor, file) | ||
|
||
return intentions.map { intentionAction -> | ||
DumbAwareAction.create(intentionAction.text) { | ||
intentionAction.invoke(project, editor, file) | ||
} | ||
}.toTypedArray() | ||
} | ||
} |
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