private static boolean collectOwnerOccurrences(final Project project,
                                                 final GrParameterListOwner owner,
                                                 final Collection<PsiElement> occurrences) {
    final PsiElement namedElem = getReferencedElement(owner);
    if (namedElem == null) return true;
    final Ref<Boolean> result = new Ref<>(true);
    final Task task = new Task.Modal(
      project,
      owner instanceof GrClosableBlock ? GroovyBundle.message("find.method.ro.closure.usages")
                                       : GroovyBundle.message("find.method.ro.method.usages"),
      true
    ) {
      @Override
      public void run(@NotNull final ProgressIndicator indicator) {
        final Collection<PsiReference> references = Collections.synchronizedSet(new HashSet<>());
        final Processor<PsiReference> consumer = psiReference -> {
          references.add(psiReference);
          return true;
        };
        ReferencesSearch.search(namedElem).forEach(consumer);
        boolean isProperty =
          ReadAction.compute(() -> namedElem instanceof GrField && ((GrField)namedElem).isProperty());
        if (isProperty) {
          final GrAccessorMethod[] getters = ReadAction.compute(() -> ((GrField)namedElem).getGetters());
          for (GrAccessorMethod getter : getters) {
            MethodReferencesSearch.search(getter).forEach(consumer);
          }
        }
        for (final PsiReference reference : references) {
          ApplicationManager.getApplication().runReadAction(() -> {
            final PsiElement element = reference.getElement();
            occurrences.add(element);
          });
        }
      }

      @Override
      public void onCancel() {
        result.set(false);
      }

      @Override
      public void onThrowable(@NotNull Throwable error) {
        super.onThrowable(error);
        result.set(false);
      }

      @Override
      public void onSuccess() {
        result.set(true);
      }
    };
    ProgressManager.getInstance().run(task);
    return result.get().booleanValue();
  }
private static boolean collectOwnerOccurrences(final Project project,
                                                 final GrParameterListOwner owner,
                                                 final Collection<PsiElement> occurrences)