use of com.android.tools.idea.run.ValidationError in project intellij by bazelbuild.
the class BlazeAndroidBinaryRunConfigurationHandler method validate.
/**
* We collect errors rather than throwing to avoid missing fatal errors by exiting early for a
* warning. We use a separate method for the collection so the compiler prevents us from
* accidentally throwing.
*/
private List<ValidationError> validate() {
List<ValidationError> errors = Lists.newArrayList();
Module module = getModule();
errors.addAll(BlazeAndroidRunConfigurationValidationUtil.validateModule(module));
AndroidFacet facet = null;
if (module != null) {
facet = AndroidFacet.getInstance(module);
errors.addAll(BlazeAndroidRunConfigurationValidationUtil.validateFacet(facet, module));
}
errors.addAll(configState.validate(facet));
errors.addAll(BlazeAndroidRunConfigurationValidationUtil.validateLabel(getLabel(), configuration.getProject(), ImmutableList.of(Kind.ANDROID_BINARY)));
return errors;
}
use of com.android.tools.idea.run.ValidationError in project intellij by bazelbuild.
the class BlazeAndroidRunConfigurationValidationUtil method validateModule.
public static List<ValidationError> validateModule(@Nullable Module module) {
List<ValidationError> errors = Lists.newArrayList();
if (module == null) {
errors.add(ValidationError.fatal("No run configuration module found. Have you successfully synced your project?"));
return errors;
}
final Project project = module.getProject();
if (AndroidProjectInfo.getInstance(project).requiredAndroidModelMissing()) {
errors.add(ValidationError.fatal(SYNC_FAILED_ERR_MSG));
}
return errors;
}
use of com.android.tools.idea.run.ValidationError in project intellij by bazelbuild.
the class BlazeAndroidRunConfigurationValidationUtil method validateExecution.
public static void validateExecution(@Nullable Module module, @Nullable AndroidFacet facet, @Nullable ProjectViewSet projectViewSet) throws ExecutionException {
List<ValidationError> errors = Lists.newArrayList();
errors.addAll(validateModule(module));
if (module != null) {
errors.addAll(validateFacet(facet, module));
}
if (projectViewSet == null) {
errors.add(ValidationError.fatal("Could not load project view. Please resync project"));
}
if (errors.isEmpty()) {
return;
}
ValidationError topError = Ordering.natural().max(errors);
if (topError.isFatal()) {
throw new ExecutionException(topError.getMessage());
}
}
use of com.android.tools.idea.run.ValidationError in project intellij by bazelbuild.
the class BlazeAndroidTestRunConfigurationHandler method validate.
/**
* We collect errors rather than throwing to avoid missing fatal errors by exiting early for a
* warning. We use a separate method for the collection so the compiler prevents us from
* accidentally throwing.
*/
private List<ValidationError> validate() {
List<ValidationError> errors = Lists.newArrayList();
Module module = getModule();
errors.addAll(BlazeAndroidRunConfigurationValidationUtil.validateModule(module));
AndroidFacet facet = null;
if (module != null) {
facet = AndroidFacet.getInstance(module);
errors.addAll(BlazeAndroidRunConfigurationValidationUtil.validateFacet(facet, module));
}
errors.addAll(configState.validate(facet));
errors.addAll(BlazeAndroidRunConfigurationValidationUtil.validateLabel(getLabel(), configuration.getProject(), ImmutableList.of(Kind.ANDROID_TEST, Kind.ANDROID_INSTRUMENTATION_TEST)));
return errors;
}
use of com.android.tools.idea.run.ValidationError in project intellij by bazelbuild.
the class BlazeAndroidRunConfigurationValidationUtil method validateLabel.
public static List<ValidationError> validateLabel(@Nullable Label label, Project project, ImmutableList<Kind> kinds) {
List<ValidationError> errors = Lists.newArrayList();
if (label == null) {
errors.add(ValidationError.fatal("No target selected."));
return errors;
}
TargetInfo target = TargetFinder.findTargetInfo(project, label);
if (target == null) {
errors.add(ValidationError.fatal(String.format("No existing %s rule selected.", Blaze.buildSystemName(project))));
} else if (target.getKind() == null || !target.getKind().isOneOf(kinds)) {
errors.add(ValidationError.fatal(String.format("Selected %s rule is not one of: %s", Blaze.buildSystemName(project), kinds.stream().map(Kind::toString).collect(Collectors.joining(", ")))));
}
return errors;
}
Aggregations