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();
}
}
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);
}
Aggregations