Search in sources :

Example 1 with BlazeAndroidRunConfigurationHandler

use of com.google.idea.blaze.android.run.BlazeAndroidRunConfigurationHandler in project intellij by bazelbuild.

the class BlazeAndroidProjectStructureSyncer method getRunConfigurationTargets.

// Collect potential android run configuration targets
private static List<TargetIdeInfo> getRunConfigurationTargets(Project project, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData, Set<TargetKey> androidResourceModules) {
    List<TargetIdeInfo> result = Lists.newArrayList();
    Set<Label> runConfigurationModuleTargets = Sets.newHashSet();
    // Doing this now will cut down on root changes later
    for (TargetExpression targetExpression : projectViewSet.listItems(TargetSection.KEY)) {
        if (!(targetExpression instanceof Label)) {
            continue;
        }
        Label label = (Label) targetExpression;
        runConfigurationModuleTargets.add(label);
    }
    // Get any pre-existing targets
    for (RunConfiguration runConfiguration : RunManager.getInstance(project).getAllConfigurationsList()) {
        BlazeAndroidRunConfigurationHandler handler = BlazeAndroidRunConfigurationHandler.getHandlerFrom(runConfiguration);
        if (handler == null) {
            continue;
        }
        runConfigurationModuleTargets.add(handler.getLabel());
    }
    for (Label label : runConfigurationModuleTargets) {
        TargetKey targetKey = TargetKey.forPlainTarget(label);
        // If it's a resource module, it will already have been created
        if (androidResourceModules.contains(targetKey)) {
            continue;
        }
        // Ensure the label is a supported android rule that exists
        TargetIdeInfo target = blazeProjectData.targetMap.get(targetKey);
        if (target == null) {
            continue;
        }
        if (!target.kindIsOneOf(Kind.ANDROID_BINARY, Kind.ANDROID_TEST)) {
            continue;
        }
        result.add(target);
    }
    return result;
}
Also used : TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) BlazeAndroidRunConfigurationHandler(com.google.idea.blaze.android.run.BlazeAndroidRunConfigurationHandler) Label(com.google.idea.blaze.base.model.primitives.Label) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey)

Example 2 with BlazeAndroidRunConfigurationHandler

use of com.google.idea.blaze.android.run.BlazeAndroidRunConfigurationHandler 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 3 with BlazeAndroidRunConfigurationHandler

use of com.google.idea.blaze.android.run.BlazeAndroidRunConfigurationHandler in project intellij by bazelbuild.

the class BlazeAndroidBinaryProgramRunner method canRun.

@Override
public boolean canRun(String executorId, RunProfile profile) {
    BlazeAndroidRunConfigurationHandler handler = BlazeAndroidRunConfigurationHandler.getHandlerFrom(profile);
    if (!(handler instanceof BlazeAndroidBinaryRunConfigurationHandler)) {
        return false;
    }
    // In practice, the stock runner will probably handle all non-incremental-install configs.
    if (DefaultDebugExecutor.EXECUTOR_ID.equals(executorId) || DefaultRunExecutor.EXECUTOR_ID.equals(executorId)) {
        return true;
    }
    // Otherwise, the configuration must be a Blaze incremental install configuration running with
    // an incremental install executor.
    AndroidBinaryLaunchMethod launchMethod = ((BlazeAndroidBinaryRunConfigurationHandler) handler).getState().getLaunchMethod();
    return (AndroidBinaryLaunchMethod.MOBILE_INSTALL.equals(launchMethod) || AndroidBinaryLaunchMethod.MOBILE_INSTALL_V2.equals(launchMethod)) && (IncrementalInstallDebugExecutor.EXECUTOR_ID.equals(executorId) || IncrementalInstallRunExecutor.EXECUTOR_ID.equals(executorId));
}
Also used : BlazeAndroidRunConfigurationHandler(com.google.idea.blaze.android.run.BlazeAndroidRunConfigurationHandler) AndroidBinaryLaunchMethod(com.google.idea.blaze.android.run.binary.BlazeAndroidBinaryLaunchMethodsProvider.AndroidBinaryLaunchMethod)

Aggregations

BlazeAndroidRunConfigurationHandler (com.google.idea.blaze.android.run.BlazeAndroidRunConfigurationHandler)3 AndroidBinaryLaunchMethod (com.google.idea.blaze.android.run.binary.BlazeAndroidBinaryLaunchMethodsProvider.AndroidBinaryLaunchMethod)1 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)1 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)1 Label (com.google.idea.blaze.base.model.primitives.Label)1 TargetExpression (com.google.idea.blaze.base.model.primitives.TargetExpression)1 BlazeCommandRunConfiguration (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1