private static void addReferences(int offset,
                                    @NotNull PsiElement element,
                                    @NotNull final Collection<PsiReference> outReferences,
                                    @NotNull PyResolveContext resolveContext) {
    final PsiReference[] references;
    if (element instanceof PyReferenceOwner owner) {
      final PsiPolyVariantReference reference = owner.getReference(resolveContext);
      references = new PsiReference[]{reference};
    }
    else {
      references = element.getReferences();
    }
    for (final PsiReference reference : references) {
      for (TextRange range : ReferenceRange.getRanges(reference)) {
        assert range != null : reference;
        if (range.containsOffset(offset)) {
          outReferences.add(reference);
        }
      }
    }
  }
private static void addReferences(int offset,
                                    @NotNull PsiElement element,
                                    @NotNull final Collection<PsiReference> outReferences,
                                    @NotNull PyResolveContext resolveContext)