private static @Nullable Object buildServiceModel(
    @NotNull String modelName,
    @NotNull Project project,
    @NotNull ModelBuilderContext context,
    @NotNull ModelBuilderService service,
    @Nullable ModelBuilderService.Parameter parameter
  ) {
    final long startTime = System.currentTimeMillis();
    try {
      if (service instanceof ModelBuilderService.ParameterizedModelBuilderService) {
        return ((ModelBuilderService.ParameterizedModelBuilderService)service)
          .buildAll(modelName, project, context, parameter);
      }
      if (service instanceof ModelBuilderService.Ex) {
        return ((ModelBuilderService.Ex)service).buildAll(modelName, project, context);
      }
      else {
        return service.buildAll(modelName, project);
      }
    }
    catch (Exception exception) {
      reportErrorMessage(modelName, project, context, service, exception);
      return null;
    }
    finally {
      if (Boolean.getBoolean("idea.gradle.custom.tooling.perf")) {
        final long timeInMs = (System.currentTimeMillis() - startTime);
        reportPerformanceStatistic(project, service, modelName, timeInMs);
      }
    }
  }
private static @Nullable Object buildServiceModel(
    @NotNull String modelName,
    @NotNull Project project,
    @NotNull ModelBuilderContext context,
    @NotNull ModelBuilderService service,
    @Nullable ModelBuilderService.Parameter parameter
  )