void (PsiReference reference, PsiElement position, Set<? super LookupElement> set, TailType tailType, ElementFilter filter, CompletionVariant variant) { if (reference instanceof PsiMultiReference) { for (PsiReference ref : getReferences((PsiMultiReference)reference)) { completeReference(ref, position, set, tailType, filter, variant); } } else if (reference instanceof PsiReferencesWrapper) { for (PsiReference ref : ((PsiReferencesWrapper)reference).getReferences()) { completeReference(ref, position, set, tailType, filter, variant); } } else{ final Object[] completions = reference.getVariants(); for (Object completion : completions) { if (completion == null) { LOG.error("Position=" + position + "\n;Reference=" + reference + "\n;variants=" + Arrays.toString(completions)); continue; } if (completion instanceof PsiElement psiElement) { if (filter.isClassAcceptable(psiElement.getClass()) && filter.isAcceptable(psiElement, position)) { addLookupItem(set, tailType, completion, variant); } } else { if (completion instanceof LookupItem) { final Object o = ((LookupItem<?>)completion).getObject(); if (o instanceof PsiElement) { if (!filter.isClassAcceptable(o.getClass()) || !filter.isAcceptable(o, position)) continue; } } try { addLookupItem(set, tailType, completion, variant); } catch (AssertionError e) { LOG.error("Caused by variant from reference: " + reference.getClass(), e); } } } } }