@Override
  public @NotNull <R extends BuildRootDescriptor> List<R> getRootDescriptors(@NotNull File root,
                                                                             @Nullable Collection<? extends BuildTargetType<? extends BuildTarget<R>>> types,
                                                                             @Nullable CompileContext context) {
    List<BuildRootDescriptor> descriptors = myRootToDescriptors.get(root);
    List<R> result = new SmartList<>();
    if (descriptors != null) {
      for (BuildRootDescriptor descriptor : descriptors) {
        if (types == null || types.contains(descriptor.getTarget().getTargetType())) {
          //noinspection unchecked
          result.add((R)descriptor);
        }
      }
    }
    if (context != null) {
      final Map<File, BuildRootDescriptor> contextMap = ROOT_DESCRIPTOR_MAP.get(context);
      if (contextMap != null) {
        BuildRootDescriptor descriptor = contextMap.get(root);
        if (descriptor != null && (types == null || types.contains(descriptor.getTarget().getTargetType()))) {
          //noinspection unchecked
          result.add((R)descriptor);
        }
      }
    }
    return result;
  }
@Override
  public @NotNull <R extends BuildRootDescriptor> List<R> getRootDescriptors(@NotNull File root,
                                                                             @Nullable Collection<? extends BuildTargetType<? extends BuildTarget<R>>> types,
                                                                             @Nullable CompileContext context)