public static PsiElement[] collectVariableUsages(GrVariable variable, PsiElement scope) {
    final List<PsiElement> list = Collections.synchronizedList(new ArrayList<>());
    if (scope instanceof GroovyScriptClass) {
      scope = scope.getContainingFile();
    }
    ReferencesSearch.search(variable, new LocalSearchScope(scope)).forEach(psiReference -> {
      final PsiElement element = psiReference.getElement();
      list.add(element);
      return true;
    });
    return list.toArray(PsiElement.EMPTY_ARRAY);
  }
public static PsiElement[] collectVariableUsages(GrVariable variable, PsiElement scope)