PsiElement (PsiElement element, boolean allowMethodCalls) { PsiElement parent = element.getParent(); if (parent instanceof GrVariable && element == ((GrVariable)parent).getNameIdentifierGroovy()) { return element; } else if (parent instanceof GrReferenceExpression) { final PsiElement pparent = parent.getParent(); if (pparent instanceof GrCall) { parent = pparent; } if (allowMethodCalls || !GroovyRefactoringUtil.hasSideEffect((GroovyPsiElement)parent)) { return parent; } } return null; }