Set<PsiPackage> () { if (myIndex == 0) return myReferenceSet.getInitialContext(); Set<PsiPackage> psiPackages = new HashSet<>(); for (ResolveResult resolveResult : myReferenceSet.getReference(myIndex - 1).doMultiResolve()) { PsiElement psiElement = resolveResult.getElement(); if (psiElement instanceof PsiPackage) { psiPackages.add((PsiPackage)psiElement); } } return psiPackages; }