void () { try { //forget about smart pointers Map<PsiElement, String> variableRenames = new HashMap<>(); for (Map.Entry<SmartPsiElementPointer<?>, String> entry : myVariablesRenames.entrySet()) { variableRenames.put(entry.getKey().getElement(), entry.getValue()); } for (UsageInfo usage : myVariablesUsages) { if (usage instanceof MoveRenameUsageInfo renameUsageInfo) { final String newName = variableRenames.get(renameUsageInfo.getUpToDateReferencedElement()); final PsiReference reference = renameUsageInfo.getReference(); if (reference != null) { reference.handleElementRename(newName); } } } for (Map.Entry<SmartPsiElementPointer<?>, String> entry : myVariablesRenames.entrySet()) { String newName = entry.getValue(); if (newName != null) { final PsiVariable variable = (PsiVariable)entry.getKey().getElement(); variable.setName(newName); } } } catch (IncorrectOperationException e) { LOG.error(e); } }