Search in sources :

Example 1 with Breakpoint

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());
                    }
                });
            }
        });
    }
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) Optional(com.google.common.base.Optional) FunctionException(org.eclipse.che.api.promises.client.FunctionException) Operation(org.eclipse.che.api.promises.client.Operation) StorableBreakpointDto(org.eclipse.che.ide.api.debug.dto.StorableBreakpointDto) Promise(org.eclipse.che.api.promises.client.Promise) Storage(com.google.gwt.storage.client.Storage) PromiseError(org.eclipse.che.api.promises.client.PromiseError) File(org.eclipse.che.ide.api.resources.File) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile)

Example 2 with Breakpoint

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());
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) LineChangeAction(org.eclipse.che.ide.api.debug.BreakpointRenderer.LineChangeAction) Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint)

Example 3 with Breakpoint

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();
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) BreakpointRenderer(org.eclipse.che.ide.api.debug.BreakpointRenderer) HasBreakpointRenderer(org.eclipse.che.ide.api.debug.HasBreakpointRenderer)

Example 4 with Breakpoint

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();
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) BreakpointRenderer(org.eclipse.che.ide.api.debug.BreakpointRenderer) HasBreakpointRenderer(org.eclipse.che.ide.api.debug.HasBreakpointRenderer) Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint)

Example 5 with Breakpoint

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);
            }
        }
    }
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) BreakpointRenderer(org.eclipse.che.ide.api.debug.BreakpointRenderer) HasBreakpointRenderer(org.eclipse.che.ide.api.debug.HasBreakpointRenderer) Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint)

Aggregations

Breakpoint (org.eclipse.che.ide.api.debug.Breakpoint)18 ArrayList (java.util.ArrayList)6 BreakpointRenderer (org.eclipse.che.ide.api.debug.BreakpointRenderer)6 HasBreakpointRenderer (org.eclipse.che.ide.api.debug.HasBreakpointRenderer)6 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)4 LocationDto (org.eclipse.che.api.debug.shared.dto.LocationDto)3 Operation (org.eclipse.che.api.promises.client.Operation)3 PromiseError (org.eclipse.che.api.promises.client.PromiseError)3 BaseTest (org.eclipse.che.plugin.debugger.ide.BaseTest)3 Test (org.junit.Test)3 Storage (com.google.gwt.storage.client.Storage)2 LinkedList (java.util.LinkedList)2 BreakpointDto (org.eclipse.che.api.debug.shared.dto.BreakpointDto)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)2 BreakpointManagerObserver (org.eclipse.che.ide.api.debug.BreakpointManagerObserver)2 LineChangeAction (org.eclipse.che.ide.api.debug.BreakpointRenderer.LineChangeAction)2 StorableBreakpointDto (org.eclipse.che.ide.api.debug.dto.StorableBreakpointDto)2 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)2 Optional (com.google.common.base.Optional)1