void (PsiElement element, String newName, GroovyPsiElement place, CollidingVariableVisitor visitor) { final GrReferenceExpression refExpr = GroovyPsiElementFactory.getInstance(place.getProject()).createReferenceExpressionFromText(newName, place); final GroovyResolveResult[] results = refExpr.multiResolve(false); for (GroovyResolveResult result : results) { final PsiElement resolved = result.getElement(); if (resolved instanceof GrParameter || (resolved instanceof GrVariable && !(resolved instanceof GrField))) { final PsiElement parent = PsiTreeUtil.findCommonParent(resolved, element); if (parent != null) { PsiElement current = element; while (current != null && current != parent) { if (current instanceof PsiMethod || current instanceof PsiClass || current instanceof GrClosableBlock) { return; } current = current.getParent(); } } if (!place.getManager().areElementsEquivalent(element, resolved)) { visitor.visitCollidingVariable((PsiVariable)resolved); } } } }