Search in sources :

Example 16 with Breakpoint

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);
    }
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) Project(org.eclipse.che.ide.api.resources.Project) Storage(com.google.gwt.storage.client.Storage) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) Resource(org.eclipse.che.ide.api.resources.Resource) StorableBreakpointDto(org.eclipse.che.ide.api.debug.dto.StorableBreakpointDto) LinkedList(java.util.LinkedList)

Example 17 with Breakpoint

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);
        }
    }
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) Operation(org.eclipse.che.api.promises.client.Operation) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) PromiseError(org.eclipse.che.api.promises.client.PromiseError) BreakpointDto(org.eclipse.che.api.debug.shared.dto.BreakpointDto) DebuggerObserver(org.eclipse.che.ide.debug.DebuggerObserver) LocationDto(org.eclipse.che.api.debug.shared.dto.LocationDto) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 18 with 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);
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) ArrayList(java.util.ArrayList) AcceptsOneWidget(com.google.gwt.user.client.ui.AcceptsOneWidget) Test(org.junit.Test) BaseTest(org.eclipse.che.plugin.debugger.ide.BaseTest)

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