PsiElement (PsiElement element) { final PsiElement context = PsiTreeUtil.getParentOfType(element, PsiMember.class, PsiLambdaExpression.class); if (context instanceof PsiField) { return ((PsiField)context).getInitializer(); } else if (context instanceof PsiClassInitializer) { return ((PsiClassInitializer)context).getBody(); } else if (context instanceof PsiMethod) { return ((PsiMethod)context).getBody(); } else if (context instanceof PsiLambdaExpression) { return ((PsiLambdaExpression)context).getBody(); } return null; }