Search in sources :

Example 1 with BreakpointDto

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

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

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

BreakpointDto (org.eclipse.che.api.debug.shared.dto.BreakpointDto)3 LocationDto (org.eclipse.che.api.debug.shared.dto.LocationDto)3 Breakpoint (org.eclipse.che.ide.api.debug.Breakpoint)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 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)1 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)1