I'm using an editor instance in a JFrame. Which took me a while to implement, but now it's working.
ScratchpadManager scratchpadManager = ScratchpadManager.getInstance(project);
VirtualFile scratchFile = scratchpadManager.createScratchFile(psiFile.getLanguage());
EditorFactory editorFactory = EditorFactory.getInstance();
Document document = editorFactory.createDocument(selectedText);
Editor editor = editorFactory.createEditor(document, project, scratchFile, false);
The variable psiFile comes from the application editor. My questions is, how can I get the PSI File of scratchFile?
Or is there any method than CodeStyleManager.reformat() to reformat the code without getting the PSI File?