use of org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException in project che by eclipse.
the class NodeJsBreakpointsParser method parse.
@Override
public Breakpoints parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException {
final List<Breakpoint> breakpoints = new ArrayList<>();
JsonObject json = new JsonParser().parse(nodeJsOutput.getOutput()).getAsJsonObject();
if (json.has("breakpoints")) {
Iterator<JsonElement> iter = json.getAsJsonArray("breakpoints").iterator();
while (iter.hasNext()) {
JsonObject item = iter.next().getAsJsonObject();
try {
final String condition = item.has("condition") && !item.get("condition").isJsonNull() ? item.get("condition").getAsString() : null;
final boolean isEnabled = item.has("active") && !item.get("active").isJsonNull() && item.get("active").getAsBoolean();
final int lineNumber = item.get("line").getAsInt();
final String target;
String targetType = item.get("type").getAsString();
switch(targetType) {
case "scriptId":
target = String.valueOf(item.get("script_id").getAsInt());
break;
case "scriptRegExp":
target = item.get("script_regexp").getAsString();
break;
default:
throw new IllegalArgumentException("Unsupported 'type' value: " + targetType);
}
Location location = new LocationImpl(targetType + ":" + target, lineNumber + 1);
Breakpoint breakpoint = new BreakpointImpl(location, isEnabled, condition);
breakpoints.add(breakpoint);
} catch (Exception e) {
LOG.error("Failed to parse breakpoint: " + item.toString(), e);
}
}
}
return new Breakpoints(breakpoints);
}
use of org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException in project che by eclipse.
the class NodeJsStepParser method parse.
@Override
public Location parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException {
String output = nodeJsOutput.getOutput();
for (String line : output.split("\n")) {
Matcher matcher = PATTERN.matcher(line);
if (matcher.find()) {
String file = matcher.group(1);
String lineNumber = matcher.group(2);
return new LocationImpl(file, Integer.parseInt(lineNumber));
}
}
throw new NodeJsDebuggerParseException(Location.class, output);
}
use of org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException in project che by eclipse.
the class NodeJsBackTraceParser method parse.
@Override
public Location parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException {
String output = nodeJsOutput.getOutput();
for (String line : output.split("\n")) {
Matcher matcher = PATTERN.matcher(line);
if (matcher.find()) {
String file = matcher.group(2);
String lineNumber = matcher.group(3);
return new LocationImpl(file, Integer.parseInt(lineNumber));
}
}
throw new NodeJsDebuggerParseException(Location.class, output);
}
Aggregations