Search in sources :

Example 86 with ExecutionException

use of com.intellij.execution.ExecutionException in project buck by facebook.

the class BuckClient method connect.

public void connect() {
    if (isConnected() || mConnecting.get()) {
        return;
    }
    mConnecting.set(true);
    ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {

        @Override
        public void run() {
            try {
                int port = BuckWSServerPortUtils.getPort(mProject.getBasePath());
                // Connect to WebServer
                connectToWebServer("localhost", port);
            } catch (NumberFormatException e) {
                LOG.error(e);
            } catch (ExecutionException e) {
                LOG.error(e);
            } catch (IOException e) {
                LOG.error(e);
            } catch (RuntimeException e) {
                if (!mProject.isDisposed()) {
                    BuckModule buckModule = mProject.getComponent(BuckModule.class);
                    buckModule.attachIfDetached();
                    buckModule.getBuckEventsConsumer().consumeConsoleEvent(e.toString());
                }
            }
        }
    });
}
Also used : BuckModule(com.facebook.buck.intellij.ideabuck.config.BuckModule) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException)

Example 87 with ExecutionException

use of com.intellij.execution.ExecutionException in project jscs-plugin by idok.

the class JscsSettingsPage method getVersion.

private void getVersion() {
    if (settings != null && areEqual(nodeInterpreterField, settings.node) && areEqual(jscsBinField, settings.jscsExecutablePath) && settings.cwd.equals(project.getBasePath())) {
        return;
    }
    settings = new JscsSettings();
    settings.node = nodeInterpreterField.getChildComponent().getText();
    settings.jscsExecutablePath = jscsBinField.getChildComponent().getText();
    settings.cwd = project.getBasePath();
    try {
        String version = JscsRunner.version(settings);
        versionLabel.setText(version.trim());
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}
Also used : JscsSettings(com.jscs.cli.JscsSettings) ExecutionException(com.intellij.execution.ExecutionException)

Example 88 with ExecutionException

use of com.intellij.execution.ExecutionException in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoTestRunningState method patchExecutor.

@Override
protected GoExecutor patchExecutor(@NotNull GoExecutor executor) throws ExecutionException {
    executor.withParameters("test", "-v");
    executor.withParameterString(myConfiguration.getGoToolParams());
    switch(myConfiguration.getKind()) {
        case DIRECTORY:
            String relativePath = FileUtil.getRelativePath(myConfiguration.getWorkingDirectory(), myConfiguration.getDirectoryPath(), File.separatorChar);
            // TODO Once Go gets support for covering multiple packages the ternary condition should be reverted
            // See https://golang.org/issues/6909
            String pathSuffix = myCoverageFilePath == null ? "..." : ".";
            if (relativePath != null && !".".equals(relativePath)) {
                executor.withParameters("./" + relativePath + "/" + pathSuffix);
            } else {
                executor.withParameters("./" + pathSuffix);
                executor.withWorkDirectory(myConfiguration.getDirectoryPath());
            }
            addFilterParameter(executor, ObjectUtils.notNull(myFailedTestsPattern, myConfiguration.getPattern()));
            break;
        case PACKAGE:
            executor.withParameters(myConfiguration.getPackage());
            addFilterParameter(executor, ObjectUtils.notNull(myFailedTestsPattern, myConfiguration.getPattern()));
            break;
        case FILE:
            String filePath = myConfiguration.getFilePath();
            VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(filePath);
            if (virtualFile == null) {
                throw new ExecutionException("Test file doesn't exist");
            }
            PsiFile file = PsiManager.getInstance(myConfiguration.getProject()).findFile(virtualFile);
            if (file == null || !GoTestFinder.isTestFile(file)) {
                throw new ExecutionException("File '" + filePath + "' is not test file");
            }
            String importPath = ((GoFile) file).getImportPath(false);
            if (StringUtil.isEmpty(importPath)) {
                throw new ExecutionException("Cannot find import path for " + filePath);
            }
            executor.withParameters(importPath);
            addFilterParameter(executor, myFailedTestsPattern != null ? myFailedTestsPattern : buildFilterPatternForFile((GoFile) file));
            break;
    }
    if (myCoverageFilePath != null) {
        executor.withParameters("-coverprofile=" + myCoverageFilePath, "-covermode=atomic");
    }
    return executor;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GoFile(com.goide.psi.GoFile) PsiFile(com.intellij.psi.PsiFile) ExecutionException(com.intellij.execution.ExecutionException)

Example 89 with ExecutionException

use of com.intellij.execution.ExecutionException in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoRunConfigurationBase method createRunningState.

@NotNull
private RunningState createRunningState(ExecutionEnvironment env) throws ExecutionException {
    GoModuleBasedConfiguration configuration = getConfigurationModule();
    Module module = configuration.getModule();
    if (module == null) {
        throw new ExecutionException("Go isn't configured for run configuration: " + getName());
    }
    return newRunningState(env, module);
}
Also used : Module(com.intellij.openapi.module.Module) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Example 90 with ExecutionException

use of com.intellij.execution.ExecutionException in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoExecutor method createCommandLine.

@NotNull
public GeneralCommandLine createCommandLine() throws ExecutionException {
    if (myGoRoot == null) {
        throw new ExecutionException("Sdk is not set or Sdk home path is empty for module");
    }
    GeneralCommandLine commandLine = !myPtyDisabled && PtyCommandLine.isEnabled() ? new PtyCommandLine() : new GeneralCommandLine();
    commandLine.setExePath(ObjectUtils.notNull(myExePath, GoSdkService.getGoExecutablePath(myGoRoot)));
    commandLine.getEnvironment().putAll(myExtraEnvironment);
    commandLine.getEnvironment().put(GoConstants.GO_ROOT, StringUtil.notNullize(myGoRoot));
    commandLine.getEnvironment().put(GoConstants.GO_PATH, StringUtil.notNullize(myGoPath));
    if (myVendoringEnabled != null) {
        commandLine.getEnvironment().put(GoConstants.GO_VENDORING_EXPERIMENT, myVendoringEnabled ? "1" : "0");
    }
    Collection<String> paths = ContainerUtil.newArrayList();
    ContainerUtil.addIfNotNull(paths, StringUtil.nullize(commandLine.getEnvironment().get(GoConstants.PATH), true));
    ContainerUtil.addIfNotNull(paths, StringUtil.nullize(EnvironmentUtil.getValue(GoConstants.PATH), true));
    ContainerUtil.addIfNotNull(paths, StringUtil.nullize(myEnvPath, true));
    commandLine.getEnvironment().put(GoConstants.PATH, StringUtil.join(paths, File.pathSeparator));
    commandLine.withWorkDirectory(myWorkDirectory);
    commandLine.addParameters(myParameterList.getList());
    commandLine.withParentEnvironmentType(myParentEnvironmentType);
    commandLine.withCharset(CharsetToolkit.UTF8_CHARSET);
    return commandLine;
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) PtyCommandLine(com.intellij.execution.configurations.PtyCommandLine) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ExecutionException (com.intellij.execution.ExecutionException)154 NotNull (org.jetbrains.annotations.NotNull)42 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)39 IOException (java.io.IOException)35 File (java.io.File)34 VirtualFile (com.intellij.openapi.vfs.VirtualFile)26 Sdk (com.intellij.openapi.projectRoots.Sdk)20 Nullable (org.jetbrains.annotations.Nullable)20 Project (com.intellij.openapi.project.Project)19 ProcessHandler (com.intellij.execution.process.ProcessHandler)17 ProcessOutput (com.intellij.execution.process.ProcessOutput)17 Module (com.intellij.openapi.module.Module)13 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)12 Key (com.intellij.openapi.util.Key)12 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)10 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)9 ProcessEvent (com.intellij.execution.process.ProcessEvent)8 JavaParameters (com.intellij.execution.configurations.JavaParameters)7 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)7 ArrayList (java.util.ArrayList)7