void (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { final int offset = editor.getCaretModel().getOffset(); final PsiElement position = file.findElementAt(offset); if (position == null) { return; } try { final File svgFile = FileUtil.createTempFile("control-flow", ".svg", true); final String path = svgFile.getAbsolutePath(); final boolean success = toSvgFile(path, position); if (success) { ApplicationManager.getApplication().invokeLater(() -> { boolean exists = svgFile.exists(); final VirtualFile fileByUrl = VirtualFileManager.getInstance().refreshAndFindFileByUrl(VfsUtilCore.pathToUrl(path)); if (fileByUrl != null) { final AnAction openInBrowser = ActionManager.getInstance().getAction("OpenInBrowser"); DataContext dataContext = dataId -> { if (CommonDataKeys.VIRTUAL_FILE.is(dataId)) { return fileByUrl; } if (CommonDataKeys.PROJECT.is(dataId)) { return project; } return null; }; final AnActionEvent action = AnActionEvent.createFromDataContext("ShowControlFlow", null, dataContext); openInBrowser.actionPerformed(action); } else { LOGGER.error("cannot find file by URL: " + path + " " + exists); } }); } } catch (FileNotFoundException e) { NOTIFICATION_GROUP .createNotification("Show CFG:", NO_GRAPHVIZ_HELP, NotificationType.ERROR) .setSubtitle(e.getMessage()) .notify(project); LOGGER.warn(e); } catch (IOException | ExecutionException e) { LOGGER.warn(e); } }