Search in sources :

Example 1 with LineBreakpoint

use of processing.mode.java.debug.LineBreakpoint in project processing by processing.

the class JavaEditor method handleSaveAs.

public boolean handleSaveAs() {
    //System.out.println("handleSaveAs");
    String oldName = getSketch().getCode(0).getFileName();
    //System.out.println("old name: " + oldName);
    boolean saved = super.handleSaveAs();
    if (saved) {
        // re-set breakpoints in first tab (name has changed)
        List<LineBreakpoint> bps = debugger.getBreakpoints(oldName);
        debugger.clearBreakpoints(oldName);
        String newName = getSketch().getCode(0).getFileName();
        //System.out.println("new name: " + newName);
        for (LineBreakpoint bp : bps) {
            LineID line = new LineID(newName, bp.lineID().lineIdx());
            //System.out.println("setting: " + line);
            debugger.setBreakpoint(line);
        }
        // add breakpoint marker comments to source file
        for (SketchCode code : getSketch().getCode()) {
            addBreakpointComments(code.getFileName());
        }
    // set new name of variable inspector
    //inspector.setTitle(getSketch().getName());
    }
    return saved;
}
Also used : LineBreakpoint(processing.mode.java.debug.LineBreakpoint) LineID(processing.mode.java.debug.LineID)

Example 2 with LineBreakpoint

use of processing.mode.java.debug.LineBreakpoint in project processing by processing.

the class JavaEditor method addBreakpointComments.

/**
   * Add breakpoint marker comments to the source file of a specific tab. This
   * acts on the source file on disk, not the editor text. Intended to be
   * called just after saving the sketch.
   *
   * @param tabFilename the tab file name
   */
protected void addBreakpointComments(String tabFilename) {
    SketchCode tab = getTab(tabFilename);
    if (tab == null) {
        // this method gets called twice when saving sketch for the first time
        // once with new name and another with old(causing NPE). Keep an eye out
        // for potential issues. See #2675. TODO:
        Messages.loge("Illegal tab name to addBreakpointComments() " + tabFilename);
        return;
    }
    List<LineBreakpoint> bps = debugger.getBreakpoints(tab.getFileName());
    //System.out.println("file: " + sourceFile);
    try {
        tab.load();
        String code = tab.getProgram();
        //System.out.println("code: " + code);
        // newlines not included
        String[] lines = code.split("\\r?\\n");
        for (LineBreakpoint bp : bps) {
            //System.out.println("adding bp: " + bp.lineID());
            lines[bp.lineID().lineIdx()] += breakpointMarkerComment;
        }
        code = PApplet.join(lines, "\n");
        //System.out.println("new code: " + code);
        tab.setProgram(code);
        tab.save();
    } catch (IOException ex) {
        Messages.loge(null, ex);
    }
}
Also used : LineBreakpoint(processing.mode.java.debug.LineBreakpoint)

Aggregations

LineBreakpoint (processing.mode.java.debug.LineBreakpoint)2 LineID (processing.mode.java.debug.LineID)1