Search in sources :

Example 21 with JSONArray

use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.

the class DocumentColorRegistrationOptions method create.

public static DocumentColorRegistrationOptions create(List<Object> documentSelector) {
    final JSONObject json = new JSONObject();
    if (documentSelector != null) {
        JSONArray documentSelectorJsonArr = new JSONArray();
        for (Object object : documentSelector) {
            if (object instanceof DocumentFilter) {
                documentSelectorJsonArr.put(((DocumentFilter) object).jsonData);
            } else {
                documentSelectorJsonArr.put(object);
            }
        }
        json.put("documentSelector", documentSelectorJsonArr);
    } else {
        json.put("documentSelector", JSONObject.NULL);
    }
    return new DocumentColorRegistrationOptions(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 22 with JSONArray

use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.

the class InitializeParams method getWorkspaceFolders.

/**
 * The actual configured workspace folders.
 */
public List<WorkspaceFolder> getWorkspaceFolders() {
    final JSONArray json = jsonData.optJSONArray("workspaceFolders");
    if (json == null) {
        return null;
    }
    final List<WorkspaceFolder> list = new ArrayList<>(json.length());
    for (int i = 0; i < json.length(); i++) {
        list.add(new WorkspaceFolder(json.getJSONObject(i)));
    }
    return Collections.unmodifiableList(list);
}
Also used : JSONArray(com.oracle.truffle.tools.utils.json.JSONArray) ArrayList(java.util.ArrayList)

Example 23 with JSONArray

use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.

the class ImplementationRegistrationOptions method setDocumentSelector.

public ImplementationRegistrationOptions setDocumentSelector(List<Object> documentSelector) {
    if (documentSelector != null) {
        final JSONArray json = new JSONArray();
        for (Object object : documentSelector) {
            if (object instanceof DocumentFilter) {
                json.put(((DocumentFilter) object).jsonData);
            } else {
                json.put(object);
            }
        }
        jsonData.put("documentSelector", json);
    } else {
        jsonData.put("documentSelector", JSONObject.NULL);
    }
    return this;
}
Also used : JSONArray(com.oracle.truffle.tools.utils.json.JSONArray) JSONObject(com.oracle.truffle.tools.utils.json.JSONObject)

Example 24 with JSONArray

use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.

the class ExecuteCommandOptions method create.

public static ExecuteCommandOptions create(List<String> commands) {
    final JSONObject json = new JSONObject();
    JSONArray commandsJsonArr = new JSONArray();
    for (String string : commands) {
        commandsJsonArr.put(string);
    }
    json.put("commands", commandsJsonArr);
    return new ExecuteCommandOptions(json);
}
Also used : JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) JSONArray(com.oracle.truffle.tools.utils.json.JSONArray)

Example 25 with JSONArray

use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.

the class Hover method create.

@SuppressWarnings("deprecation")
public static Hover create(Object contents) {
    final JSONObject json = new JSONObject();
    if (contents instanceof List) {
        final JSONArray jsonArr = new JSONArray();
        for (Object obj : (List<?>) contents) {
            jsonArr.put(obj instanceof MarkedString ? ((MarkedString) obj).jsonData : obj);
        }
        json.put("contents", jsonArr);
    } else if (contents instanceof MarkupContent) {
        json.put("contents", ((MarkupContent) contents).jsonData);
    } else if (contents instanceof MarkedString) {
        json.put("contents", ((MarkedString) contents).jsonData);
    } else {
        json.put("contents", contents);
    }
    return new Hover(json);
}
Also used : JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) JSONArray(com.oracle.truffle.tools.utils.json.JSONArray) List(java.util.List) ArrayList(java.util.ArrayList) JSONObject(com.oracle.truffle.tools.utils.json.JSONObject)

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