Search in sources :

Example 6 with BuckModule

use of com.facebook.buck.intellij.ideabuck.config.BuckModule in project buck by facebook.

the class BuckTestAction method executeOnPooledThread.

@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
    String target = buildManager.getCurrentSavedTarget(project);
    BuckModule buckModule = project.getComponent(BuckModule.class);
    buckModule.attach(target);
    if (target == null) {
        buildManager.showNoTargetMessage(project);
        return;
    }
    // Initiate a buck test
    BuckBuildCommandHandler handler = new BuckBuildCommandHandler(project, project.getBaseDir(), BuckCommand.TEST);
    handler.command().addParameter(target);
    buildManager.runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}
Also used : Project(com.intellij.openapi.project.Project) BuckModule(com.facebook.buck.intellij.ideabuck.config.BuckModule) BuckBuildManager(com.facebook.buck.intellij.ideabuck.build.BuckBuildManager) BuckBuildCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler)

Example 7 with BuckModule

use of com.facebook.buck.intellij.ideabuck.config.BuckModule in project buck by facebook.

the class BuckUninstallAction method executeOnPooledThread.

@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
    String target = buildManager.getCurrentSavedTarget(project);
    BuckModule buckModule = project.getComponent(BuckModule.class);
    buckModule.attach(target);
    if (target == null) {
        buildManager.showNoTargetMessage(project);
        return;
    }
    // Initiate a buck uninstall
    BuckBuildCommandHandler handler = new BuckBuildCommandHandler(project, project.getBaseDir(), BuckCommand.UNINSTALL);
    handler.command().addParameter(target);
    buildManager.runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}
Also used : Project(com.intellij.openapi.project.Project) BuckModule(com.facebook.buck.intellij.ideabuck.config.BuckModule) BuckBuildManager(com.facebook.buck.intellij.ideabuck.build.BuckBuildManager) BuckBuildCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler)

Example 8 with BuckModule

use of com.facebook.buck.intellij.ideabuck.config.BuckModule in project buck by facebook.

the class TestExecutionState method runBuildCommand.

private ProcessHandler runBuildCommand(Executor executor) {
    final BuckModule buckModule = mProject.getComponent(BuckModule.class);
    final String target = mConfiguration.data.target;
    final String additionalParams = mConfiguration.data.additionalParams;
    final String testSelectors = mConfiguration.data.testSelectors;
    final String title = "Buck Test " + target;
    buckModule.attach(target);
    final BuckBuildCommandHandler handler = new BuckBuildCommandHandler(mProject, mProject.getBaseDir(), BuckCommand.TEST, /* doStartNotify */
    false) {

        @Override
        protected void notifyLines(Key outputType, Iterable<String> lines) {
            super.notifyLines(outputType, lines);
            if (outputType != ProcessOutputTypes.STDERR) {
                return;
            }
            for (String line : lines) {
                final Matcher matcher = DEBUG_SUSPEND_PATTERN.matcher(line);
                if (matcher.find()) {
                    final String port = matcher.group(1);
                    attachDebugger(title, port);
                }
            }
        }
    };
    if (!target.isEmpty()) {
        handler.command().addParameter(target);
    }
    if (!testSelectors.isEmpty()) {
        handler.command().addParameter("--test-selectors");
        handler.command().addParameter(testSelectors);
    }
    if (!additionalParams.isEmpty()) {
        for (String param : additionalParams.split("\\s")) {
            handler.command().addParameter(param);
        }
    }
    if (executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
        handler.command().addParameter("--debug");
    }
    handler.start();
    final OSProcessHandler result = handler.getHandler();
    showProgress(result, title);
    return result;
}
Also used : BuckModule(com.facebook.buck.intellij.ideabuck.config.BuckModule) Matcher(java.util.regex.Matcher) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) BuckBuildCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler) Key(com.intellij.openapi.util.Key)

Example 9 with BuckModule

use of com.facebook.buck.intellij.ideabuck.config.BuckModule 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)

Aggregations

BuckModule (com.facebook.buck.intellij.ideabuck.config.BuckModule)9 Project (com.intellij.openapi.project.Project)7 BuckBuildCommandHandler (com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler)6 BuckBuildManager (com.facebook.buck.intellij.ideabuck.build.BuckBuildManager)5 Matcher (java.util.regex.Matcher)2 BuckKillCommandHandler (com.facebook.buck.intellij.ideabuck.build.BuckKillCommandHandler)1 BuckSettingsProvider (com.facebook.buck.intellij.ideabuck.config.BuckSettingsProvider)1 ExecutionException (com.intellij.execution.ExecutionException)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Key (com.intellij.openapi.util.Key)1 IOException (java.io.IOException)1 JComponent (javax.swing.JComponent)1