com.intellij.refactoring.move.moveFilesOrDirectories.MoveFileHandler Java Examples

The following examples show how to use com.intellij.refactoring.move.moveFilesOrDirectories.MoveFileHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CSharpClassesMoveProcessor.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
private static void processDirectoryFiles(List<PsiFile> movedFiles, Map<PsiElement, PsiElement> oldToNewMap, PsiElement psiElement)
{
	if(psiElement instanceof PsiFile)
	{
		final PsiFile movedFile = (PsiFile) psiElement;
		MoveFileHandler.forElement(movedFile).prepareMovedFile(movedFile, movedFile.getParent(), oldToNewMap);
		movedFiles.add(movedFile);
	}
	else if(psiElement instanceof PsiDirectory)
	{
		for(PsiElement element : psiElement.getChildren())
		{
			processDirectoryFiles(movedFiles, oldToNewMap, element);
		}
	}
}
 
Example #2
Source File: MoveDirectoryWithClassesHelper.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean move(PsiFile psiFile,
                       PsiDirectory moveDestination,
                       Map<PsiElement, PsiElement> oldToNewElementsMapping,
                       List<PsiFile> movedFiles,
                       RefactoringElementListener listener) {
  if (moveDestination.equals(psiFile.getContainingDirectory())) {
    return false;
  }

  MoveFileHandler.forElement(psiFile).prepareMovedFile(psiFile, moveDestination, oldToNewElementsMapping);

  PsiFile moving = moveDestination.findFile(psiFile.getName());
  if (moving == null) {
    MoveFilesOrDirectoriesUtil.doMoveFile(psiFile, moveDestination);
  }
  moving = moveDestination.findFile(psiFile.getName());
  movedFiles.add(moving);
  listener.elementMoved(psiFile);
  return true;
}