KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > core > refactoring > BreakpointRenameMethodParticipant


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.core.refactoring;
12
13 import java.util.List JavaDoc;
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.IJavaElement;
20 import org.eclipse.jdt.core.IMethod;
21 import org.eclipse.jdt.core.IType;
22 import org.eclipse.jdt.debug.core.IJavaMethodBreakpoint;
23 import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
24
25 /**
26  * Breakpoint participant for method rename.
27  *
28  * @since 3.2
29  */

30 public class BreakpointRenameMethodParticipant extends BreakpointRenameParticipant {
31
32     
33     /* (non-Javadoc)
34      * @see org.eclipse.jdt.internal.debug.core.refactoring.BreakpointRenameParticipant#accepts(org.eclipse.jdt.core.IJavaElement)
35      */

36     protected boolean accepts(IJavaElement element) {
37         return element instanceof IMethod;
38     }
39
40     /* (non-Javadoc)
41      * @see org.eclipse.jdt.internal.debug.core.refactoring.BreakpointRenameParticipant#gatherChanges(org.eclipse.core.resources.IMarker[], java.util.List, java.lang.String)
42      */

43     protected void gatherChanges(IMarker[] markers, List JavaDoc changes, String JavaDoc destMethodName) throws CoreException, OperationCanceledException {
44         IMethod originalMethod = (IMethod) getOriginalElement();
45         for (int i = 0; i < markers.length; i++) {
46             IMarker marker = markers[i];
47             IBreakpoint breakpoint = getBreakpoint(marker);
48             if (breakpoint instanceof IJavaMethodBreakpoint) {
49                 IJavaMethodBreakpoint methodBreakpoint = (IJavaMethodBreakpoint) breakpoint;
50                 IType breakpointType = BreakpointUtils.getType(methodBreakpoint);
51                 if (breakpointType != null && originalMethod.getDeclaringType().equals(breakpointType)) {
52                     IMethod destMethod = originalMethod.getDeclaringType().getMethod(destMethodName, originalMethod.getParameterTypes());
53                     changes.add(new MethodBreakpointMethodChange(methodBreakpoint, destMethod));
54                 }
55             }
56         }
57     }
58     
59 }
60
Popular Tags