Search in sources :

Example 11 with Breakpoint

use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.

the class BreakpointManagerImpl method doSetCurrentBreakpoint.

private void doSetCurrentBreakpoint(VirtualFile activeFile, int lineNumber) {
    currentBreakpoint = new Breakpoint(Type.CURRENT, lineNumber, activeFile.getLocation().toString(), activeFile, true);
    BreakpointRenderer breakpointRenderer = getBreakpointRendererForFile(activeFile.getLocation().toString());
    if (breakpointRenderer != null) {
        breakpointRenderer.setLineActive(lineNumber, true);
    }
    preserveBreakpoints();
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) BreakpointRenderer(org.eclipse.che.ide.api.debug.BreakpointRenderer) HasBreakpointRenderer(org.eclipse.che.ide.api.debug.HasBreakpointRenderer)

Example 12 with Breakpoint

use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.

the class BreakpointManagerImpl method deleteAllBreakpoints.

@Override
public void deleteAllBreakpoints() {
    for (List<Breakpoint> pathBreakpoints : breakpoints.values()) {
        removeBreakpointsForPath(pathBreakpoints);
    }
    breakpoints.clear();
    preserveBreakpoints();
    for (BreakpointManagerObserver observer : observers) {
        observer.onAllBreakpointsDeleted();
    }
    Debugger debugger = debuggerManager.getActiveDebugger();
    if (debugger != null) {
        debugger.deleteAllBreakpoints();
    }
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) BreakpointManagerObserver(org.eclipse.che.ide.api.debug.BreakpointManagerObserver)

Example 13 with Breakpoint

use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.

the class BreakpointManagerImpl method onLineChange.

/**
     * {@inheritDoc}
     */
@Override
public void onLineChange(final VirtualFile file, final int firstLine, final int linesAdded, final int linesRemoved) {
    final List<Breakpoint> fileBreakpoints = breakpoints.get(file.getLocation().toString());
    final int delta = linesAdded - linesRemoved;
    if (fileBreakpoints != null) {
        LOG.fine("Change in file with breakpoints " + file.getLocation().toString());
        final List<Breakpoint> toRemove = new ArrayList<>();
        final List<Breakpoint> toAdd = new ArrayList<>();
        for (final Breakpoint breakpoint : fileBreakpoints) {
            final int lineNumber = breakpoint.getLineNumber();
            if (lineNumber < firstLine) {
                // we're before any change
                continue;
            }
            toRemove.add(breakpoint);
            toAdd.add(new Breakpoint(breakpoint.getType(), breakpoint.getLineNumber() + delta, breakpoint.getPath(), breakpoint.getFile(), breakpoint.isActive()));
        }
        for (final Breakpoint breakpoint : toRemove) {
            deleteBreakpoint(file, breakpoint);
        }
        for (final Breakpoint breakpoint : toAdd) {
            if (isLineNotEmpty(file, breakpoint.getLineNumber())) {
                addBreakpoint(new Breakpoint(breakpoint.getType(), breakpoint.getLineNumber(), breakpoint.getPath(), file, false));
            }
        }
    }
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) ArrayList(java.util.ArrayList) Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint)

Example 14 with Breakpoint

use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.

the class BreakpointManagerImpl method addBreakpoint.

/**
     * Adds breakpoint to the list and JVM.
     */
private void addBreakpoint(final Breakpoint breakpoint) {
    List<Breakpoint> pathBreakpoints = breakpoints.get(breakpoint.getPath());
    if (pathBreakpoints == null) {
        pathBreakpoints = new ArrayList<>();
        breakpoints.put(breakpoint.getPath(), pathBreakpoints);
    }
    if (!pathBreakpoints.contains(breakpoint)) {
        pathBreakpoints.add(breakpoint);
    }
    preserveBreakpoints();
    final BreakpointRenderer breakpointRenderer = getBreakpointRendererForFile(breakpoint.getPath());
    if (breakpointRenderer != null) {
        breakpointRenderer.addBreakpointMark(breakpoint.getLineNumber(), new LineChangeAction() {

            @Override
            public void onLineChange(VirtualFile file, int firstLine, int linesAdded, int linesRemoved) {
                BreakpointManagerImpl.this.onLineChange(file, firstLine, linesAdded, linesRemoved);
            }
        });
        breakpointRenderer.setBreakpointActive(breakpoint.getLineNumber(), breakpoint.isActive());
    }
    for (BreakpointManagerObserver observer : observers) {
        observer.onBreakpointAdded(breakpoint);
    }
    Debugger debugger = debuggerManager.getActiveDebugger();
    if (debugger != null) {
        debugger.addBreakpoint(breakpoint.getFile(), breakpoint.getLineNumber());
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) BreakpointRenderer(org.eclipse.che.ide.api.debug.BreakpointRenderer) HasBreakpointRenderer(org.eclipse.che.ide.api.debug.HasBreakpointRenderer) LineChangeAction(org.eclipse.che.ide.api.debug.BreakpointRenderer.LineChangeAction) BreakpointManagerObserver(org.eclipse.che.ide.api.debug.BreakpointManagerObserver) Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint)

Example 15 with Breakpoint

use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.

the class BreakpointManagerImpl method onDebuggerDisconnected.

@Override
public void onDebuggerDisconnected() {
    for (Entry<String, List<Breakpoint>> entry : breakpoints.entrySet()) {
        List<Breakpoint> breakpointsForPath = entry.getValue();
        for (int i = 0; i < breakpointsForPath.size(); i++) {
            Breakpoint breakpoint = breakpointsForPath.get(i);
            if (breakpoint.isActive()) {
                Breakpoint newInactiveBreakpoint = new Breakpoint(breakpoint.getType(), breakpoint.getLineNumber(), breakpoint.getPath(), breakpoint.getFile(), false);
                breakpointsForPath.set(i, newInactiveBreakpoint);
                BreakpointRenderer breakpointRenderer = getBreakpointRendererForFile(breakpoint.getPath());
                if (breakpointRenderer != null) {
                    breakpointRenderer.setBreakpointActive(breakpoint.getLineNumber(), false);
                }
            }
        }
    }
    deleteCurrentBreakpoint();
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) BreakpointRenderer(org.eclipse.che.ide.api.debug.BreakpointRenderer) HasBreakpointRenderer(org.eclipse.che.ide.api.debug.HasBreakpointRenderer) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint)

Aggregations

Breakpoint (org.eclipse.che.ide.api.debug.Breakpoint)18 ArrayList (java.util.ArrayList)6 BreakpointRenderer (org.eclipse.che.ide.api.debug.BreakpointRenderer)6 HasBreakpointRenderer (org.eclipse.che.ide.api.debug.HasBreakpointRenderer)6 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)4 LocationDto (org.eclipse.che.api.debug.shared.dto.LocationDto)3 Operation (org.eclipse.che.api.promises.client.Operation)3 PromiseError (org.eclipse.che.api.promises.client.PromiseError)3 BaseTest (org.eclipse.che.plugin.debugger.ide.BaseTest)3 Test (org.junit.Test)3 Storage (com.google.gwt.storage.client.Storage)2 LinkedList (java.util.LinkedList)2 BreakpointDto (org.eclipse.che.api.debug.shared.dto.BreakpointDto)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)2 BreakpointManagerObserver (org.eclipse.che.ide.api.debug.BreakpointManagerObserver)2 LineChangeAction (org.eclipse.che.ide.api.debug.BreakpointRenderer.LineChangeAction)2 StorableBreakpointDto (org.eclipse.che.ide.api.debug.dto.StorableBreakpointDto)2 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)2 Optional (com.google.common.base.Optional)1