PsiClass () { final PsiClass delegate = getUserData(DELEGATE_KEY); if (delegate instanceof ClsClassImpl) { return ((ClsClassImpl)delegate).getSourceMirrorClass(); } final String name = getName(); final PsiElement parent = getParent(); if (parent instanceof PsiFile) { if (!(parent instanceof PsiClassOwner)) return null; PsiClassOwner fileNavigationElement = (PsiClassOwner)parent.getNavigationElement(); if (fileNavigationElement == parent) return null; for (PsiClass aClass : fileNavigationElement.getClasses()) { if (name.equals(aClass.getName())) return aClass; } } else if (parent != null) { ClsClassImpl parentClass = (ClsClassImpl)parent; PsiClass parentSourceMirror = parentClass.getSourceMirrorClass(); if (parentSourceMirror == null) return null; PsiClass[] innerClasses = parentSourceMirror.getInnerClasses(); for (PsiClass innerClass : innerClasses) { if (name.equals(innerClass.getName())) return innerClass; } } else { throw new PsiInvalidElementAccessException(this); } return null; }