use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class ColorPresentation method setAdditionalTextEdits.
public ColorPresentation setAdditionalTextEdits(List<TextEdit> additionalTextEdits) {
if (additionalTextEdits != null) {
final JSONArray json = new JSONArray();
for (TextEdit textEdit : additionalTextEdits) {
json.put(textEdit.jsonData);
}
jsonData.put("additionalTextEdits", json);
}
return this;
}
use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class Command method create.
/**
* Creates a new Command literal.
*/
public static Command create(String title, String command, Object... args) {
final JSONObject json = new JSONObject();
json.put("title", title);
json.put("command", command);
if (args != null) {
JSONArray jsonArr = new JSONArray();
for (Object arg : args) {
jsonArr.put(arg);
}
json.put("arguments", jsonArr);
}
return new Command(json);
}
use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class CompletionList method getItems.
/**
* The completion items.
*/
public List<CompletionItem> getItems() {
final JSONArray json = jsonData.getJSONArray("items");
final List<CompletionItem> list = new ArrayList<>(json.length());
for (int i = 0; i < json.length(); i++) {
list.add(new CompletionItem(json.getJSONObject(i)));
}
return Collections.unmodifiableList(list);
}
use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class TruffleObject2JSON method fromArray.
static JSONArray fromArray(TruffleObject array) {
JSONArray json = new JSONArray();
long size;
try {
size = INTEROP.getArraySize(array);
} catch (UnsupportedMessageException ex) {
return json;
}
if (size > 0) {
for (long i = 0; i < size; i++) {
try {
Object value = INTEROP.readArrayElement(array, i);
json.put((int) i, from(value));
} catch (UnsupportedMessageException | InvalidArrayIndexException ex) {
// ignore that element
break;
}
}
}
return json;
}
use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class InspectServerSession method getDomains.
private static Params getDomains() {
JSONArray domains = new JSONArray();
domains.put(createJsonDomain("Runtime"));
domains.put(createJsonDomain("Debugger"));
domains.put(createJsonDomain("Profiler"));
domains.put(createJsonDomain("Schema"));
JSONObject domainsObj = new JSONObject();
domainsObj.put("domains", domains);
return new Params(domainsObj);
}
Aggregations