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