void (boolean optimizeImports, boolean rearrangeCode) { final PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(getOrCreateProjectBaseDir()); ReformatCodeAction.reformatDirectory( getProject(), psiDirectory, new DirectoryFormattingOptions() { @Override public boolean isIncludeSubdirectories() { return true; } @Nullable @Override public String getFileTypeMask() { return null; } @Nullable @Override public SearchScope getSearchScope() { return null; } @Override public TextRangeType getTextRangeType() { return TextRangeType.WHOLE_FILE; } @Override public boolean isOptimizeImports() { return optimizeImports; } @Override public boolean isRearrangeCode() { return rearrangeCode; } } ); FileDocumentManager.getInstance().saveAllDocuments(); }