当前位置: 首页>>代码示例>>Java>>正文


Java DebuggerManager.addBreakpoint方法代码示例

本文整理汇总了Java中org.netbeans.api.debugger.DebuggerManager.addBreakpoint方法的典型用法代码示例。如果您正苦于以下问题:Java DebuggerManager.addBreakpoint方法的具体用法?Java DebuggerManager.addBreakpoint怎么用?Java DebuggerManager.addBreakpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.api.debugger.DebuggerManager的用法示例。


在下文中一共展示了DebuggerManager.addBreakpoint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doAction

import org.netbeans.api.debugger.DebuggerManager; //导入方法依赖的package包/类
@Override
public void doAction(Object action) {
    Line line = JSUtils.getCurrentLine();
    if (line == null) {
        return ;
    }
    DebuggerManager d = DebuggerManager.getDebuggerManager();
    boolean add = true;
    for (Breakpoint breakpoint : d.getBreakpoints()) {
        if (breakpoint instanceof JSLineBreakpoint &&
            JSUtils.getLine((JSLineBreakpoint) breakpoint).equals(line)) {
            
            d.removeBreakpoint(breakpoint);
            add = false;
            break;
        }
    }
    if (add) {
        d.addBreakpoint(JSUtils.createLineBreakpoint(line));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ToggleBreakpointActionProvider.java

示例2: testBreakpointUnambiguity2

import org.netbeans.api.debugger.DebuggerManager; //导入方法依赖的package包/类
/**
 * Tests debugger's ability to make difference between different projects
 * with the same classes while getting the locations during class-loaded event.
 *
 * 1. The user creates 2 classes: ${test.dir.src}/.../LineBreakpointApp.java
 *    and ${test.dir.src_2}/.../LineBreakpointApp.java
 * 2. Then set a breakpoint in ${test.dir.src_2}/.../LineBreakpointApp.java.
 * 
 * Debugger should stop _only_ in the second project. If debugger stopped in
 * the first one, then assertion violation would arise because of source path
 * equality test.
 */
public void testBreakpointUnambiguity2 () throws Exception {
    try {
        Utils.BreakPositions bp = Utils.getBreakPositions(System.getProperty ("test.dir.src") + 
                "org/netbeans/api/debugger/jpda/testapps/LineBreakpointApp.java");
        LineBreakpoint lb1 = LineBreakpoint.create(
                Utils.getURL(System.getProperty ("user.home") + // intentionally bad path
                java.io.File.separator +
                "org/netbeans/api/debugger/jpda/testapps/LineBreakpointApp.java"), bp.getStopLine("condition1"));
        //lb1.setSourceRoot(System.getProperty ("test.dir.src") + "_2");
        DebuggerManager dm = DebuggerManager.getDebuggerManager ();
        dm.addBreakpoint (lb1);
        
        TestBreakpointListener tb1 = new TestBreakpointListener (lb1);
        lb1.addJPDABreakpointListener (tb1);
        
        support = JPDASupport.attach (
            "org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp"
        );
        JPDADebugger debugger = support.getDebugger();

        support.waitState (JPDADebugger.STATE_STOPPED); // Stopped or disconnected
        assertEquals(
                "Debugger should not stop on BP with faked source root",
                debugger.getState(),
                JPDADebugger.STATE_DISCONNECTED
        );
        
        tb1.checkNotNotified();
        dm.removeBreakpoint (lb1);
    } finally {
        if (support != null) support.doFinish ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:LineBreakpointTest.java

示例3: testBreakpointUnambiguity

import org.netbeans.api.debugger.DebuggerManager; //导入方法依赖的package包/类
/**
 * Tests debugger's ability to make difference between different JSP pages
 * with the same name while getting the locations during class-loaded event.
 *
 * 1. The user creates JSP (index.jsp, include.jsp, d/include.jsp) and 
 * 2. statically includes d/include.jsp (as 1st) and include.jsp (as 2nd) into index.jsp.
 * 3. Then bp is set in include.jsp (line 2).
 * 
 * Debugger should stop _only_ in the include.jsp. If debugger stopped in the first JSP
 * (d/include.jsp), then assertion violation would arise because of source path
 * equality test.
 */
public void testBreakpointUnambiguity () throws Exception {
    try {
        //install SDE extension to class file
        runSDEInstaller(testAppCLAZ, testAppSMAP);

        //String URL = getClass().getResource("testapps/resources/included.jsp").toString();
        String URL = "file:"+SRC_ROOT+"/org/netbeans/api/debugger/jpda/testapps/resources/included.jsp";
        LineBreakpoint lb = LineBreakpoint.create(URL, LINE_NUMBER);
        lb.setStratum(STRATUM); // NOI18N
        lb.setSourceName(SOURCE_NAME);
        lb.setSourcePath(SOURCE_PATH_SECOND);
        lb.setPreferredClassName(CLASS_NAME);

        DebuggerManager dm = DebuggerManager.getDebuggerManager ();
        dm.addBreakpoint (lb);

        support = JPDASupport.attach (
            "org.netbeans.api.debugger.jpda.testapps.JspLineBreakpointApp"
        );
        JPDADebugger debugger = support.getDebugger();

        support.waitState (JPDADebugger.STATE_STOPPED);  // breakpoint hit
        assertNotNull(debugger.getCurrentCallStackFrame());
        assertEquals(
            "Debugger stopped at wrong file", 
            lb.getSourcePath(), 
            debugger.getCurrentCallStackFrame().getSourcePath(STRATUM)
        );

        dm.removeBreakpoint (lb);
    } finally {
        if (support != null) support.doFinish ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:JspLineBreakpointTest.java

示例4: testBreakpointRepeatability

import org.netbeans.api.debugger.DebuggerManager; //导入方法依赖的package包/类
/**
 * Tests debugger's ability to stop in one JSP as many times as this JSP 
 * is included in another page.
 *
 * 1. The user creates JSP (index.jsp, include.jsp) and 
 * 2. statically includes include.jsp twice into index.jsp.
 * 3. Then bp is set in include.jsp (line 2).
 * 
 * Debugger should stop twice in the include.jsp. If debugger didn't stopped 
 * in the include.jsp for the second time, then assertion violation would arise
 * because of testing debugger's state for STOP state.
 */
public void testBreakpointRepeatability () throws Exception {
    try {
        //install SDE extension to class file
        runSDEInstaller(testAppCLAZ, testAppSMAP);

        //String URL = getClass().getResource("testapps/resources/included.jsp").toString();
        String URL = "file:"+SRC_ROOT+"/org/netbeans/api/debugger/jpda/testapps/resources/included.jsp";
        LineBreakpoint lb = LineBreakpoint.create(URL, LINE_NUMBER);
        lb.setStratum(STRATUM); // NOI18N
        lb.setSourceName(SOURCE_NAME);
        lb.setSourcePath(SOURCE_PATH_SECOND);
        lb.setPreferredClassName(CLASS_NAME);

        DebuggerManager dm = DebuggerManager.getDebuggerManager ();
        dm.addBreakpoint (lb);

        support = JPDASupport.attach (
            "org.netbeans.api.debugger.jpda.testapps.JspLineBreakpointApp"
        );
        JPDADebugger debugger = support.getDebugger();

        support.waitState (JPDADebugger.STATE_STOPPED);  // first breakpoint hit
        support.doContinue ();
        support.waitState (JPDADebugger.STATE_STOPPED);  // second breakpoint hit
        assertTrue(
            "Debugger did not stop at breakpoint for the second time.",
            debugger.getState() == JPDADebugger.STATE_STOPPED
        );
        
        dm.removeBreakpoint (lb);

    } finally {
        if (support != null) support.doFinish ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:JspLineBreakpointTest.java

示例5: testMultipleLineBreakpoints

import org.netbeans.api.debugger.DebuggerManager; //导入方法依赖的package包/类
public void testMultipleLineBreakpoints () throws Exception {
    try {
        Utils.BreakPositions bp = Utils.getBreakPositions(TEST_APP_PATH);
        LineBreakpoint[] lb = bp.getBreakpoints().toArray(new LineBreakpoint[0]);
        {
            LineBreakpoint b;
            b = lb[4];
            lb[4] = lb[2];
            lb[2] = b;
        }
        /*
        LineBreakpoint lb1 = LineBreakpoint.create (TEST_APP, 32);
        LineBreakpoint lb2 = LineBreakpoint.create (TEST_APP, 37);
        LineBreakpoint lb3 = LineBreakpoint.create (TEST_APP, 109);
        lb3.setPreferredClassName("org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp$Inner");
        LineBreakpoint lb4 = LineBreakpoint.create (TEST_APP, 92);
        lb4.setPreferredClassName("org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp$InnerStatic");
        LineBreakpoint lb5 = LineBreakpoint.create (TEST_APP, 41);
        */
        DebuggerManager dm = DebuggerManager.getDebuggerManager ();
        for (int i = 0; i < lb.length; i++) {
            dm.addBreakpoint (lb[i]);
        }

        TestBreakpointListener[] tb = new TestBreakpointListener[lb.length];
        for (int i = 0; i < lb.length; i++) {
            tb[i] = new TestBreakpointListener (lb[i]);
            lb[i].addJPDABreakpointListener (tb[i]);
        }
        support = JPDASupport.attach (
            "org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp"
        );
        JPDADebugger debugger = support.getDebugger();
        
        for (int j = 0; j < lb.length; j++) {
            support.waitState (JPDADebugger.STATE_STOPPED);  // j-th breakpoint hit
            assertEquals (
                "Debugger stopped at wrong line for breakpoint " + j, 
                lb[j].getLineNumber (), 
                debugger.getCurrentCallStackFrame ().getLineNumber (null)
            );
            for (int i = j+1; i < tb.length; i++) {
                tb[i].checkNotNotified();
            }
            if (j < lb.length - 1) {
                support.doContinue();
            }
        }
        
        for (int i = 0; i < tb.length; i++) {
            tb[i].checkResult ();
        }
        for (int i = 0; i < tb.length; i++) {
            dm.removeBreakpoint (lb[i]);
        }
        support.doContinue ();
        support.waitState (JPDADebugger.STATE_DISCONNECTED);
    } finally {
        if (support != null) support.doFinish ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:62,代码来源:LineBreakpointTest.java

示例6: testBreakpointUnambiguity1

import org.netbeans.api.debugger.DebuggerManager; //导入方法依赖的package包/类
/**
     * Tests debugger's ability to make difference between different projects
     * with the same classes while getting the locations during class-loaded event.
     *
     * 1. The user creates 2 classes: ${test.dir.src}/.../LineBreakpointApp.java
     *    and ${test.dir.src_2}/.../LineBreakpointApp.java
     * 2. Then set a breakpoint in ${test.dir.src_2}/.../LineBreakpointApp.java.
     * 
     * Debugger should stop _only_ in the second project. If debugger stopped in
     * the first one, then assertion violation would arise because of source path
     * equality test.
     */
    public void testBreakpointUnambiguity1 () throws Exception {
        try {
            Utils.BreakPositions bp = Utils.getBreakPositions(System.getProperty ("test.dir.src") + 
                    "org/netbeans/api/debugger/jpda/testapps/LineBreakpointApp.java");
            LineBreakpoint lb1 = LineBreakpoint.create (TEST_APP, bp.getStopLine("condition1"));
//            lb1.setSourceRoot(System.getProperty ("test.dir.src"));
            DebuggerManager dm = DebuggerManager.getDebuggerManager ();
            dm.addBreakpoint (lb1);
            
            TestBreakpointListener tb1 = new TestBreakpointListener (lb1);
            lb1.addJPDABreakpointListener (tb1);
            
            support = JPDASupport.attach (
                "org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp"
            );
            JPDADebugger debugger = support.getDebugger();

            support.waitState (JPDADebugger.STATE_STOPPED);  // breakpoint hit, the source root is correct
            assertEquals (
                "Debugger stopped at wrong line", 
                lb1.getLineNumber (), 
                debugger.getCurrentCallStackFrame ().getLineNumber (null)
            );

            tb1.checkResult ();
            support.doContinue();
            support.waitState (JPDADebugger.STATE_DISCONNECTED);
            dm.removeBreakpoint (lb1);
            support.doFinish ();
            /*
            // Second run - BP should not be hit with a different source root - viz testBreakpointUnambiguity2()
            support = null;
            lb1 = LineBreakpoint.create (TEST_APP, 39);
            lb1.setSourceRoot(System.getProperty ("test.dir.src")+"_2");
            dm = DebuggerManager.getDebuggerManager ();
            dm.addBreakpoint (lb1);
            
            tb1 = new TestBreakpointListener (lb1);
            lb1.addJPDABreakpointListener (tb1);
            
            support = JPDASupport.attach (
                "org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp"
            );
            debugger = support.getDebugger();
            
            support.waitState (JPDADebugger.STATE_STOPPED); // Stopped or disconnected
            assertEquals(
                    "Debugger should not stop on BP with faked source root",
                    debugger.getState(),
                    JPDADebugger.STATE_DISCONNECTED
            );
            tb1.checkNotNotified();
            dm.removeBreakpoint (lb1);
             */
        } finally {
            if (support != null) support.doFinish ();
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:71,代码来源:LineBreakpointTest.java

示例7: testBreakpointsDeactivation

import org.netbeans.api.debugger.DebuggerManager; //导入方法依赖的package包/类
public void testBreakpointsDeactivation () throws Exception {
    try {
        Utils.BreakPositions bp = Utils.getBreakPositions(TEST_APP_PATH);
        LineBreakpoint[] lb = bp.getBreakpoints().toArray(new LineBreakpoint[0]);
        {
            LineBreakpoint b;
            b = lb[4];
            lb[4] = lb[2];
            lb[2] = b;
        }
        /*
        LineBreakpoint lb1 = LineBreakpoint.create (TEST_APP, 32);
        LineBreakpoint lb2 = LineBreakpoint.create (TEST_APP, 37);
        LineBreakpoint lb3 = LineBreakpoint.create (TEST_APP, 109);
        lb3.setPreferredClassName("org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp$Inner");
        LineBreakpoint lb4 = LineBreakpoint.create (TEST_APP, 92);
        lb4.setPreferredClassName("org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp$InnerStatic");
        LineBreakpoint lb5 = LineBreakpoint.create (TEST_APP, 41);
        */
        DebuggerManager dm = DebuggerManager.getDebuggerManager ();
        for (int i = 0; i < lb.length; i++) {
            dm.addBreakpoint (lb[i]);
        }

        TestBreakpointListener[] tb = new TestBreakpointListener[lb.length];
        for (int i = 0; i < lb.length; i++) {
            tb[i] = new TestBreakpointListener (lb[i]);
            lb[i].addJPDABreakpointListener (tb[i]);
        }
        support = JPDASupport.attach (
            "org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp"
        );
        JPDADebugger debugger = support.getDebugger();
        assertEquals("Breakpoints should be active initially.", true, debugger.getBreakpointsActive());
        
        support.waitState (JPDADebugger.STATE_STOPPED);  // stopped on the first breakpoint
        
        final PropertyChangeEvent[] propertyPtr = new PropertyChangeEvent[] { null };
        debugger.addPropertyChangeListener(JPDADebugger.PROP_BREAKPOINTS_ACTIVE, new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                propertyPtr[0] = evt;
            }
        });
        debugger.setBreakpointsActive(false);
        assertNotNull(propertyPtr[0]);
        assertEquals(propertyPtr[0].getSource(), debugger);
        assertEquals(propertyPtr[0].getOldValue(), Boolean.TRUE);
        assertEquals(propertyPtr[0].getNewValue(), Boolean.FALSE);
        assertEquals("Breakpoints should be inactive after deactivation.", false, debugger.getBreakpointsActive());
        
        int j = 0;
        assertEquals (
            "Debugger stopped at wrong line for breakpoint " + j, 
            lb[j].getLineNumber (), 
            debugger.getCurrentCallStackFrame ().getLineNumber (null)
        );
        for (int i = j+1; i < tb.length; i++) {
            tb[i].checkNotNotified();
        }
        if (j < lb.length - 1) {
            support.doContinue();
        }
        
        for (int i = 0; i < tb.length; i++) {
            dm.removeBreakpoint (lb[i]);
        }
        support.waitState (JPDADebugger.STATE_DISCONNECTED);
    } finally {
        if (support != null) {
            support.doFinish ();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:75,代码来源:BreakpointsDeactivationTest.java


注:本文中的org.netbeans.api.debugger.DebuggerManager.addBreakpoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。