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;
}
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);
}
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));
}
Aggregations