Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2012 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2013 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 19-24
Link Here
|
19 |
|
19 |
|
20 |
import org.eclipse.core.resources.IFile; |
20 |
import org.eclipse.core.resources.IFile; |
21 |
import org.eclipse.core.resources.IResource; |
21 |
import org.eclipse.core.resources.IResource; |
|
|
22 |
import org.eclipse.core.resources.IWorkspaceRunnable; |
22 |
import org.eclipse.core.resources.ResourcesPlugin; |
23 |
import org.eclipse.core.resources.ResourcesPlugin; |
23 |
import org.eclipse.core.runtime.CoreException; |
24 |
import org.eclipse.core.runtime.CoreException; |
24 |
import org.eclipse.core.runtime.IProgressMonitor; |
25 |
import org.eclipse.core.runtime.IProgressMonitor; |
Lines 175-181
Link Here
|
175 |
switch(element.getElementType()) { |
176 |
switch(element.getElementType()) { |
176 |
case IJavaElement.FIELD: { |
177 |
case IJavaElement.FIELD: { |
177 |
return ((IField)element).getDeclaringType(); |
178 |
return ((IField)element).getDeclaringType(); |
178 |
} |
179 |
} |
179 |
case IJavaElement.METHOD: { |
180 |
case IJavaElement.METHOD: { |
180 |
return ((IMethod)element).getDeclaringType(); |
181 |
return ((IMethod)element).getDeclaringType(); |
181 |
} |
182 |
} |
Lines 197-203
Link Here
|
197 |
|
198 |
|
198 |
/** |
199 |
/** |
199 |
* Toggles a line breakpoint. |
200 |
* Toggles a line breakpoint. |
200 |
* @param part the currently active workbench part |
201 |
* @param part the currently active workbench part |
201 |
* @param selection the current selection |
202 |
* @param selection the current selection |
202 |
* @param bestMatch if we should make a best match or not |
203 |
* @param bestMatch if we should make a best match or not |
203 |
*/ |
204 |
*/ |
Lines 252-258
Link Here
|
252 |
if (selection instanceof IStructuredSelection) { |
253 |
if (selection instanceof IStructuredSelection) { |
253 |
IMethod[] members = getMethods((IStructuredSelection) selection); |
254 |
IMethod[] members = getMethods((IStructuredSelection) selection); |
254 |
if (members.length == 0) { |
255 |
if (members.length == 0) { |
255 |
report(ActionMessages.ToggleBreakpointAdapter_9, part); |
256 |
report(ActionMessages.ToggleBreakpointAdapter_9, part); |
256 |
return Status.OK_STATUS; |
257 |
return Status.OK_STATUS; |
257 |
} |
258 |
} |
258 |
IJavaBreakpoint breakpoint = null; |
259 |
IJavaBreakpoint breakpoint = null; |
Lines 285-291
Link Here
|
285 |
if (!type.isBinary()) { |
286 |
if (!type.isBinary()) { |
286 |
signature = resolveMethodSignature(members[i]); |
287 |
signature = resolveMethodSignature(members[i]); |
287 |
if (signature == null) { |
288 |
if (signature == null) { |
288 |
report(ActionMessages.ManageMethodBreakpointActionDelegate_methodNonAvailable, part); |
289 |
report(ActionMessages.ManageMethodBreakpointActionDelegate_methodNonAvailable, part); |
289 |
return Status.OK_STATUS; |
290 |
return Status.OK_STATUS; |
290 |
} |
291 |
} |
291 |
} |
292 |
} |
Lines 374-380
Link Here
|
374 |
IRegion line = document.getLineInformation(lnumber - 1); |
375 |
IRegion line = document.getLineInformation(lnumber - 1); |
375 |
charstart = line.getOffset(); |
376 |
charstart = line.getOffset(); |
376 |
charend = charstart + line.getLength(); |
377 |
charend = charstart + line.getLength(); |
377 |
} |
378 |
} |
378 |
catch (BadLocationException ble) {JDIDebugUIPlugin.log(ble);} |
379 |
catch (BadLocationException ble) {JDIDebugUIPlugin.log(ble);} |
379 |
BreakpointUtils.addJavaBreakpointAttributes(attributes, type); |
380 |
BreakpointUtils.addJavaBreakpointAttributes(attributes, type); |
380 |
IJavaLineBreakpoint breakpoint = JDIDebugModel.createLineBreakpoint(resource, tname, lnumber, charstart, charend, 0, true, attributes); |
381 |
IJavaLineBreakpoint breakpoint = JDIDebugModel.createLineBreakpoint(resource, tname, lnumber, charstart, charend, 0, true, attributes); |
Lines 386-392
Link Here
|
386 |
report(ActionMessages.ToggleBreakpointAdapter_3, part); |
387 |
report(ActionMessages.ToggleBreakpointAdapter_3, part); |
387 |
return Status.OK_STATUS; |
388 |
return Status.OK_STATUS; |
388 |
} |
389 |
} |
389 |
} |
390 |
} |
390 |
catch (CoreException ce) {return ce.getStatus();} |
391 |
catch (CoreException ce) {return ce.getStatus();} |
391 |
} |
392 |
} |
392 |
return Status.OK_STATUS; |
393 |
return Status.OK_STATUS; |
Lines 438-444
Link Here
|
438 |
report(ActionMessages.ToggleBreakpointAdapter_0, part); |
439 |
report(ActionMessages.ToggleBreakpointAdapter_0, part); |
439 |
return Status.OK_STATUS; |
440 |
return Status.OK_STATUS; |
440 |
} |
441 |
} |
441 |
} |
442 |
} |
442 |
catch (CoreException e) { |
443 |
catch (CoreException e) { |
443 |
return e.getStatus(); |
444 |
return e.getStatus(); |
444 |
} |
445 |
} |
Lines 499-505
Link Here
|
499 |
} |
500 |
} |
500 |
} |
501 |
} |
501 |
} |
502 |
} |
502 |
} |
503 |
} |
503 |
} |
504 |
} |
504 |
return createQualifiedTypeName(type); |
505 |
return createQualifiedTypeName(type); |
505 |
} |
506 |
} |
Lines 553-559
Link Here
|
553 |
if(packName != null && !packName.equals(EMPTY_STRING)) { |
554 |
if(packName != null && !packName.equals(EMPTY_STRING)) { |
554 |
tname = packName+"."+tname; //$NON-NLS-1$ |
555 |
tname = packName+"."+tname; //$NON-NLS-1$ |
555 |
} |
556 |
} |
556 |
} |
557 |
} |
557 |
catch (JavaModelException e) {} |
558 |
catch (JavaModelException e) {} |
558 |
return tname; |
559 |
return tname; |
559 |
} |
560 |
} |
Lines 639-645
Link Here
|
639 |
IEditorInput input = editor.getEditorInput(); |
640 |
IEditorInput input = editor.getEditorInput(); |
640 |
Object adapter = Platform.getAdapterManager().getAdapter(input, "org.eclipse.team.core.history.IFileRevision"); //$NON-NLS-1$ |
641 |
Object adapter = Platform.getAdapterManager().getAdapter(input, "org.eclipse.team.core.history.IFileRevision"); //$NON-NLS-1$ |
641 |
return adapter != null; |
642 |
return adapter != null; |
642 |
} |
643 |
} |
643 |
return false; |
644 |
return false; |
644 |
} |
645 |
} |
645 |
|
646 |
|
Lines 678-684
Link Here
|
678 |
methods.add(method); |
679 |
methods.add(method); |
679 |
} |
680 |
} |
680 |
} |
681 |
} |
681 |
} |
682 |
} |
682 |
catch (JavaModelException e) {} |
683 |
catch (JavaModelException e) {} |
683 |
} |
684 |
} |
684 |
return methods.toArray(new IMethod[methods.size()]); |
685 |
return methods.toArray(new IMethod[methods.size()]); |
Lines 703-709
Link Here
|
703 |
element = ((IClassFile) element).getElementAt(selection.getOffset()); |
704 |
element = ((IClassFile) element).getElementAt(selection.getOffset()); |
704 |
} |
705 |
} |
705 |
return element != null && element.getElementType() == IJavaElement.METHOD; |
706 |
return element != null && element.getElementType() == IJavaElement.METHOD; |
706 |
} |
707 |
} |
707 |
catch (JavaModelException e) {return false;} |
708 |
catch (JavaModelException e) {return false;} |
708 |
} |
709 |
} |
709 |
} |
710 |
} |
Lines 768-774
Link Here
|
768 |
return type != null && type.isInterface(); |
769 |
return type != null && type.isInterface(); |
769 |
} |
770 |
} |
770 |
} |
771 |
} |
771 |
} |
772 |
} |
772 |
catch (CoreException e1) {} |
773 |
catch (CoreException e1) {} |
773 |
return false; |
774 |
return false; |
774 |
} |
775 |
} |
Lines 793-800
Link Here
|
793 |
element = ((IClassFile) element).getElementAt(selection.getOffset()); |
794 |
element = ((IClassFile) element).getElementAt(selection.getOffset()); |
794 |
} |
795 |
} |
795 |
return element != null && element.getElementType() == IJavaElement.FIELD; |
796 |
return element != null && element.getElementType() == IJavaElement.FIELD; |
796 |
} |
797 |
} |
797 |
catch (JavaModelException e) {return false;} |
798 |
catch (JavaModelException e) {return false;} |
798 |
} |
799 |
} |
799 |
} |
800 |
} |
800 |
return false; |
801 |
return false; |
Lines 854-860
Link Here
|
854 |
if (selection instanceof IStructuredSelection) { |
855 |
if (selection instanceof IStructuredSelection) { |
855 |
List<Object> fields = getFields((IStructuredSelection) selection); |
856 |
List<Object> fields = getFields((IStructuredSelection) selection); |
856 |
if (fields.isEmpty()) { |
857 |
if (fields.isEmpty()) { |
857 |
report(ActionMessages.ToggleBreakpointAdapter_10, part); |
858 |
report(ActionMessages.ToggleBreakpointAdapter_10, part); |
858 |
return Status.OK_STATUS; |
859 |
return Status.OK_STATUS; |
859 |
} |
860 |
} |
860 |
Iterator<Object> theFields = fields.iterator(); |
861 |
Iterator<Object> theFields = fields.iterator(); |
Lines 967-973
Link Here
|
967 |
return null; |
968 |
return null; |
968 |
} |
969 |
} |
969 |
return Signature.createMethodSignature(resolvedParameterTypes, resolvedReturnType); |
970 |
return Signature.createMethodSignature(resolvedParameterTypes, resolvedReturnType); |
970 |
} |
971 |
} |
971 |
|
972 |
|
972 |
/** |
973 |
/** |
973 |
* Returns the resolved type signature for the given signature in the given |
974 |
* Returns the resolved type signature for the given signature in the given |
Lines 1090-1097
Link Here
|
1090 |
} |
1091 |
} |
1091 |
if (container == null) { |
1092 |
if (container == null) { |
1092 |
try { |
1093 |
try { |
1093 |
if (method.getDeclaringType().getFullyQualifiedName().equals(methodBreakpoint.getTypeName()) && |
1094 |
if (method.getDeclaringType().getFullyQualifiedName().equals(methodBreakpoint.getTypeName()) && |
1094 |
method.getElementName().equals(methodBreakpoint.getMethodName()) && |
1095 |
method.getElementName().equals(methodBreakpoint.getMethodName()) && |
1095 |
methodBreakpoint.getMethodSignature().equals(resolveMethodSignature(method))) { |
1096 |
methodBreakpoint.getMethodSignature().equals(resolveMethodSignature(method))) { |
1096 |
return methodBreakpoint; |
1097 |
return methodBreakpoint; |
1097 |
} |
1098 |
} |
Lines 1234-1240
Link Here
|
1234 |
return null; |
1235 |
return null; |
1235 |
} |
1236 |
} |
1236 |
IField field; |
1237 |
IField field; |
1237 |
IJavaType declaringType = variable.getDeclaringType(); |
1238 |
IJavaType declaringType = variable.getDeclaringType(); |
1238 |
IType type = JavaDebugUtils.resolveType(declaringType); |
1239 |
IType type = JavaDebugUtils.resolveType(declaringType); |
1239 |
if (type != null) { |
1240 |
if (type != null) { |
1240 |
field = type.getField(varName); |
1241 |
field = type.getField(varName); |
Lines 1279-1285
Link Here
|
1279 |
else if(loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_LINE) { |
1280 |
else if(loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_LINE) { |
1280 |
toggleLineBreakpoints(part, ts, false, loc); |
1281 |
toggleLineBreakpoints(part, ts, false, loc); |
1281 |
} |
1282 |
} |
1282 |
} |
1283 |
} |
1283 |
} |
1284 |
} |
1284 |
else if(member.getElementType() == IJavaElement.TYPE) { |
1285 |
else if(member.getElementType() == IJavaElement.TYPE) { |
1285 |
toggleClassBreakpoints(part, sel); |
1286 |
toggleClassBreakpoints(part, sel); |
Lines 1299-1305
Link Here
|
1299 |
* @param progressMonitor the progress monitor |
1300 |
* @param progressMonitor the progress monitor |
1300 |
* @throws CoreException if the deletion fails |
1301 |
* @throws CoreException if the deletion fails |
1301 |
*/ |
1302 |
*/ |
1302 |
private static void deleteBreakpoint(IJavaBreakpoint breakpoint, IWorkbenchPart part, IProgressMonitor monitor) throws CoreException { |
1303 |
private static void deleteBreakpoint(final IJavaBreakpoint breakpoint, IWorkbenchPart part, IProgressMonitor monitor) throws CoreException { |
1303 |
final Shell shell= part != null ? part.getSite().getShell() : null; |
1304 |
final Shell shell= part != null ? part.getSite().getShell() : null; |
1304 |
final boolean[] result= new boolean[] { true }; |
1305 |
final boolean[] result= new boolean[] { true }; |
1305 |
|
1306 |
|
Lines 1320-1327
Link Here
|
1320 |
}); |
1321 |
}); |
1321 |
} |
1322 |
} |
1322 |
} |
1323 |
} |
1323 |
if (result[0]) |
1324 |
if (result[0]) { |
1324 |
DebugUITools.deleteBreakpoints(new IBreakpoint[] { breakpoint }, shell, monitor); |
1325 |
IWorkspaceRunnable runnable = new IWorkspaceRunnable() { // see bug 373201 |
|
|
1326 |
public void run(IProgressMonitor monitor) throws CoreException { |
1327 |
DebugUITools.deleteBreakpoints(new IBreakpoint[] { breakpoint }, shell, monitor); |
1328 |
} |
1329 |
}; |
1330 |
ResourcesPlugin.getWorkspace().run(runnable, null, 0, monitor); |
1331 |
} |
1325 |
} |
1332 |
} |
1326 |
|
1333 |
|
1327 |
/* |
1334 |
/* |
Lines 1333-1339
Link Here
|
1333 |
public boolean canToggleBreakpoints(IWorkbenchPart part, ISelection selection) { |
1340 |
public boolean canToggleBreakpoints(IWorkbenchPart part, ISelection selection) { |
1334 |
if (isRemote(part, selection)) { |
1341 |
if (isRemote(part, selection)) { |
1335 |
return false; |
1342 |
return false; |
1336 |
} |
1343 |
} |
1337 |
return canToggleLineBreakpoints(part, selection); |
1344 |
return canToggleLineBreakpoints(part, selection); |
1338 |
} |
1345 |
} |
1339 |
|
1346 |
|