use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.
the class BreakpointManagerImpl method preserveBreakpoints.
private void preserveBreakpoints() {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null) {
List<StorableBreakpointDto> allDtoBreakpoints = new LinkedList<StorableBreakpointDto>();
List<Breakpoint> allBreakpoints = getBreakpointList();
if (currentBreakpoint != null) {
allBreakpoints.add(currentBreakpoint);
}
for (Breakpoint breakpoint : allBreakpoints) {
StorableBreakpointDto dto = dtoFactory.createDto(StorableBreakpointDto.class);
dto.setType(breakpoint.getType());
dto.setPath(breakpoint.getPath());
dto.setLineNumber(breakpoint.getLineNumber());
if (breakpoint.getFile() instanceof Resource) {
final Optional<Project> project = ((Resource) breakpoint.getFile()).getRelatedProject();
if (project.isPresent()) {
final ProjectConfigDto projectDto = dtoFactory.createDto(ProjectConfigDto.class).withName(project.get().getName()).withPath(project.get().getPath()).withType(project.get().getType()).withDescription(project.get().getDescription()).withAttributes(project.get().getAttributes()).withMixins(project.get().getMixins());
//TODO need to think to change argument type from dto to model interface
dto.setFileProjectConfig(projectDto);
}
}
dto.setActive(breakpoint.isActive());
allDtoBreakpoints.add(dto);
}
String data = dtoFactory.toJson(allDtoBreakpoints);
localStorage.setItem(LOCAL_STORAGE_BREAKPOINTS_KEY, data);
}
}
use of org.eclipse.che.ide.api.debug.Breakpoint 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.api.debug.Breakpoint in project che by eclipse.
the class DebuggerPresenterTest method testGo.
@Test
public void testGo() {
AcceptsOneWidget container = mock(AcceptsOneWidget.class);
List<Breakpoint> breakpoints = new ArrayList<>();
doReturn(breakpoints).when(breakpointManager).getBreakpointList();
doReturn(container).when(view).getDebuggerToolbarPanel();
presenter.go(container);
verify(view).setBreakpoints(breakpoints);
verify(view).setVariables(any());
verify(container).setWidget(view);
verify(debuggerToolbar).go(container);
}
Aggregations