use of com.oracle.truffle.tools.chromeinspector.ScriptsHandler.LoadScriptListener in project graal by oracle.
the class BreakpointsHandler method createURLBreakpoint.
Params createURLBreakpoint(Object url, int line, int column, String condition) {
JSONArray locations = new JSONArray();
long id;
LoadScriptListener scriptListener;
synchronized (bpIDs) {
id = ++lastID;
scriptListener = script -> {
if (url instanceof Pattern ? ((Pattern) url).matcher(script.getUrl()).matches() : url.equals(script.getUrl())) {
Breakpoint bp = createBuilder(script.getSource(), line, column).resolveListener(resolvedHandler).build();
if (condition != null && !condition.isEmpty()) {
bp.setCondition(condition);
}
bp = ds.install(bp);
synchronized (bpIDs) {
bpIDs.put(bp, id);
SourceSection section = resolvedBreakpoints.remove(bp);
if (section != null) {
Location resolvedLocation = new Location(script.getId(), section.getStartLine(), section.getStartColumn());
locations.put(resolvedLocation.toJSON());
}
}
}
};
scriptListeners.put(id, scriptListener);
}
slh.addLoadScriptListener(scriptListener);
JSONObject json = new JSONObject();
json.put("breakpointId", Long.toString(id));
json.put("locations", locations);
return new Params(json);
}
use of com.oracle.truffle.tools.chromeinspector.ScriptsHandler.LoadScriptListener in project graal by oracle.
the class BreakpointsHandler method removeBreakpoint.
boolean removeBreakpoint(String idStr) {
boolean bpRemoved = false;
try {
long id = Long.parseLong(idStr);
synchronized (bpIDs) {
Iterator<Map.Entry<Breakpoint, Long>> bpEntryIt = bpIDs.entrySet().iterator();
while (bpEntryIt.hasNext()) {
Map.Entry<Breakpoint, Long> bpEntry = bpEntryIt.next();
if (id == bpEntry.getValue().longValue()) {
Breakpoint bp = bpEntry.getKey();
if (bp != null) {
bp.dispose();
}
bpEntryIt.remove();
bpRemoved = true;
}
}
LoadScriptListener scriptListener = scriptListeners.remove(id);
if (scriptListener != null) {
slh.removeLoadScriptListener(scriptListener);
bpRemoved = true;
}
}
} catch (NumberFormatException nfex) {
}
return bpRemoved;
}
Aggregations