PsiJavaCodeReferenceElement (@NotNull PsiClass aClass) { String text; if (aClass instanceof PsiAnonymousClass) { text = ((PsiAnonymousClass)aClass).getBaseClassType().getPresentableText(); } else { text = aClass.getName(); } if (text == null) { throw new IncorrectOperationException("Invalid class: " + aClass); } return new LightClassReference(myManager, text, aClass); }