ToolWindow window = manager.getToolWindow(GoCommonConsoleView.ID);
if (GoCommonConsoleView.consoleView == null) {
GoCommonConsoleView.consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
}
ConsoleView consoleView = GoCommonConsoleView.consoleView;
if (window == null) {
window = manager.registerToolWindow(GoCommonConsoleView.ID, false, ToolWindowAnchor.BOTTOM);
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
Content content = contentFactory.createContent(consoleView.getComponent(), "", false);
window.getContentManager().addContent(content);
window.setIcon(GoSdkUtil.getProjectIcon(sdk));
window.setToHideOnEmptyContent(true);
}
window.setTitle(TITLE);
window.show(EmptyRunnable.getInstance());
String[] goEnv = GoSdkUtil.convertEnvMapToArray(sysEnv);
String command = String.format(
"%s vet ./...",
goExecName
);
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(command, goEnv, new File(projectDir));
OSProcessHandler handler = new OSProcessHandler(proc, null);
consoleView.attachToProcess(handler);
consoleView.print(String.format("%s%n", command), ConsoleViewContentType.NORMAL_OUTPUT);
handler.startNotify();
if (proc.waitFor() == 0) {
VirtualFileManager.getInstance().syncRefresh();
consoleView.print(String.format("%nFinished running go vet on project %s%n", projectDir), ConsoleViewContentType.NORMAL_OUTPUT);
} else {
consoleView.print(String.format("%nCouldn't vet project %s%n", projectDir), ConsoleViewContentType.ERROR_OUTPUT);
throw new CantRunException(String.format("Error while processing %s vet command.", goExecName));
}
} catch (Exception e) {
throw new CantRunException(String.format("Error while processing %s vet command.", goExecName));
}