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.runtime.CoreException; 17 import org.eclipse.core.runtime.OperationCanceledException; 18 import org.eclipse.debug.core.model.IBreakpoint; 19 import org.eclipse.jdt.core.ICompilationUnit; 20 import org.eclipse.jdt.core.IJavaElement; 21 import org.eclipse.jdt.core.IPackageFragment; 22 import org.eclipse.jdt.core.IPackageFragmentRoot; 23 import org.eclipse.jdt.core.IType; 24 import org.eclipse.jdt.debug.core.IJavaBreakpoint; 25 import org.eclipse.jdt.internal.debug.ui.BreakpointUtils; 26 27 32 public class BreakpointMovePackageParticipant extends BreakpointMoveParticipant { 33 34 37 protected boolean accepts(IJavaElement element) { 38 return element instanceof IPackageFragment && getArguments().getDestination() instanceof IPackageFragmentRoot; 39 } 40 41 44 protected void gatherChanges(IMarker[] markers, List changes) throws CoreException, OperationCanceledException { 45 IPackageFragmentRoot destRoot = (IPackageFragmentRoot)getDestination(); 46 for (int i = 0; i < markers.length; i++) { 47 IMarker marker = markers[i]; 48 IBreakpoint breakpoint = getBreakpoint(marker); 49 if (breakpoint instanceof IJavaBreakpoint) { 50 IJavaBreakpoint javaBreakpoint = (IJavaBreakpoint) breakpoint; 51 IType breakpointType = BreakpointUtils.getType(javaBreakpoint); 52 if (breakpointType != null) { 53 String breakpointPackageName = breakpointType.getPackageFragment().getElementName(); 54 IPackageFragment destBreakpointPackage = destRoot.getPackageFragment(breakpointPackageName); 55 ICompilationUnit cu = destBreakpointPackage.getCompilationUnit(breakpointType.getCompilationUnit().getElementName()); 56 IJavaElement element = BreakpointChange.findElement(cu, breakpointType); 57 if (element != null) { 58 if (element instanceof IType) { 59 IType destType = (IType) element; 60 changes.add(createTypeChange(javaBreakpoint, destType, breakpointType)); 61 } 62 } 63 } 64 } 65 } 66 } 67 68 } 69 | Popular Tags |