PsiMethod (final PsiReference ref) { assertThat(ref, instanceOf(PsiReferenceExpression.class)); final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; final PsiElement parent = refExpr.getParent(); assertThat(parent, instanceOf(PsiMethodCallExpression.class)); final PsiMethodCallExpression expression = (PsiMethodCallExpression)parent; final PsiMethod method = expression.resolveMethod(); assertNotNull(method); return method; }