Eclipse插件以编程方式创建IJavaLineBreakpoint不会在“断点”视图中显示方法信息

时间:2013-10-29 14:06:22

标签: eclipse eclipse-plugin

我正在创建一个Eclipse插件,我正在尝试使用JDIDebugModel创建JavaLineBreakpoint。

但是,当从Java编辑器创建行断点时,它会显示类名,行号和方法名,如下图所示:

enter image description here

在插件中创建行断点时,方法名称将替换为类名,如下所示:

breakpoint create in the editor

以下是用于创建断点的代码。

谢谢。

IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();
if (breakpoints.length == 0) {
    return null;
}

IJavaLineBreakpoint oldBreakpoint = null;
for (int i = 0; i < breakpoints.length; i++) {
    IBreakpoint breakpoint = breakpoints[i];
    if (breakpoint instanceof IJavaLineBreakpoint) {
        oldBreakpoint = (IJavaLineBreakpoint)breakpoint;
        break;
    }
}
if (oldBreakpoint != null) {
    Map newAttrMap = null;
    IResource resource = null;
    try {
        IMarker marker = oldBreakpoint.getMarker();
        if (marker != null && marker.exists()) {
            newAttrMap = marker.getAttributes();
            resource = marker.getResource();
        }
    } catch (CoreException ce) {
        Activator.logError("SinfoniaCloudBreakpointItem - Contructor - Marker attributes not found", ce);
    }
    int lineNumber = -1;
    try {
        lineNumber = (Integer)newAttrMap.get(IMarker.LINE_NUMBER);
    } catch (ClassCastException cce) {
    } catch (NullPointerException ne) {
    }
    try {
        JDIDebugModel.createLineBreakpoint( 
                resource,
                oldBreakpoint.getTypeName(),
                lineNumber, -1, -1, 0, true, newAttrMap);

        oldBreakpoint.delete();
    } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

0 个答案:

没有答案