JavaClassReference (final PsiFile file, final int offset) { PsiReference reference = file.findReferenceAt(offset); if (reference instanceof PsiMultiReference) { for (final PsiReference psiReference : ((PsiMultiReference)reference).getReferences()) { if (psiReference instanceof JavaClassReference) { return (JavaClassReference)psiReference; } } } return reference instanceof JavaClassReference ? (JavaClassReference)reference : null; }