void (@NotNull final ReferencesSearch.SearchParameters p, @NotNull final Processor<? super PsiReference> consumer) { final PsiElement element = p.getElementToSearch(); if (!element.isValid()) return; final SearchScope scope = p.getEffectiveSearchScope(); if (!(scope instanceof GlobalSearchScope)) return; if (element instanceof PsiClass aClass) { final String jvmClassName = ClassUtil.getJVMClassName(aClass); if (jvmClassName == null) return; final PsiFile[] files = FilenameIndex.getFilesByName(aClass.getProject(), jvmClassName, (GlobalSearchScope)scope); for (PsiFile file : files) { if (file.getLanguage() == SPILanguage.INSTANCE) { final PsiReference reference = file.getReference(); if (reference != null) { consumer.process(reference); } } } } else if (element instanceof PsiPackage) { final String qualifiedName = ((PsiPackage)element).getQualifiedName(); final Project project = element.getProject(); final String[] filenames = FilenameIndex.getAllFilenames(project); for (final String filename : filenames) { if (filename.startsWith(qualifiedName + ".")) { final PsiFile[] files = FilenameIndex.getFilesByName(project, filename, (GlobalSearchScope)scope); for (PsiFile file : files) { if (file.getLanguage() == SPILanguage.INSTANCE) { final PsiReference[] references = file.getReferences(); for (final PsiReference reference : references) { if (reference.getCanonicalText().equals(qualifiedName)) { consumer.process(reference); } } } } } } } }