PsiElement (@NotNull GrVariable field, @NotNull PsiElement occurrence, @NotNull PsiClass containingClass) { boolean isOriginal = occurrence == myContext.getExpression(); final GrReferenceExpression newExpr = createRefExpression(field, occurrence, containingClass); final PsiElement replaced; if (occurrence instanceof GrExpression) { replaced = ((GrExpression)occurrence).replaceWithExpression(newExpr, false); } else { replaced = occurrence.replace(newExpr); } if (replaced instanceof GrQualifiedReference<?>) { GrReferenceAdjuster.shortenReference((GrQualifiedReference<?>)replaced); } if (isOriginal) { updateCaretPosition(replaced); } return replaced; }