private void collectEdits(
     String newName,
     String oldName,
     List<Change> changes,
     PhasedUnit phasedUnit,
     Map<Declaration, String> imports) {
   try {
     Tree.CompilationUnit cu = phasedUnit.getCompilationUnit();
     if (!imports.isEmpty()) {
       IFileVirtualFile virtualFile = (IFileVirtualFile) phasedUnit.getUnitFile();
       IFile file = virtualFile.getFile();
       String path = file.getProjectRelativePath().toPortableString();
       TextFileChange change = fileChanges.get(path);
       if (change == null) {
         change = new TextFileChange(file.getName(), file);
         change.setEdit(new MultiTextEdit());
         changes.add(change);
         fileChanges.put(path, change);
       }
       List<TextEdit> edits =
           importEditForMove(
               cu,
               imports.keySet(),
               imports.values(),
               newName,
               oldName,
               EditorUtil.getDocument(change));
       if (!edits.isEmpty()) {
         for (TextEdit edit : edits) {
           change.addEdit(edit);
         }
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 private void collectEditsToMovedFile(
     String newName,
     String oldName,
     List<Change> changes,
     PhasedUnit movedPhasedUnit,
     Map<Declaration, String> imports) {
   try {
     IFileVirtualFile virtualFile = (IFileVirtualFile) movedPhasedUnit.getUnitFile();
     IFile file = virtualFile.getFile();
     String path = file.getProjectRelativePath().toPortableString();
     TextFileChange change = fileChanges.get(path);
     if (change == null) {
       change = new TextFileChange(file.getName(), file);
       change.setEdit(new MultiTextEdit());
       changes.add(change);
       fileChanges.put(path, change);
     }
     Tree.CompilationUnit cu = movedPhasedUnit.getCompilationUnit();
     if (!imports.isEmpty()) {
       List<InsertEdit> edits =
           importEdits(
               cu, imports.keySet(), imports.values(), null, EditorUtil.getDocument(change));
       for (TextEdit edit : edits) {
         change.addEdit(edit);
       }
     }
     Tree.Import toDelete = findImportNode(cu, newName);
     if (toDelete != null) {
       change.addEdit(
           new DeleteEdit(
               toDelete.getStartIndex(), toDelete.getStopIndex() - toDelete.getStartIndex() + 1));
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }