KickJava   Java API By Example, From Geeks To Geeks.

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


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.IField;
20 import org.eclipse.jdt.core.IJavaElement;
21 import org.eclipse.jdt.core.IType;
22 import org.eclipse.jdt.debug.core.IJavaWatchpoint;
23 import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
24
25 /**
26  * Breakpoint participant for field rename.
27  *
28  * @since 3.2
29  */

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

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

42     protected void gatherChanges(IMarker[] markers, List JavaDoc changes, String JavaDoc destFieldName) throws CoreException, OperationCanceledException {
43         IField originalField = (IField) getOriginalElement();
44         for (int i = 0; i < markers.length; i++) {
45             IMarker marker = markers[i];
46             IBreakpoint breakpoint = getBreakpoint(marker);
47             if (breakpoint instanceof IJavaWatchpoint) {
48                 IJavaWatchpoint watchpoint = (IJavaWatchpoint) breakpoint;
49                 IType breakpointType = BreakpointUtils.getType(watchpoint);
50                 if (breakpointType != null && originalField.getDeclaringType().equals(breakpointType)) {
51                     IField destField = originalField.getDeclaringType().getField(destFieldName);
52                     changes.add(new WatchpointFieldChange(watchpoint, destField));
53                 }
54             }
55         }
56     }
57
58
59 }
60
Popular Tags