PsiClass (@NotNull PsiElement entry) { PsiClass result = null; PsiElement parent; PsiElement element; for (element = entry; element != null && !(element instanceof PsiFile); element = parent) { result = myInsideConstructorOfClassCache.get(entry); if (result != null || myInsideConstructorOfClassCache.containsKey(entry)) { return result; } parent = element.getParent(); if (parent instanceof PsiExpressionStatement) { PsiElement p2 = parent.getParent(); if (p2 instanceof PsiCodeBlock) { PsiElement p3 = p2.getParent(); if (p3 instanceof PsiMethod && ((PsiMethod)p3).isConstructor()) { PsiElement p4 = p3.getParent(); if (p4 instanceof PsiClass) { result = (PsiClass)p4; } } } } if (result != null) { break; } } for (PsiElement e = entry; e != null && !(e instanceof PsiFile); e = e.getParent()) { myInsideConstructorOfClassCache.put(e, result); if (e == element) break; } return result; }