use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.
the class BreakpointManagerImpl method restoreBreakpoints.
private void restoreBreakpoints() {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage == null) {
return;
}
String data = localStorage.getItem(LOCAL_STORAGE_BREAKPOINTS_KEY);
if (data == null || data.isEmpty()) {
return;
}
List<StorableBreakpointDto> allDtoBreakpoints = dtoFactory.createListDtoFromJson(data, StorableBreakpointDto.class);
Promise<Void> bpPromise = promises.resolve(null);
for (final StorableBreakpointDto dto : allDtoBreakpoints) {
bpPromise.thenPromise(new Function<Void, Promise<Void>>() {
@Override
public Promise<Void> apply(Void ignored) throws FunctionException {
return appContext.getWorkspaceRoot().getFile(dto.getPath()).then(new Function<Optional<File>, Void>() {
@Override
public Void apply(Optional<File> file) throws FunctionException {
if (!file.isPresent()) {
return null;
}
if (dto.getType() == Type.CURRENT) {
doSetCurrentBreakpoint(file.get(), dto.getLineNumber());
} else {
addBreakpoint(new Breakpoint(dto.getType(), dto.getLineNumber(), dto.getPath(), file.get(), dto.isActive()));
}
return null;
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
Log.error(getClass(), "Failed to restore breakpoint. ", arg.getCause());
}
});
}
});
}
}
use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.
the class BreakpointManagerImpl method reAddBreakpointMark.
private void reAddBreakpointMark(BreakpointRenderer breakpointRenderer, Breakpoint breakpoint) {
int lineNumber = breakpoint.getLineNumber();
breakpointRenderer.addBreakpointMark(lineNumber, new LineChangeAction() {
@Override
public void onLineChange(VirtualFile file, int firstLine, int linesAdded, int linesRemoved) {
BreakpointManagerImpl.this.onLineChange(file, firstLine, linesAdded, linesRemoved);
}
});
breakpointRenderer.setBreakpointActive(lineNumber, breakpoint.isActive());
}
use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.
the class BreakpointManagerImpl method doDeleteBreakpoint.
/**
* Deletes breakpoint from the list.
*/
private void doDeleteBreakpoint(Breakpoint breakpoint) {
BreakpointRenderer breakpointRenderer = getBreakpointRendererForFile(breakpoint.getPath());
if (breakpointRenderer != null) {
breakpointRenderer.removeBreakpointMark(breakpoint.getLineNumber());
}
String path = breakpoint.getPath();
List<Breakpoint> pathBreakpoints = breakpoints.get(path);
if (pathBreakpoints != null) {
pathBreakpoints.remove(breakpoint);
if (pathBreakpoints.isEmpty()) {
breakpoints.remove(breakpoint.getPath());
}
}
preserveBreakpoints();
}
use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.
the class BreakpointManagerImpl method onBreakpointAdded.
@Override
public void onBreakpointAdded(Breakpoint breakpoint) {
String path = breakpoint.getPath();
List<Breakpoint> breakpointsForPath = breakpoints.get(path);
if (breakpointsForPath == null) {
breakpointsForPath = new ArrayList<>();
breakpoints.put(path, breakpointsForPath);
}
int i = breakpointsForPath.indexOf(breakpoint);
if (i == -1) {
breakpointsForPath.add(breakpoint);
} else {
breakpointsForPath.set(i, breakpoint);
}
BreakpointRenderer breakpointRenderer = getBreakpointRendererForFile(breakpoint.getPath());
if (breakpointRenderer != null) {
breakpointRenderer.setBreakpointActive(breakpoint.getLineNumber(), breakpoint.isActive());
}
preserveBreakpoints();
}
use of org.eclipse.che.ide.api.debug.Breakpoint in project che by eclipse.
the class BreakpointManagerImpl method onBreakpointActivated.
@Override
public void onBreakpointActivated(String filePath, int lineNumber) {
List<Breakpoint> breakpointsForPath = breakpoints.get(filePath);
if (breakpointsForPath == null) {
return;
}
for (int i = 0; i < breakpointsForPath.size(); i++) {
Breakpoint breakpoint = breakpointsForPath.get(i);
if (breakpoint.getLineNumber() == lineNumber) {
Breakpoint newActiveBreakpoint = new Breakpoint(breakpoint.getType(), breakpoint.getLineNumber(), breakpoint.getPath(), breakpoint.getFile(), true);
breakpointsForPath.set(i, newActiveBreakpoint);
preserveBreakpoints();
BreakpointRenderer breakpointRenderer = getBreakpointRendererForFile(breakpoint.getPath());
if (breakpointRenderer != null) {
breakpointRenderer.setBreakpointActive(breakpoint.getLineNumber(), true);
}
}
}
}
Aggregations