void (PsiLocalVariable variable, String boxName) { List<PsiReferenceExpression> references = findReferences(variable); PsiElementFactory factory = JavaPsiFacade.getElementFactory(variable.getProject()); PsiExpression expr = factory.createExpressionFromText(boxName + "." + variable.getName(), null); for (PsiReferenceExpression reference : references) { reference.replace(expr); } }