Search in sources :

Example 1 with LocationDto

use of org.eclipse.che.api.debug.shared.dto.LocationDto 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 2 with LocationDto

use of org.eclipse.che.api.debug.shared.dto.LocationDto 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 3 with LocationDto

use of org.eclipse.che.api.debug.shared.dto.LocationDto in project che by eclipse.

the class AbstractDebugger method onEventListReceived.

private void onEventListReceived(@NotNull DebuggerEventDto event) {
    LocationDto newLocationDto;
    switch(event.getType()) {
        case SUSPEND:
            newLocationDto = ((SuspendEventDto) event).getLocation();
            break;
        case BREAKPOINT_ACTIVATED:
            BreakpointDto breakpointDto = ((BreakpointActivatedEventDto) event).getBreakpoint();
            onBreakpointActivated(breakpointDto.getLocation());
            return;
        case DISCONNECT:
            disconnect();
            return;
        default:
            Log.error(AbstractDebugger.class, "Unknown debuggerType of debugger event: " + event.getType());
            return;
    }
    if (newLocationDto != null) {
        currentLocation = newLocationDto;
        openCurrentFile();
    }
    preserveDebuggerState();
}
Also used : BreakpointDto(org.eclipse.che.api.debug.shared.dto.BreakpointDto) BreakpointActivatedEventDto(org.eclipse.che.api.debug.shared.dto.event.BreakpointActivatedEventDto) LocationDto(org.eclipse.che.api.debug.shared.dto.LocationDto)

Example 4 with LocationDto

use of org.eclipse.che.api.debug.shared.dto.LocationDto in project che by eclipse.

the class DebuggerPresenterTest method testOnBreakpointStopped.

@Test
public void testOnBreakpointStopped() {
    String filePath = "filePath";
    String className = "className";
    int lineNumber = 40;
    LocationDto executionPoint = mock(LocationDto.class);
    doReturn(executionPoint).when(dtoFactory).createDto(LocationDto.class);
    doReturn(promiseString).when(debugger).dumpStackFrame();
    doReturn(promiseString).when(promiseString).then((Operation<String>) any());
    presenter.onBreakpointStopped(filePath, className, lineNumber);
    verify(presenter).showAndUpdateView();
    verify(view).setExecutionPoint(any(Location.class));
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) LocationDto(org.eclipse.che.api.debug.shared.dto.LocationDto) Location(org.eclipse.che.api.debug.shared.model.Location) Test(org.junit.Test) BaseTest(org.eclipse.che.plugin.debugger.ide.BaseTest)

Example 5 with LocationDto

use of org.eclipse.che.api.debug.shared.dto.LocationDto in project che by eclipse.

the class AbstractDebugger method addBreakpoint.

@Override
public void addBreakpoint(final VirtualFile file, final int lineNumber) {
    if (isConnected()) {
        String fqn = pathToFqn(file);
        if (fqn == null) {
            return;
        }
        final String filePath = file.getLocation().toString();
        LocationDto locationDto = dtoFactory.createDto(LocationDto.class).withLineNumber(lineNumber + 1).withTarget(fqn).withResourcePath(filePath).withResourceProjectPath(getProject(file).getPath());
        BreakpointDto breakpointDto = dtoFactory.createDto(BreakpointDto.class).withLocation(locationDto).withEnabled(true);
        Promise<Void> promise = service.addBreakpoint(debugSessionDto.getId(), breakpointDto);
        promise.then(new Operation<Void>() {

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

            @Override
            public void apply(PromiseError arg) throws OperationException {
                Log.error(AbstractDebugger.class, arg.getMessage());
            }
        });
    } else {
        Breakpoint breakpoint = new Breakpoint(Breakpoint.Type.BREAKPOINT, lineNumber, file.getLocation().toString(), file, false);
        for (DebuggerObserver observer : observers) {
            observer.onBreakpointAdded(breakpoint);
        }
    }
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) Operation(org.eclipse.che.api.promises.client.Operation) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) PromiseError(org.eclipse.che.api.promises.client.PromiseError) BreakpointDto(org.eclipse.che.api.debug.shared.dto.BreakpointDto) DebuggerObserver(org.eclipse.che.ide.debug.DebuggerObserver) LocationDto(org.eclipse.che.api.debug.shared.dto.LocationDto) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

LocationDto (org.eclipse.che.api.debug.shared.dto.LocationDto)5 Breakpoint (org.eclipse.che.ide.api.debug.Breakpoint)4 BreakpointDto (org.eclipse.che.api.debug.shared.dto.BreakpointDto)3 Operation (org.eclipse.che.api.promises.client.Operation)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 PromiseError (org.eclipse.che.api.promises.client.PromiseError)2 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)2 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)2 ArrayList (java.util.ArrayList)1 StartActionDto (org.eclipse.che.api.debug.shared.dto.action.StartActionDto)1 BreakpointActivatedEventDto (org.eclipse.che.api.debug.shared.dto.event.BreakpointActivatedEventDto)1 Location (org.eclipse.che.api.debug.shared.model.Location)1 BaseTest (org.eclipse.che.plugin.debugger.ide.BaseTest)1 Test (org.junit.Test)1