PsiCall (PsiJavaCodeReferenceElement ref) { PsiElement parent = ref.getParent(); if (ref instanceof PsiReferenceExpression && parent instanceof PsiMethodCallExpression) return (PsiCall)parent; if (parent instanceof PsiAnonymousClass) { parent = parent.getParent(); } return parent instanceof PsiNewExpression ? (PsiNewExpression)parent : null; }