use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class Hover method setContents.
@SuppressWarnings("deprecation")
public Hover setContents(Object contents) {
if (contents instanceof List) {
final JSONArray json = new JSONArray();
for (Object obj : (List<?>) contents) {
json.put(obj instanceof MarkedString ? ((MarkedString) obj).jsonData : obj);
}
jsonData.put("contents", json);
} else if (contents instanceof MarkupContent) {
jsonData.put("contents", ((MarkupContent) contents).jsonData);
} else if (contents instanceof MarkedString) {
jsonData.put("contents", ((MarkedString) contents).jsonData);
} else {
jsonData.put("contents", contents);
}
return this;
}
use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class DocumentSymbol method getChildren.
/**
* Children of this symbol, e.g. properties of a class.
*/
public List<DocumentSymbol> getChildren() {
final JSONArray json = jsonData.optJSONArray("children");
if (json == null) {
return null;
}
final List<DocumentSymbol> list = new ArrayList<>(json.length());
for (int i = 0; i < json.length(); i++) {
list.add(new DocumentSymbol(json.getJSONObject(i)));
}
return Collections.unmodifiableList(list);
}
use of com.oracle.truffle.tools.utils.json.JSONArray 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.JSONArray in project graal by oracle.
the class DocumentSymbol method setChildren.
public DocumentSymbol setChildren(List<DocumentSymbol> children) {
if (children != null) {
final JSONArray json = new JSONArray();
for (DocumentSymbol documentSymbol : children) {
json.put(documentSymbol.jsonData);
}
jsonData.put("children", json);
}
return this;
}
use of com.oracle.truffle.tools.utils.json.JSONArray 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);
}
Aggregations