Search in sources :

Example 1 with StackFrameDumpDto

use of org.eclipse.che.api.debug.shared.dto.StackFrameDumpDto in project che by eclipse.

the class JavaDebugger method dumpStackFrame.

@Override
public StackFrameDumpDto dumpStackFrame() throws DebuggerException {
    lock.lock();
    try {
        final JdiStackFrame currentFrame = getCurrentFrame();
        StackFrameDumpDto dump = newDto(StackFrameDumpDto.class);
        boolean existInformation = true;
        JdiLocalVariable[] variables = new JdiLocalVariable[0];
        try {
            variables = currentFrame.getLocalVariables();
        } catch (DebuggerAbsentInformationException e) {
            existInformation = false;
        }
        for (JdiField f : currentFrame.getFields()) {
            List<String> variablePath = asList(f.isStatic() ? "static" : "this", f.getName());
            dump.getFields().add(newDto(FieldDto.class).withIsFinal(f.isFinal()).withIsStatic(f.isStatic()).withIsTransient(f.isTransient()).withIsVolatile(f.isVolatile()).withName(f.getName()).withExistInformation(existInformation).withValue(f.getValue().getAsString()).withType(f.getTypeName()).withVariablePath(newDto(VariablePathDto.class).withPath(variablePath)).withPrimitive(f.isPrimitive()));
        }
        for (JdiLocalVariable var : variables) {
            dump.getVariables().add(newDto(VariableDto.class).withName(var.getName()).withExistInformation(existInformation).withValue(var.getValue().getAsString()).withType(var.getTypeName()).withVariablePath(newDto(VariablePathDto.class).withPath(singletonList(var.getName()))).withPrimitive(var.isPrimitive()));
        }
        return dump;
    } finally {
        lock.unlock();
    }
}
Also used : StackFrameDumpDto(org.eclipse.che.api.debug.shared.dto.StackFrameDumpDto) VariableDto(org.eclipse.che.api.debug.shared.dto.VariableDto) DebuggerAbsentInformationException(org.eclipse.che.plugin.jdb.server.exceptions.DebuggerAbsentInformationException) FieldDto(org.eclipse.che.api.debug.shared.dto.FieldDto)

Example 2 with StackFrameDumpDto

use of org.eclipse.che.api.debug.shared.dto.StackFrameDumpDto in project che by eclipse.

the class DebuggerTest method testGetStackFrameDump.

@Test
public void testGetStackFrameDump() throws Exception {
    Promise<StackFrameDumpDto> promiseStackFrameDump = mock(Promise.class);
    StackFrameDumpDto mockStackFrameDumpDto = mock(StackFrameDumpDto.class);
    final String json = "json";
    doReturn(json).when(dtoFactory).toJson(mockStackFrameDumpDto);
    doReturn(promiseStackFrameDump).when(service).getStackFrameDump(SESSION_ID);
    doReturn(promiseStackFrameDump).when(promiseStackFrameDump).then((Function<StackFrameDumpDto, Object>) any());
    doReturn(promiseStackFrameDump).when(promiseStackFrameDump).catchError((Operation<PromiseError>) any());
    Promise<StackFrameDump> result = debugger.dumpStackFrame();
    assertEquals(promiseStackFrameDump, result);
}
Also used : StackFrameDumpDto(org.eclipse.che.api.debug.shared.dto.StackFrameDumpDto) PromiseError(org.eclipse.che.api.promises.client.PromiseError) StackFrameDump(org.eclipse.che.api.debug.shared.model.StackFrameDump) Matchers.anyString(org.mockito.Matchers.anyString) BaseTest(org.eclipse.che.plugin.debugger.ide.BaseTest) Test(org.junit.Test)

Aggregations

StackFrameDumpDto (org.eclipse.che.api.debug.shared.dto.StackFrameDumpDto)2 FieldDto (org.eclipse.che.api.debug.shared.dto.FieldDto)1 VariableDto (org.eclipse.che.api.debug.shared.dto.VariableDto)1 StackFrameDump (org.eclipse.che.api.debug.shared.model.StackFrameDump)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 BaseTest (org.eclipse.che.plugin.debugger.ide.BaseTest)1 DebuggerAbsentInformationException (org.eclipse.che.plugin.jdb.server.exceptions.DebuggerAbsentInformationException)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1