void (@NotNull PsiElement psiElement, @NotNull Map<? super Integer, ? super PsiReference> refMap, @NotNull Map<PsiFile, PsiFile> filesMap, @NotNull PsiFile psiFile) { PsiReference ref = psiElement.getReference(); if(ref instanceof PsiJavaCodeReferenceElement) { PsiElement refElement = ref.resolve(); if(refElement instanceof PsiClass) { PsiFile containingFile = refElement.getContainingFile(); if(!containingFile.equals(psiFile) && filesMap.get(containingFile) != null) { refMap.put(psiElement.getTextRange().getStartOffset(), ref); } return; } } PsiElement[] children = psiElement.getChildren(); for (PsiElement aChildren : children) { findClassReferences(aChildren, refMap, filesMap, psiFile); } }