void (UsageInfo usage, PsiElement referenced, GrExpression initializer) { if (initializer == null) return; GrExpression exprToBeReplaced = (GrExpression)usage.getElement(); if (exprToBeReplaced == null) return; if ((referenced instanceof GrAccessorMethod || referenced instanceof GrField) && exprToBeReplaced instanceof GrReferenceExpression) { final GroovyResolveResult resolveResult = ((GrReferenceExpression)exprToBeReplaced).advancedResolve(); if (resolveResult.getElement() instanceof GrAccessorMethod && !resolveResult.isInvokedOnProperty()) { final PsiElement parent = exprToBeReplaced.getParent(); if (parent instanceof GrCall && parent instanceof GrExpression) { exprToBeReplaced = (GrExpression)parent; } else { return; } } } GrExpression newExpr = exprToBeReplaced.replaceWithExpression((GrExpression)initializer.copy(), true); final Project project = usage.getProject(); JavaCodeStyleManager.getInstance(project).shortenClassReferences(newExpr); Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); GroovyRefactoringUtil.highlightOccurrences(project, editor, new PsiElement[]{newExpr}); WindowManager.getInstance().getStatusBar(project).setInfo(GroovyRefactoringBundle.message("press.escape.to.remove.the.highlighting")); }