code: public boolean refactorVariable(SymbolDefinition n, final String newName) {
          Map<String, SymbolDefinition> scope = n.getVariableDefinitions();
  
          if (!scope.containsKey(newName)) {
  
              if (n.getUsages() != null) {
                  List<SymbolReference> usages = new LinkedList<SymbolReference>(n.getUsages());
  
                  VoidVisitorAdapter<?> visitor = new VoidVisitorAdapter<Object>() {
                      @Override
                      public void visit(NameExpr nexpr, Object ctx) {
                          Map<String, SymbolDefinition> innerScope = nexpr.getVariableDefinitions();
                          if (innerScope.containsKey(newName)) {
                              nexpr.getParentNode().replaceChildNode(nexpr, new FieldAccessExpr(new ThisExpr(), newName));
                          } else {
                              nexpr.getParentNode().replaceChildNode(nexpr, new NameExpr(newName));
                          }
                      }
  
                      @Override
                      public void visit(FieldAccessExpr nexpr, Object ctx) {
                          nexpr.getParentNode().replaceChildNode(nexpr,
                                  new FieldAccessExpr(nexpr.getScope(), nexpr.getTypeArgs(), newName));
                      }
                  };
  
                  for (SymbolReference usage : usages) {
                      Node aux = (Node) usage;
  
                      aux.accept(visitor, null);
  
                  }
              }
  
              return true;
          }
          return false;
      }
docs: Generic method to rename a SymbolDefinition variable/parameter.
  @param n variable to rename.
  @param newName new name to set.
  @return if the rename procedure has been applied successfully.