Search in sources :

Example 6 with Breakpoint

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

the class BreakpointManagerImpl method changeBreakpointState.

@Override
public void changeBreakpointState(final int lineNumber) {
    EditorPartPresenter editor = editorAgent.getActiveEditor();
    if (editor == null) {
        return;
    }
    final VirtualFile activeFile = editor.getEditorInput().getFile();
    List<Breakpoint> pathBreakpoints = breakpoints.get(activeFile.getLocation().toString());
    if (pathBreakpoints != null) {
        for (final Breakpoint breakpoint : pathBreakpoints) {
            if (breakpoint.getLineNumber() == lineNumber) {
                // breakpoint already exists at given line
                deleteBreakpoint(activeFile, breakpoint);
                return;
            }
        }
    }
    if (isLineNotEmpty(activeFile, lineNumber)) {
        Breakpoint breakpoint = new Breakpoint(BREAKPOINT, lineNumber, activeFile.getLocation().toString(), activeFile, false);
        addBreakpoint(breakpoint);
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 7 with Breakpoint

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

the class AbstractDebugger method deleteBreakpoint.

@Override
public void deleteBreakpoint(final VirtualFile file, final int lineNumber) {
    if (!isConnected()) {
        return;
    }
    LocationDto locationDto = dtoFactory.createDto(LocationDto.class);
    locationDto.setLineNumber(lineNumber + 1);
    String fqn = pathToFqn(file);
    if (fqn == null) {
        return;
    }
    locationDto.setTarget(fqn);
    Promise<Void> promise = service.deleteBreakpoint(debugSessionDto.getId(), locationDto);
    promise.then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            for (DebuggerObserver observer : observers) {
                Breakpoint breakpoint = new Breakpoint(Breakpoint.Type.BREAKPOINT, lineNumber, file.getLocation().toString(), file, false);
                observer.onBreakpointDeleted(breakpoint);
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            Log.error(AbstractDebugger.class, arg.getMessage());
        }
    });
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) DebuggerObserver(org.eclipse.che.ide.debug.DebuggerObserver) LocationDto(org.eclipse.che.api.debug.shared.dto.LocationDto) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 8 with Breakpoint

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

the class AbstractDebugger method startDebugger.

protected void startDebugger(final DebugSessionDto debugSessionDto) {
    List<BreakpointDto> breakpoints = new ArrayList<>();
    for (Breakpoint breakpoint : breakpointManager.getBreakpointList()) {
        LocationDto locationDto = dtoFactory.createDto(LocationDto.class).withLineNumber(breakpoint.getLineNumber() + 1).withResourcePath(breakpoint.getPath()).withResourceProjectPath(getProject(breakpoint.getFile()).getPath());
        String target = pathToFqn(breakpoint.getFile());
        if (target != null) {
            locationDto.setTarget(target);
            BreakpointDto breakpointDto = dtoFactory.createDto(BreakpointDto.class);
            breakpointDto.setLocation(locationDto);
            breakpointDto.setEnabled(true);
            breakpoints.add(breakpointDto);
        }
    }
    StartActionDto action = dtoFactory.createDto(StartActionDto.class);
    action.setType(Action.TYPE.START);
    action.setBreakpoints(breakpoints);
    service.start(debugSessionDto.getId(), action);
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) ArrayList(java.util.ArrayList) BreakpointDto(org.eclipse.che.api.debug.shared.dto.BreakpointDto) LocationDto(org.eclipse.che.api.debug.shared.dto.LocationDto) StartActionDto(org.eclipse.che.api.debug.shared.dto.action.StartActionDto)

Example 9 with Breakpoint

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

the class DebuggerPresenterTest method testOnBreakpointDeleted.

@Test
public void testOnBreakpointDeleted() {
    Breakpoint breakpoint = mock(Breakpoint.class);
    List<Breakpoint> breakpoints = new ArrayList<>();
    doReturn(breakpoints).when(breakpointManager).getBreakpointList();
    presenter.onBreakpointDeleted(breakpoint);
    verify(breakpointManager, times(2)).getBreakpointList();
    verify(view).setBreakpoints(any());
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(org.eclipse.che.plugin.debugger.ide.BaseTest)

Example 10 with Breakpoint

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

the class DebuggerPresenterTest method testOnBreakpointAdded.

@Test
public void testOnBreakpointAdded() {
    Breakpoint breakpoint = mock(Breakpoint.class);
    List<Breakpoint> breakpoints = new ArrayList<>();
    doReturn(breakpoints).when(breakpointManager).getBreakpointList();
    presenter.onBreakpointAdded(breakpoint);
    verify(presenter).updateBreakpoints();
    verify(breakpointManager, times(2)).getBreakpointList();
    verify(view).setBreakpoints(any());
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(org.eclipse.che.plugin.debugger.ide.BaseTest)

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