Invoking ReformatCodeAction programmatically without the dialog

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
2 comments
Comment actions Permalink

The code to call can be seen in ReformatCodeAction ;-) use com.intellij.codeInsight.actions.ReformatCodeProcessor and its variants

0
Comment actions Permalink

Thanks Yann, I'll try this.

Andre

0

Please sign in to leave a comment.