void (final String objectName) { final PsiStatement exitStatementCopy = myExtractProcessor.myFirstExitStatementCopy; if (exitStatementCopy != null) { myExtractProcessor.myDuplicates = new ArrayList<>(); final Map<String, PsiVariable> outVarsNames = new HashMap<>(); for (PsiVariable variable : myOutputVariables) { outVarsNames.put(variable.getName(), variable); } final Map<PsiElement, PsiElement> replaceMap = new HashMap<>(); exitStatementCopy.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) { super.visitReferenceExpression(expression); if (expression.resolve() == null) { final PsiVariable variable = outVarsNames.get(expression.getReferenceName()); if (variable != null) { final String call2Getter = objectName + "." + GenerateMembersUtil.suggestGetterName(getPureName(variable), variable.getType(), myProject) + "()"; final PsiExpression callToGetter = myElementFactory.createExpressionFromText(call2Getter, variable); replaceMap.put(expression, callToGetter); } } } }); for (PsiElement element : replaceMap.keySet()) { if (element.isValid()) { element.replace(replaceMap.get(element)); } } } }