void (@NotNull AnActionEvent e) { Editor editor = e.getData(CommonDataKeys.EDITOR); final Project project = e.getProject(); JsonLineExtractor jsonLineExtractor = project == null || editor == null ? null : new JsonLineExtractor(editor); if (jsonLineExtractor == null || !jsonLineExtractor.has()) { return; } FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); if (selectOpened(editor, jsonLineExtractor, fileEditorManager)) { return; } LightVirtualFile virtualFile = new LightVirtualFile(StringUtil.trimMiddle(jsonLineExtractor.getPrefix(), 50), JsonLanguage.INSTANCE, jsonLineExtractor.get()); virtualFile.putUserData(LINE_KEY, jsonLineExtractor.getLine()); virtualFile.putUserData(EDITOR_REF_KEY, new WeakReference<>(editor)); final PsiFile file = PsiManager.getInstance(project).findFile(virtualFile); if (file == null) { return; } DocumentUtil.writeInRunUndoTransparentAction(() -> CodeStyleManager.getInstance(project).reformat(file, true)); virtualFile.setWritable(false); FileEditorManager.getInstance(project).openFile(virtualFile, true); }