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());
}
});
}
}
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;
}
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);
}
}
}
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());
}
});
}
}
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());
}
});
}
}
Aggregations