private VCOutputFile generateVCs(VirtualFile resolveFile, Editor editor, Project project) { boolean forceGeneration = true; // from action, they really mean it RunRESOLVEOnLanguageFile gen = new RunRESOLVEOnLanguageFile(resolveFile, project, "gen vcs"); // SMTestRunnerConnectionUtil Map<String, String> argMap = new LinkedHashMap<>(); argMap.put("-lib", RunRESOLVEOnLanguageFile.getContentRoot(project, resolveFile).getPath()); argMap.put("-vcs", ""); gen.addArgs(argMap); boolean successful = false; try { successful = ProgressManager.getInstance() .run(gen); // , "Generating", canBeCancelled, e.getData(PlatformDataKeys.PROJECT)); } catch (Exception e1) { } if (successful && !editor.isDisposed()) { return gen.getVCOutput(); } return null; }
@Override public void actionPerformed(AnActionEvent e) { Project project = e.getData(PlatformDataKeys.PROJECT); if (project == null) { LOGGER.error("actionPerformed (genVCs): no project for " + e); return; } VirtualFile resolveFile = getRESOLVEFileFromEvent(e); LOGGER.info("prove actionPerformed " + (resolveFile == null ? "NONE" : resolveFile)); if (resolveFile == null) return; String title = "RESOLVE Prove"; boolean canBeCancelled = true; commitDoc(project, resolveFile); Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (editor == null) return; RunRESOLVEOnLanguageFile gen = new RunRESOLVEOnLanguageFile(resolveFile, project, title); MyProverListener pl = new MyProverListener(); VCOutputFile vco = generateVCs(resolveFile, editor, project); // give each action an instance of the prover listener and make Update() print the result as it // comes back produce if (vco == null) return; RESOLVEPluginController controller = RESOLVEPluginController.getInstance(project); VerifierPanel verifierPanel = controller.getVerifierPanel(); verifierPanel.createVerifierView2( vco.getFinalVCs(), pl); // TODO: maybe make this take in a list of VCs addVCGutterIcons(vco, editor, project, pl); controller.getVerifierWindow().show(null); // runProver List<String> args = new ArrayList<>(); args.add(resolveFile.getPath()); args.add("-lib"); args.add(RunRESOLVEOnLanguageFile.getContentRoot(project, resolveFile).getPath()); args.add("-prove"); RESOLVECompiler compiler = new RESOLVECompiler(args.toArray(new String[args.size()])); compiler.addProverListener(pl); // TODO: Instead of this being anon, make a separate static class and add an error listener to // 'compiler' that (make it accessible // right here though so the UI part below can stop and update remaining (unproved) vcs if the // compiler does indeed suffer some // catastrophic failure: npe, etc. Task.Backgroundable proverTask = new Task.Backgroundable(project, "Proving") { @Override public void run(@NotNull final ProgressIndicator progressIndicator) { compiler.processCommandLineTargets(); } }; ProgressManager.getInstance().run(proverTask); // TODO: Different status icons for different proof results. running = true; Task.Backgroundable task = new Task.Backgroundable(project, "Updating Presentation") { @Override public void run(@NotNull final ProgressIndicator progressIndicator) { Map<String, Boolean> processed = new HashMap<>(); for (VC vc : vco.getFinalVCs()) { processed.put(vc.getName(), false); } while (pl.vcIsProved.size() != vco.getFinalVCs().size()) { // if (proverTask.getNotificationInfo().)//TODO: Put something here that breaks out of // this if the compiler crashes.. for (VC vc : vco.getFinalVCs()) { if (pl.vcIsProved.containsKey(vc.getName()) && !processed.get(vc.getName())) { processed.put(vc.getName(), true); long dur = pl.vcMetrics.get(vc.getName()).getProofDuration(); ConditionCollapsiblePanel section = verifierPanel.vcSelectorPanel.vcTabs.get(vc.getNumber()); section.changeToFinalState( pl.vcIsProved.get(vc.getName()) ? ConditionCollapsiblePanel.State.PROVED : ConditionCollapsiblePanel.State.NOT_PROVED, dur); } } } running = false; } }; ProgressManager.getInstance().run(task); }