use of com.oracle.truffle.tools.utils.json.JSONObject in project graal by oracle.
the class DocumentSymbol method create.
/**
* Creates a new symbol information literal.
*
* @param name The name of the symbol.
* @param detail The detail of the symbol.
* @param kind The kind of the symbol.
* @param range The range of the symbol.
* @param selectionRange The selectionRange of the symbol.
* @param children Children of the symbol.
*/
public static DocumentSymbol create(String name, String detail, SymbolKind kind, Range range, Range selectionRange, List<DocumentSymbol> children) {
final JSONObject json = new JSONObject();
json.put("name", name);
json.putOpt("detail", detail);
json.put("kind", kind.getIntValue());
json.put("range", range.jsonData);
json.put("selectionRange", selectionRange.jsonData);
if (children != null) {
JSONArray childrenJsonArr = new JSONArray();
for (DocumentSymbol documentSymbol : children) {
childrenJsonArr.put(documentSymbol.jsonData);
}
json.put("children", childrenJsonArr);
}
return new DocumentSymbol(json);
}
use of com.oracle.truffle.tools.utils.json.JSONObject in project graal by oracle.
the class CPUSamplerCLI method printSamplingJson.
private static void printSamplingJson(PrintStream out, OptionValues options, Map<TruffleContext, CPUSamplerData> data) {
boolean gatheredHitTimes = options.get(GATHER_HIT_TIMES);
JSONObject output = new JSONObject();
output.put("tool", CPUSamplerInstrument.ID);
output.put("version", CPUSamplerInstrument.VERSION);
JSONArray contexts = new JSONArray();
for (CPUSamplerData samplerData : data.values()) {
contexts.put(perContextData(samplerData, gatheredHitTimes));
}
output.put("contexts", contexts);
out.println(output);
}
use of com.oracle.truffle.tools.utils.json.JSONObject in project graal by oracle.
the class ResultsPrinter method printRawResults.
void printRawResults() {
JSONArray output = new JSONArray();
for (Results results : resultsList) {
JSONObject jsonResults = new JSONObject();
jsonResults.put("location", results.location);
jsonResults.put("samples", new JSONArray(results.samples));
output.put(jsonResults);
}
stream.print(output);
}
use of com.oracle.truffle.tools.utils.json.JSONObject in project graal by oracle.
the class DelegateServers method mergeResults.
public Object mergeResults(Object id, Object result) {
Object allResults = result;
for (DelegateServer ds : delegateServers) {
try {
JSONObject message = ds.awaitMessage(id);
if (message != null && logger.isLoggable(Level.FINER)) {
String format = "[Trace - %s] Received response from %s: %s";
logger.log(Level.FINER, String.format(format, Instant.now().toString(), ds.toString(), message.toString()));
}
allResults = mergeResults(allResults, message);
} catch (InterruptedException iex) {
}
}
return allResults;
}
use of com.oracle.truffle.tools.utils.json.JSONObject in project graal by oracle.
the class DelegateServers method findContextLanguage.
private String findContextLanguage(JSONObject params) {
JSONObject textDocument = params != null ? params.optJSONObject("textDocument") : null;
Object uri = textDocument != null ? textDocument.opt("uri") : null;
return uri instanceof String ? truffleAdapter.getLanguageId(URI.create((String) uri)) : null;
}
Aggregations