Search in sources :

Example 6 with OptimizeImportsProcessor

use of com.intellij.codeInsight.actions.OptimizeImportsProcessor in project intellij-plugins by StepicOrg.

the class ReformatUtils method reformatSelectedEditor.

public static void reformatSelectedEditor(@NotNull Project project, @NotNull Document document) {
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
    if (file == null)
        return;
    new ReformatCodeProcessor(new OptimizeImportsProcessor(project, file), false).run();
}
Also used : OptimizeImportsProcessor(com.intellij.codeInsight.actions.OptimizeImportsProcessor) PsiFile(com.intellij.psi.PsiFile) ReformatCodeProcessor(com.intellij.codeInsight.actions.ReformatCodeProcessor)

Aggregations

OptimizeImportsProcessor (com.intellij.codeInsight.actions.OptimizeImportsProcessor)6 PsiFile (com.intellij.psi.PsiFile)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 ReformatCodeProcessor (com.intellij.codeInsight.actions.ReformatCodeProcessor)1 Result (com.intellij.openapi.application.Result)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 VcsConfiguration (com.intellij.openapi.vcs.VcsConfiguration)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 JavaCodeStyleManager (com.intellij.psi.codeStyle.JavaCodeStyleManager)1 IOException (java.io.IOException)1 Nullable (org.jetbrains.annotations.Nullable)1