public static @NotNull List<TextRange> getRanges(@NotNull PsiReference ref) {
    if (ref instanceof MultiRangeReference) {
      return ((MultiRangeReference)ref).getRanges();
    }
    return Collections.singletonList(ref.getRangeInElement());
  }
public static @NotNull List<TextRange> getRanges(@NotNull PsiReference ref)