当前位置: 首页>>代码示例>>Java>>正文


Java CopyHandler.doCopy方法代码示例

本文整理汇总了Java中com.intellij.refactoring.copy.CopyHandler.doCopy方法的典型用法代码示例。如果您正苦于以下问题:Java CopyHandler.doCopy方法的具体用法?Java CopyHandler.doCopy怎么用?Java CopyHandler.doCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.refactoring.copy.CopyHandler的用法示例。


在下文中一共展示了CopyHandler.doCopy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMultipleClasses

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
public void testMultipleClasses() throws Exception {
  String rootBefore = getRoot();
  PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
  final VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
  final PsiClass aClass = myJavaFacade.findClass("pack1.Klass");
  assertNotNull(aClass);

  final PsiFile containingFile = aClass.getContainingFile();

  assertTrue(CopyHandler.canCopy(new PsiElement[]{containingFile}));
  assertFalse(CopyHandler.canClone(new PsiElement[]{containingFile}));

  PsiPackage pack2 = myJavaFacade.findPackage("pack2");
  final PsiDirectory targetDirectory = pack2.getDirectories()[0];
  CopyHandler.doCopy(new PsiElement[]{containingFile}, targetDirectory);

  VirtualFile fileAfter = root.findFileByRelativePath("pack2/Klass.java");
  VirtualFile fileExpected = root.findFileByRelativePath("pack2/Klass.expected.java");

  PlatformTestUtil.assertFilesEqual(fileExpected, fileAfter);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CopyTest.java

示例2: testMultipleFiles

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
public void testMultipleFiles() throws Exception {
  String rootBefore = getRoot();
  PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
  final VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);

  final VirtualFile first = root.findFileByRelativePath("from/1.txt");
  assertNotNull(first);
  final VirtualFile second = root.findFileByRelativePath("from/2.txt");
  assertNotNull(second);

  final PsiFile firstPsi = myPsiManager.findFile(first);
  final PsiFile secondPsi = myPsiManager.findFile(second);

  assertTrue(CopyHandler.canCopy(new PsiElement[]{firstPsi, secondPsi}));

  final VirtualFile toDir = root.findChild("to");
  assertNotNull(toDir);
  final PsiDirectory targetDirectory = myPsiManager.findDirectory(toDir);

  CopyHandler.doCopy(new PsiElement[]{firstPsi, secondPsi}, targetDirectory);

  assertNotNull(root.findFileByRelativePath("to/1.txt"));
  assertNotNull(root.findFileByRelativePath("to/2.txt"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CopyTest.java

示例3: doDrop

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
private void doDrop(TreeNode targetNode, PsiElement[] sourceElements) {
  final PsiElement targetElement = getPsiElement(targetNode);
  if (targetElement == null) return;
  final PsiDirectory psiDirectory;
  if (targetElement instanceof PsiDirectoryContainer) {
    final PsiDirectoryContainer directoryContainer = (PsiDirectoryContainer)targetElement;
    final PsiDirectory[] psiDirectories = directoryContainer.getDirectories();
    psiDirectory = psiDirectories.length != 0 ? psiDirectories[0] : null;
  }
  else if (targetElement instanceof PsiDirectory) {
    psiDirectory = (PsiDirectory)targetElement;
  }
  else {
    final PsiFile containingFile = targetElement.getContainingFile();
    LOG.assertTrue(containingFile != null);
    psiDirectory = containingFile.getContainingDirectory();
  }
  CopyHandler.doCopy(sourceElements, psiDirectory);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ProjectViewDropTarget.java

示例4: testMultipleClasses

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
public void testMultipleClasses() throws Exception {
  String rootBefore = getRoot();
  PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
  final VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
  final PsiClass aClass = myJavaFacade.findClass("pack1.Klass");
  assertNotNull(aClass);

  final PsiFile containingFile = aClass.getContainingFile();

  assertTrue(CopyHandler.canCopy(new PsiElement[]{containingFile}));
  assertFalse(CopyHandler.canClone(new PsiElement[]{containingFile}));

  PsiJavaPackage pack2 = myJavaFacade.findPackage("pack2");
  final PsiDirectory targetDirectory = pack2.getDirectories()[0];
  CopyHandler.doCopy(new PsiElement[]{containingFile}, targetDirectory);

  VirtualFile fileAfter = root.findFileByRelativePath("pack2/Klass.java");
  VirtualFile fileExpected = root.findFileByRelativePath("pack2/Klass.expected.java");

  PlatformTestUtil.assertFilesEqual(fileExpected, fileAfter);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:CopyTest.java

示例5: actionPerformed

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  final VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
  @SuppressWarnings({"ConstantConditions"}) final PsiElement element = PsiManager.getInstance(project).findFile(virtualFile);
  if(element==null) return;
  CopyHandler.doCopy(new PsiElement[] {element.getContainingFile()}, PlatformPackageUtil.getDirectory(element));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:SaveAsAction.java

示例6: actionPerformed

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  final VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
  @SuppressWarnings({"ConstantConditions"}) final PsiElement element = PsiManager.getInstance(project).findFile(virtualFile);
  if(element==null) return;
  CopyHandler.doCopy(new PsiElement[] {element.getContainingFile()}, element.getContainingFile().getContainingDirectory());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:SaveAsAction.java

示例7: actionPerformed

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = dataContext.getData(CommonDataKeys.PROJECT);
  final VirtualFile virtualFile = dataContext.getData(PlatformDataKeys.VIRTUAL_FILE);
  @SuppressWarnings({"ConstantConditions"}) final PsiElement element = PsiManager.getInstance(project).findFile(virtualFile);
  if(element==null) return;
  CopyHandler.doCopy(new PsiElement[] {element.getContainingFile()}, element.getContainingFile().getContainingDirectory());
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:SaveAsAction.java

示例8: testPackageInfo

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
public void testPackageInfo() throws Exception {
  String rootBefore = getRoot();
  PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
  final VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);

  final VirtualFile first = root.findFileByRelativePath("from/package-info.java");
  assertNotNull(first);
  
  final PsiFile firstPsi = myPsiManager.findFile(first);
  
  assertTrue(CopyHandler.canCopy(new PsiElement[]{firstPsi}));

  final VirtualFile toDir = root.findChild("to");
  assertNotNull(toDir);
  final PsiDirectory targetDirectory = myPsiManager.findDirectory(toDir);

  CopyHandler.doCopy(new PsiElement[]{firstPsi}, targetDirectory);

  final VirtualFile dest = root.findFileByRelativePath("to/package-info.java");
  assertNotNull(dest);

  VirtualFile fileExpected = root.findFileByRelativePath("to/package-info.expected.java");
  
  PlatformTestUtil.assertFilesEqual(fileExpected, dest);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:CopyTest.java

示例9: doCopy

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
protected void doCopy(PsiElement[] elements, PsiDirectory defaultTargetDirectory) {
  CopyHandler.doCopy(elements, defaultTargetDirectory);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:CopyElementAction.java


注:本文中的com.intellij.refactoring.copy.CopyHandler.doCopy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。