1 11 package org.eclipse.jdt.internal.debug.core.refactoring; 12 13 import java.util.List ; 14 15 import org.eclipse.core.resources.IMarker; 16 import org.eclipse.core.resources.IProject; 17 import org.eclipse.core.resources.IResource; 18 import org.eclipse.core.resources.ResourcesPlugin; 19 import org.eclipse.core.runtime.CoreException; 20 import org.eclipse.core.runtime.OperationCanceledException; 21 import org.eclipse.debug.core.model.IBreakpoint; 22 import org.eclipse.jdt.core.IJavaElement; 23 import org.eclipse.jdt.core.IJavaProject; 24 import org.eclipse.jdt.core.IPackageFragment; 25 import org.eclipse.jdt.core.IPackageFragmentRoot; 26 import org.eclipse.jdt.core.IType; 27 import org.eclipse.jdt.core.JavaCore; 28 import org.eclipse.jdt.debug.core.IJavaBreakpoint; 29 import org.eclipse.jdt.internal.debug.ui.BreakpointUtils; 30 31 36 public class BreakpointRenameProjectParticipant extends BreakpointRenameParticipant { 37 38 41 protected boolean accepts(IJavaElement element) { 42 return element instanceof IJavaProject; 43 } 44 45 48 protected void gatherChanges(IMarker[] markers, List changes, String destProjectName) throws CoreException, OperationCanceledException { 49 IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(destProjectName); 50 IJavaProject destProject = JavaCore.create(project); 51 for (int i = 0; i < markers.length; i++) { 52 IMarker marker = markers[i]; 53 IBreakpoint breakpoint = getBreakpoint(marker); 54 if (breakpoint instanceof IJavaBreakpoint) { 55 IJavaBreakpoint javaBreakpoint = (IJavaBreakpoint) breakpoint; 56 IType breakpointType = BreakpointUtils.getType(javaBreakpoint); 57 if (breakpointType != null) { 58 IPackageFragmentRoot root = (IPackageFragmentRoot) breakpointType.getPackageFragment().getParent(); 59 IResource rootResource = null; 60 if (root.getCorrespondingResource().equals(getOriginalElement().getCorrespondingResource())) { 61 rootResource = project; 62 } else { 63 if (root.isArchive()) { 64 rootResource = project.getFile(root.getElementName()); 65 } else { 66 rootResource = project.getFolder(root.getElementName()); 67 } 68 } 69 IPackageFragmentRoot destRoot = destProject.getPackageFragmentRoot(rootResource); 70 IPackageFragment destPackage = destRoot.getPackageFragment(breakpointType.getPackageFragment().getElementName()); 71 IJavaElement parentElement = null; 72 if (breakpointType.isBinary()) { 73 parentElement = destPackage.getClassFile(breakpointType.getClassFile().getElementName()); 74 } else { 75 parentElement = destPackage.getCompilationUnit(breakpointType.getCompilationUnit().getElementName()); 76 } 77 IJavaElement element = BreakpointChange.findElement(parentElement, breakpointType); 78 if (element != null) { 79 if (element instanceof IType) { 80 IType destType = (IType) element; 81 changes.add(createTypeChange(javaBreakpoint, destType, breakpointType)); 82 } 83 } 84 } 85 } 86 } 87 } 88 89 } 90 | Popular Tags |