use of org.eclipse.che.api.debug.shared.model.impl.LocationImpl in project che by eclipse.
the class JavaDebuggerTest method testGetAllBreakpoints.
@Test(priority = 8)
public void testGetAllBreakpoints() throws Exception {
assertFalse(debugger.getAllBreakpoints().isEmpty());
debugger.deleteAllBreakpoints();
assertTrue(debugger.getAllBreakpoints().isEmpty());
debugger.addBreakpoint(new BreakpointImpl(new LocationImpl("com.HelloWorld", 18), false, null));
DebuggerEvent debuggerEvent = events.take();
assertTrue(debuggerEvent instanceof BreakpointActivatedEvent);
assertEquals(debugger.getAllBreakpoints().size(), 1);
Breakpoint breakpoint = debugger.getAllBreakpoints().get(0);
assertEquals(breakpoint.getLocation().getLineNumber(), 18);
assertEquals(breakpoint.getLocation().getTarget(), "com.HelloWorld");
assertTrue(breakpoint.isEnabled());
}
use of org.eclipse.che.api.debug.shared.model.impl.LocationImpl in project che by eclipse.
the class JavaDebuggerTest method testRemoveBreakpoint.
@Test(priority = 6)
public void testRemoveBreakpoint() throws Exception {
debugger.deleteBreakpoint(new LocationImpl("com.HelloWorld", 17));
assertEquals(debugger.getAllBreakpoints().size(), 1);
}
use of org.eclipse.che.api.debug.shared.model.impl.LocationImpl in project che by eclipse.
the class JavaDebuggerTest method testRemoveUnExistedBreakpoint.
@Test(priority = 7)
public void testRemoveUnExistedBreakpoint() throws Exception {
int breakpointsCount = debugger.getAllBreakpoints().size();
debugger.deleteBreakpoint(new LocationImpl("com.HelloWorld", 2));
assertEquals(debugger.getAllBreakpoints().size(), breakpointsCount);
}
use of org.eclipse.che.api.debug.shared.model.impl.LocationImpl in project che by eclipse.
the class JavaDebuggerUtils method getLocation.
/**
* Returns Location for current debugger resource.
*
* @param location
* location type from JVM
* @throws DebuggerException
* in case {@link org.eclipse.jdt.core.JavaModelException} or if Java {@link org.eclipse.jdt.core.IType}
* was not find
*/
public Location getLocation(com.sun.jdi.Location location) throws DebuggerException {
String fqn = location.declaringType().name();
List<IType> types;
try {
Pair<char[][], char[][]> fqnPair = prepareFqnToSearch(fqn);
types = findTypeByFqn(fqnPair.first, fqnPair.second, createWorkspaceScope());
} catch (JavaModelException e) {
throw new DebuggerException("Can't find class models by fqn: " + fqn, e);
}
if (types.isEmpty()) {
throw new DebuggerException("Type with fully qualified name: " + fqn + " was not found");
}
//TODO we need handle few result! It's temporary solution.
IType type = types.get(0);
String typeProjectPath = type.getJavaProject().getPath().toOSString();
if (type.isBinary()) {
IClassFile classFile = type.getClassFile();
int libId = classFile.getAncestor(IPackageFragmentRoot.PACKAGE_FRAGMENT_ROOT).hashCode();
return new LocationImpl(fqn, location.lineNumber(), null, true, libId, typeProjectPath);
} else {
ICompilationUnit compilationUnit = type.getCompilationUnit();
typeProjectPath = type.getJavaProject().getPath().toOSString();
String resourcePath = compilationUnit.getPath().toOSString();
return new LocationImpl(fqn, location.lineNumber(), resourcePath, false, -1, typeProjectPath);
}
}
use of org.eclipse.che.api.debug.shared.model.impl.LocationImpl in project che by eclipse.
the class GdbBacktrace method parse.
/**
* Factory method.
*/
public static GdbBacktrace parse(GdbOutput gdbOutput) throws GdbParseException {
Matcher matcher;
final String output = gdbOutput.getOutput();
final String[] framesInfo = output.split("#");
final Map<Integer, Location> frames = new HashMap<>(framesInfo.length);
for (String frame : framesInfo) {
try {
matcher = GDB_FILE_LOCATION.matcher(frame);
if (matcher.find()) {
final String fileLocation = matcher.group(2);
final int lineNumber = Integer.parseInt(matcher.group(3));
final int frameNumber = Integer.parseInt(matcher.group(1));
final Location location = new LocationImpl(fileLocation, lineNumber);
frames.put(frameNumber, location);
continue;
}
matcher = GDB_LIBRARY_LOCATION.matcher(frame);
if (matcher.find()) {
final int frameNumber = Integer.parseInt(matcher.group(1));
final String libraryLocation = matcher.group(2);
final Location location = new LocationImpl(libraryLocation);
frames.put(frameNumber, location);
}
} catch (NumberFormatException e) {
//we can't get info about current frame, but we are trying to get info about another frames
}
}
if (!frames.isEmpty()) {
return new GdbBacktrace(frames);
}
throw new GdbParseException(GdbBacktrace.class, output);
}
Aggregations