use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.
the class BreakpointManagerImpl method changeBreakpointState.
@Override
public void changeBreakpointState(final int lineNumber) {
EditorPartPresenter editor = editorAgent.getActiveEditor();
if (editor == null) {
return;
}
final VirtualFile activeFile = editor.getEditorInput().getFile();
List<Breakpoint> pathBreakpoints = breakpoints.get(activeFile.getLocation().toString());
if (pathBreakpoints != null) {
for (final Breakpoint breakpoint : pathBreakpoints) {
if (breakpoint.getLineNumber() == lineNumber) {
// breakpoint already exists at given line
deleteBreakpoint(activeFile, breakpoint);
return;
}
}
}
if (isLineNotEmpty(activeFile, lineNumber)) {
Breakpoint breakpoint = new Breakpoint(BREAKPOINT, lineNumber, activeFile.getLocation().toString(), activeFile, false);
addBreakpoint(breakpoint);
}
}
use of org.eclipse.che.ide.api.debug.Breakpoint 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.ide.api.debug.Breakpoint 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.ide.api.debug.Breakpoint in project che by eclipse.
the class DebuggerPresenterTest method testOnBreakpointDeleted.
@Test
public void testOnBreakpointDeleted() {
Breakpoint breakpoint = mock(Breakpoint.class);
List<Breakpoint> breakpoints = new ArrayList<>();
doReturn(breakpoints).when(breakpointManager).getBreakpointList();
presenter.onBreakpointDeleted(breakpoint);
verify(breakpointManager, times(2)).getBreakpointList();
verify(view).setBreakpoints(any());
}
use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.
the class DebuggerPresenterTest method testOnBreakpointAdded.
@Test
public void testOnBreakpointAdded() {
Breakpoint breakpoint = mock(Breakpoint.class);
List<Breakpoint> breakpoints = new ArrayList<>();
doReturn(breakpoints).when(breakpointManager).getBreakpointList();
presenter.onBreakpointAdded(breakpoint);
verify(presenter).updateBreakpoints();
verify(breakpointManager, times(2)).getBreakpointList();
verify(view).setBreakpoints(any());
}
Aggregations