PsiJavaCodeReferenceElement () { PsiJavaCodeReferenceElement result = retrieveReference(); if (result == null) { PsiType type = calcTypeByParent(); if (!(type instanceof PsiClassReferenceType)) { PsiUtilCore.ensureValid(parent); throw new IllegalStateException("No reference type for " + parent.getClass() + "; type: " + (type != null ? type.getClass() : "null")); } result = findReferenceByIndex((PsiClassReferenceType)type); if (result == null) { PsiUtilCore.ensureValid(parent); throw new RuntimeExceptionWithAttachments("Can't retrieve reference by index " + index + " for " + parent.getClass() + "; type: " + type.getClass(), new Attachment("memberType.txt", type.getCanonicalText())); } } return result; }