Search in sources :

Example 1 with SimpleValue

use of org.eclipse.che.api.debug.shared.model.SimpleValue in project che by eclipse.

the class DebuggerPresenter method onExpandVariablesTree.

@Override
public void onExpandVariablesTree() {
    List<? extends Variable> rootVariables = selectedVariable.getVariables();
    if (rootVariables.isEmpty()) {
        Debugger debugger = debuggerManager.getActiveDebugger();
        if (debugger != null) {
            Promise<SimpleValue> promise = debugger.getValue(selectedVariable);
            promise.then(new Operation<SimpleValue>() {

                @Override
                public void apply(SimpleValue arg) throws OperationException {
                    selectedVariable.setValue(arg.getValue());
                    view.setVariablesIntoSelectedVariable(arg.getVariables());
                    view.updateSelectedVariable();
                }
            }).catchError(new Operation<PromiseError>() {

                @Override
                public void apply(PromiseError arg) throws OperationException {
                    notificationManager.notify(constant.failedToGetVariableValueTitle(), arg.getMessage(), FAIL, FLOAT_MODE);
                }
            });
        }
    }
}
Also used : Debugger(org.eclipse.che.ide.debug.Debugger) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException) SimpleValue(org.eclipse.che.api.debug.shared.model.SimpleValue)

Example 2 with SimpleValue

use of org.eclipse.che.api.debug.shared.model.SimpleValue in project che by eclipse.

the class DebuggerTest method testGetValue.

@Test
public void testGetValue() throws Exception {
    final VariableDto variableDto = mock(VariableDto.class);
    final Variable variable = mock(Variable.class);
    final Promise<SimpleValueDto> promiseValue = mock(Promise.class);
    doReturn(variableDto).when(dtoFactory).createDto(VariableDto.class);
    doReturn(mock(VariablePathDto.class)).when(dtoFactory).createDto(VariablePathDto.class);
    doReturn(mock(VariablePathDto.class)).when(variable).getVariablePath();
    doReturn(Collections.emptyList()).when(variable).getVariables();
    doReturn(promiseValue).when(service).getValue(SESSION_ID, variableDto);
    doReturn(promiseValue).when(promiseValue).then((Function<SimpleValueDto, Object>) any());
    doReturn(promiseValue).when(promiseValue).catchError((Operation<PromiseError>) any());
    Promise<SimpleValue> result = debugger.getValue(variable);
    assertEquals(promiseValue, result);
}
Also used : Variable(org.eclipse.che.api.debug.shared.model.Variable) VariablePathDto(org.eclipse.che.api.debug.shared.dto.VariablePathDto) PromiseError(org.eclipse.che.api.promises.client.PromiseError) VariableDto(org.eclipse.che.api.debug.shared.dto.VariableDto) SimpleValueDto(org.eclipse.che.api.debug.shared.dto.SimpleValueDto) SimpleValue(org.eclipse.che.api.debug.shared.model.SimpleValue) BaseTest(org.eclipse.che.plugin.debugger.ide.BaseTest) Test(org.junit.Test)

Example 3 with SimpleValue

use of org.eclipse.che.api.debug.shared.model.SimpleValue in project che by eclipse.

the class ZendDbgSessionTest method testGetValue.

