Search in sources :

Example 41 with BlazeCommandRunConfiguration

use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration in project intellij by bazelbuild.

the class HotSwapUtils method canHotSwap.

public static boolean canHotSwap(ExecutionEnvironment env) {
    if (!isDebugging(env) || !enableHotSwapping.getValue()) {
        return false;
    }
    BlazeCommandRunConfiguration configuration = getConfiguration(env);
    BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
    Kind kind = configuration.getTargetKind();
    return BlazeCommandName.RUN.equals(Preconditions.checkNotNull(handlerState).getCommandState().getCommand()) && kind != null && kind.isOneOf(SUPPORTED_BINARIES);
}
Also used : BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) Kind(com.google.idea.blaze.base.model.primitives.Kind) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)

Example 42 with BlazeCommandRunConfiguration

use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration in project intellij by bazelbuild.

the class BlazeHotSwapManager method findHotSwappableBlazeDebuggerSession.

@Nullable
static HotSwappableDebugSession findHotSwappableBlazeDebuggerSession(Project project) {
    DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
    DebuggerSession session = debuggerManager.getContext().getDebuggerSession();
    if (session == null || !session.isAttached()) {
        return null;
    }
    JavaDebugProcess process = session.getProcess().getXdebugProcess();
    if (process == null) {
        return null;
    }
    ExecutionEnvironment env = ((XDebugSessionImpl) process.getSession()).getExecutionEnvironment();
    if (env == null || ClassFileManifestBuilder.getManifest(env) == null) {
        return null;
    }
    RunProfile runProfile = env.getRunProfile();
    if (!(runProfile instanceof BlazeCommandRunConfiguration)) {
        return null;
    }
    return new HotSwappableDebugSession(session, env, (BlazeCommandRunConfiguration) runProfile);
}
Also used : DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) JavaDebugProcess(com.intellij.debugger.engine.JavaDebugProcess) RunProfile(com.intellij.execution.configurations.RunProfile) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl) Nullable(javax.annotation.Nullable)

Example 43 with BlazeCommandRunConfiguration

use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration in project intellij by bazelbuild.

the class BlazeAndroidTestProgramRunner method canRun.

@Override
public boolean canRun(String executorId, RunProfile profile) {
    BlazeAndroidRunConfigurationHandler handler = BlazeAndroidRunConfigurationHandler.getHandlerFrom(profile);
    if (!(handler instanceof BlazeAndroidTestRunConfigurationHandler)) {
        return false;
    }
    if (!(profile instanceof BlazeCommandRunConfiguration)) {
        return false;
    }
    BlazeCommandRunConfiguration configuration = (BlazeCommandRunConfiguration) profile;
    // Debugging android_instrumentation_test doesn't work yet.
    if (DefaultDebugExecutor.EXECUTOR_ID.equals(executorId)) {
        return configuration.getTargetKind() != Kind.ANDROID_INSTRUMENTATION_TEST;
    }
    return DefaultRunExecutor.EXECUTOR_ID.equals(executorId);
}
Also used : BlazeAndroidRunConfigurationHandler(com.google.idea.blaze.android.run.BlazeAndroidRunConfigurationHandler) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)

Example 44 with BlazeCommandRunConfiguration

use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration in project intellij by bazelbuild.

the class BlazeAndroidBinaryRunConfigurationHandler method doMigrate.

private int doMigrate(Project project) {
    int count = 0;
    for (RunConfiguration runConfig : RunManager.getInstance(project).getConfigurationsList(BlazeCommandRunConfigurationType.getInstance())) {
        if (runConfig instanceof BlazeCommandRunConfiguration) {
            RunConfigurationState state = ((BlazeCommandRunConfiguration) runConfig).getHandler().getState();
            if (state instanceof BlazeAndroidBinaryRunConfigurationState) {
                ((BlazeAndroidBinaryRunConfigurationState) state).setLaunchMethod(AndroidBinaryLaunchMethod.MOBILE_INSTALL);
                count++;
            }
        }
    }
    return count;
}
Also used : RunConfigurationState(com.google.idea.blaze.base.run.state.RunConfigurationState) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)

Example 45 with BlazeCommandRunConfiguration

use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration in project intellij by bazelbuild.

the class RunConfigurationSerializerTest method testSetKeepInSyncWhenImporting.

@Test
public void testSetKeepInSyncWhenImporting() throws InvalidDataException {
    configuration.setTarget(Label.create("//package:rule"));
    configuration.setKeepInSync(false);
    Element element = RunConfigurationSerializer.writeToXml(configuration);
    assertThat(RunConfigurationSerializer.findExisting(getProject(), element)).isNotNull();
    // remove configuration from project
    clearRunManager();
    RunConfigurationSerializer.loadFromXmlElementIgnoreExisting(getProject(), element);
    RunConfiguration config = runManager.getAllConfigurations()[0];
    assertThat(config).isInstanceOf(BlazeCommandRunConfiguration.class);
    assertThat(((BlazeCommandRunConfiguration) config).getKeepInSync()).isTrue();
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Element(org.jdom.Element) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Test(org.junit.Test)

Aggregations

BlazeCommandRunConfiguration (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)52 Test (org.junit.Test)36 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)33 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)29 PsiFile (com.intellij.psi.PsiFile)26 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)24 MockBlazeProjectDataBuilder (com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder)23 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)23 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)9 BlazeCommandRunConfigurationCommonState (com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState)8 PsiClass (com.intellij.psi.PsiClass)8 PsiMethod (com.intellij.psi.PsiMethod)5 StringLiteral (com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral)4 PsiDirectory (com.intellij.psi.PsiDirectory)4 Nullable (javax.annotation.Nullable)4 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)3 BlazeBuildFileRunConfigurationProducer (com.google.idea.blaze.base.run.producers.BlazeBuildFileRunConfigurationProducer)3 File (java.io.File)3 ScalaFile (org.jetbrains.plugins.scala.lang.psi.api.ScalaFile)3 BlazeCommandName (com.google.idea.blaze.base.command.BlazeCommandName)2