本文整理汇总了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);
}
示例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"));
}
示例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);
}
示例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);
}
示例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));
}
示例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());
}
示例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());
}
示例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);
}
示例9: doCopy
import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
protected void doCopy(PsiElement[] elements, PsiDirectory defaultTargetDirectory) {
CopyHandler.doCopy(elements, defaultTargetDirectory);
}