public static boolean containsRangeInElement(@NotNull PsiReference ref, @NotNull TextRange rangeInElement) {
    if (ref instanceof MultiRangeReference) {
      for (TextRange range : ((MultiRangeReference)ref).getRanges()) {
        if (range.contains(rangeInElement)) return true;
      }

      return false;
    }
    return ref.getRangeInElement().contains(rangeInElement);
  }
public static boolean containsRangeInElement(@NotNull PsiReference ref, @NotNull TextRange rangeInElement)