Search in sources :

Example 6 with DebuggerObserver

use of org.eclipse.che.ide.debug.DebuggerObserver in project che by eclipse.

the class AbstractDebugger method stepInto.

@Override
public void stepInto() {
    if (isConnected()) {
        for (DebuggerObserver observer : observers) {
            observer.onPreStepInto();
        }
        removeCurrentLocation();
        preserveDebuggerState();
        StepIntoActionDto action = dtoFactory.createDto(StepIntoActionDto.class);
        action.setType(Action.TYPE.STEP_INTO);
        Promise<Void> promise = service.stepInto(debugSessionDto.getId(), action);
        promise.catchError(new Operation<PromiseError>() {

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

Example 7 with DebuggerObserver

use of org.eclipse.che.ide.debug.DebuggerObserver in project che by eclipse.

the class AbstractDebugger method connect.

@Override
public Promise<Void> connect(Map<String, String> connectionProperties) {
    if (isConnected()) {
        return Promises.reject(JsPromiseError.create("Debugger already connected"));
    }
    Promise<DebugSessionDto> connect = service.connect(debuggerType, connectionProperties);
    final DebuggerDescriptor debuggerDescriptor = toDescriptor(connectionProperties);
    Promise<Void> promise = connect.then(new Function<DebugSessionDto, Void>() {

        @Override
        public Void apply(final DebugSessionDto arg) throws FunctionException {
            DebuggerInfo debuggerInfo = arg.getDebuggerInfo();
            debuggerDescriptor.setInfo(debuggerInfo.getName() + " " + debuggerInfo.getVersion());
            setDebugSession(arg);
            preserveDebuggerState();
            startCheckingEvents();
            startDebugger(arg);
            return null;
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            Log.error(AbstractDebugger.class, arg.getMessage());
            throw new OperationException(arg.getCause());
        }
    });
    for (DebuggerObserver observer : observers) {
        observer.onDebuggerAttached(debuggerDescriptor, promise);
    }
    return promise;
}
Also used : DebuggerInfo(org.eclipse.che.api.debug.shared.model.DebuggerInfo) DebuggerDescriptor(org.eclipse.che.ide.debug.DebuggerDescriptor) Function(org.eclipse.che.api.promises.client.Function) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) PromiseError(org.eclipse.che.api.promises.client.PromiseError) DebugSessionDto(org.eclipse.che.api.debug.shared.dto.DebugSessionDto) DebuggerObserver(org.eclipse.che.ide.debug.DebuggerObserver) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 8 with DebuggerObserver

use of org.eclipse.che.ide.debug.DebuggerObserver 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)

Example 9 with DebuggerObserver

use of org.eclipse.che.ide.debug.DebuggerObserver in project che by eclipse.

the class AbstractDebugger method resume.

@Override
public void resume() {
    if (isConnected()) {
        for (DebuggerObserver observer : observers) {
            observer.onPreResume();
        }
        removeCurrentLocation();
        preserveDebuggerState();
        ResumeActionDto action = dtoFactory.createDto(ResumeActionDto.class);
        action.setType(Action.TYPE.RESUME);
        Promise<Void> promise = service.resume(debugSessionDto.getId(), action);
        promise.catchError(new Operation<PromiseError>() {

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

Example 10 with DebuggerObserver

use of org.eclipse.che.ide.debug.DebuggerObserver in project che by eclipse.

the class AbstractDebugger method setValue.

@Override
public void setValue(final Variable variable) {
    if (isConnected()) {
        Promise<Void> promise = service.setValue(debugSessionDto.getId(), asDto(variable));
        promise.then(new Operation<Void>() {

            @Override
            public void apply(Void arg) throws OperationException {
                for (DebuggerObserver observer : observers) {
                    observer.onValueChanged(variable.getVariablePath().getPath(), variable.getValue());
                }
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                Log.error(AbstractDebugger.class, arg.getMessage());
            }
        });
    }
}
Also used : 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) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

OperationException (org.eclipse.che.api.promises.client.OperationException)11 PromiseError (org.eclipse.che.api.promises.client.PromiseError)11 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)11 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)11 Operation (org.eclipse.che.api.promises.client.Operation)6 DebugSessionDto (org.eclipse.che.api.debug.shared.dto.DebugSessionDto)2 LocationDto (org.eclipse.che.api.debug.shared.dto.LocationDto)2 DebuggerInfo (org.eclipse.che.api.debug.shared.model.DebuggerInfo)2 Breakpoint (org.eclipse.che.ide.api.debug.Breakpoint)2 DebuggerDescriptor (org.eclipse.che.ide.debug.DebuggerDescriptor)2 BreakpointDto (org.eclipse.che.api.debug.shared.dto.BreakpointDto)1 ResumeActionDto (org.eclipse.che.api.debug.shared.dto.action.ResumeActionDto)1 StepIntoActionDto (org.eclipse.che.api.debug.shared.dto.action.StepIntoActionDto)1 StepOutActionDto (org.eclipse.che.api.debug.shared.dto.action.StepOutActionDto)1 StepOverActionDto (org.eclipse.che.api.debug.shared.dto.action.StepOverActionDto)1 DebuggerEventDto (org.eclipse.che.api.debug.shared.dto.event.DebuggerEventDto)1 Function (org.eclipse.che.api.promises.client.Function)1 Promise (org.eclipse.che.api.promises.client.Promise)1 JsPromise (org.eclipse.che.api.promises.client.js.JsPromise)1 WsAgentStateEvent (org.eclipse.che.ide.api.machine.events.WsAgentStateEvent)1