@Test(groups = { "zendDbg" }, dependsOnGroups = { "checkPHP" })
public void testGetValue() throws Exception {
    List<Breakpoint> breakpoints = new ArrayList<>();
    Breakpoint bp1 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgClassesFile, 16));
    breakpoints.add(bp1);
    triggerSession(dbgHelloFile, getDbgSettings(false, false), breakpoints);
    awaitBreakpointActivated(bp1);
    awaitSuspend(dbgClassesFile, 16);
    debugger.dumpStackFrame();
    VariablePath variablePath = new VariablePathImpl("0");
    SimpleValue simpleValue = debugger.getValue(variablePath);
    assertEquals(simpleValue.getVariables().size(), 3);
    List<String> path = Arrays.asList("0", "0");
    variablePath = new VariablePathImpl(path);
    simpleValue = debugger.getValue(variablePath);
    assertEquals(simpleValue.getValue(), "\"A\"");
    path = Arrays.asList("0", "1");
    variablePath = new VariablePathImpl(path);
    simpleValue = debugger.getValue(variablePath);
    assertEquals(simpleValue.getValue(), "123");
    path = Arrays.asList("0", "2");
    variablePath = new VariablePathImpl(path);
    simpleValue = debugger.getValue(variablePath);
    assertEquals(simpleValue.getValue(), "array [3]");
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) VariablePath(org.eclipse.che.api.debug.shared.model.VariablePath) BreakpointImpl(org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl) VariablePathImpl(org.eclipse.che.api.debug.shared.model.impl.VariablePathImpl) ArrayList(java.util.ArrayList) SimpleValue(org.eclipse.che.api.debug.shared.model.SimpleValue) Test(org.testng.annotations.Test)

Example 4 with SimpleValue

use of org.eclipse.che.api.debug.shared.model.SimpleValue in project che by eclipse.

the class GdbDebuggerTest method doSetAndGetValues.

private void doSetAndGetValues() throws DebuggerException {
    VariablePath variablePath = new VariablePathImpl("i");
    Variable variable = new VariableImpl("int", "i", "2", true, variablePath, Collections.emptyList(), false);
    SimpleValue value = gdbDebugger.getValue(variablePath);
    assertEquals(value.getValue(), "0");
    gdbDebugger.setValue(variable);
    value = gdbDebugger.getValue(variablePath);
    assertEquals(value.getValue(), "2");
    String expression = gdbDebugger.evaluate("i");
    assertEquals(expression, "2");
    expression = gdbDebugger.evaluate("10 + 10");
    assertEquals(expression, "20");
    StackFrameDump stackFrameDump = gdbDebugger.dumpStackFrame();
    assertTrue(stackFrameDump.getFields().isEmpty());
    assertEquals(stackFrameDump.getVariables().size(), 1);
    assertEquals(stackFrameDump.getVariables().get(0).getName(), "i");
    assertEquals(stackFrameDump.getVariables().get(0).getValue(), "2");
    assertEquals(stackFrameDump.getVariables().get(0).getType(), "int");
}
Also used : VariablePath(org.eclipse.che.api.debug.shared.model.VariablePath) VariableImpl(org.eclipse.che.api.debug.shared.model.impl.VariableImpl) Variable(org.eclipse.che.api.debug.shared.model.Variable) VariablePathImpl(org.eclipse.che.api.debug.shared.model.impl.VariablePathImpl) StackFrameDump(org.eclipse.che.api.debug.shared.model.StackFrameDump) SimpleValue(org.eclipse.che.api.debug.shared.model.SimpleValue)

Aggregations

SimpleValue (org.eclipse.che.api.debug.shared.model.SimpleValue)4 Variable (org.eclipse.che.api.debug.shared.model.Variable)2 VariablePath (org.eclipse.che.api.debug.shared.model.VariablePath)2 VariablePathImpl (org.eclipse.che.api.debug.shared.model.impl.VariablePathImpl)2 PromiseError (org.eclipse.che.api.promises.client.PromiseError)2 ArrayList (java.util.ArrayList)1 SimpleValueDto (org.eclipse.che.api.debug.shared.dto.SimpleValueDto)1 VariableDto (org.eclipse.che.api.debug.shared.dto.VariableDto)1 VariablePathDto (org.eclipse.che.api.debug.shared.dto.VariablePathDto)1 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)1 StackFrameDump (org.eclipse.che.api.debug.shared.model.StackFrameDump)1 BreakpointImpl (org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl)1 VariableImpl (org.eclipse.che.api.debug.shared.model.impl.VariableImpl)1 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 Debugger (org.eclipse.che.ide.debug.Debugger)1 BaseTest (org.eclipse.che.plugin.debugger.ide.BaseTest)1 Test (org.junit.Test)1 Test (org.testng.annotations.Test)1