CodeStyleManager.reformat Not working during big data

Answered
 private String reformat(FileType fileType, String text) {
     PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText("name.tmp", fileType, text);
     return WriteCommandAction.runWriteCommandAction(project, (Computable<String>) () -> {
         CodeStyleManager.getInstance(project).reformat(psiFile, true);
         return psiFile.getText();
     });
 }

 

I use CodeStyleManagerial. reformat to format JSON or XML in memory, but it doesn't work when the data is large, and can be used when the data is small

0
3 comments

Hi,

I briefly checked the reformat code and didn't found any limits (which exist for adjusting the indent). I suggest debugging the reformat method and find out what is happening there.

0

I may not understand what the reformat method actually does. I tried a 48k JSON file, but it couldn't be formatted. Can you help me? Is there any other method to format XML or JSON

0

I found that he worked after calling reformatText

1

Please sign in to leave a comment.