PsiElement (@Nullable PsiElement element) { if (element == null) return null; final GrParameterList parameterList = PsiTreeUtil.getParentOfType(element, GrParameterList.class); if (parameterList != null) { final PsiElement parent = parameterList.getParent(); if (parent instanceof PsiMethod) return parent; } if (element.getParent() instanceof GrMethod && ((GrMethod)element.getParent()).getNameIdentifierGroovy() == element) { return element.getParent(); } final GrCall expression = PsiTreeUtil.getParentOfType(element, GrCall.class); if (expression != null) { return expression.resolveMethod(); } final PsiReference ref = element.getReference(); if (ref == null) return null; return ref.resolve(); }