Invoking ReformatCodeAction programmatically without the dialog Follow
Hi,
This is the code that I use to invoke the "Reformat Code" action progamatically:
ReformatCodeAction reformatAction = (ReformatCodeAction)
ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_REFORMAT);
reformatAction.actionPerformed(new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN,
reformatAction.getTemplatePresentation(), ActionManager.getInstance(), 0));
The code works fine but I like to know if there is a way to avoid the "Reformat Code" dialog and perform the formatting directly.
Thanks,
Andre
Please sign in to leave a comment.
The code to call can be seen in ReformatCodeAction ;-) use com.intellij.codeInsight.actions.ReformatCodeProcessor and its variants
Thanks Yann, I'll try this.
Andre