leveraging existing actions

Is it possible to access existing actions such as reformat code, optimize imports or go to class?

1 comment

Hello!
Through OpenAPI is not possible, i guess. But you can get any action from ActionManager.getAction(String id).
Next, you must create a valid AnActionEvent. In this class you must pass a valid DataContext.
DataContext provide any information for AnAction. For example for Rename Class Action it must hold class name or virtualFile.

So, after a time of expiriment maybe you can create a valid DataContext and then you can use actionPerformed method in your selected action object.
For invoking this you must create Runnable and pass it to Application.runReadAction or SwingUtilities.invokeLater (this is must be detected by experiments).

Good luck! :)

0

Please sign in to leave a comment.