Search in sources :

Example 46 with JSONArray

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;
}
Also used : JSONArray(com.oracle.truffle.tools.utils.json.JSONArray)

Example 47 with JSONArray

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);
}
Also used : JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) JSONArray(com.oracle.truffle.tools.utils.json.JSONArray) JSONObject(com.oracle.truffle.tools.utils.json.JSONObject)

Example 48 with JSONArray

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);
}
Also used : JSONArray(com.oracle.truffle.tools.utils.json.JSONArray) ArrayList(java.util.ArrayList)

Example 49 with JSONArray

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;
}
Also used : InvalidArrayIndexException(com.oracle.truffle.api.interop.InvalidArrayIndexException) UnsupportedMessageException(com.oracle.truffle.api.interop.UnsupportedMessageException) JSONArray(com.oracle.truffle.tools.utils.json.JSONArray) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) JSONObject(com.oracle.truffle.tools.utils.json.JSONObject)

Example 50 with JSONArray

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);
}
Also used : JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) JSONArray(com.oracle.truffle.tools.utils.json.JSONArray) Params(com.oracle.truffle.tools.chromeinspector.commands.Params)

Aggregations

JSONArray (com.oracle.truffle.tools.utils.json.JSONArray)195 JSONObject (com.oracle.truffle.tools.utils.json.JSONObject)85 ArrayList (java.util.ArrayList)74 DebugValue (com.oracle.truffle.api.debug.DebugValue)8 Params (com.oracle.truffle.tools.chromeinspector.commands.Params)8 Collection (java.util.Collection)7 List (java.util.List)7 DebugException (com.oracle.truffle.api.debug.DebugException)6 Source (com.oracle.truffle.api.source.Source)5 SourceSection (com.oracle.truffle.api.source.SourceSection)4 CommandProcessException (com.oracle.truffle.tools.chromeinspector.server.CommandProcessException)4 HashMap (java.util.HashMap)4 Location (com.oracle.truffle.tools.chromeinspector.types.Location)3 Script (com.oracle.truffle.tools.chromeinspector.types.Script)3 CPUSampler (com.oracle.truffle.tools.profiler.CPUSampler)3 CPUSamplerData (com.oracle.truffle.tools.profiler.CPUSamplerData)3 PrintWriter (java.io.PrintWriter)3 Map (java.util.Map)3 TruffleContext (com.oracle.truffle.api.TruffleContext)2 Breakpoint (com.oracle.truffle.api.debug.Breakpoint)2