Search in sources :

Example 96 with JSONArray

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

the class SignatureInformation method create.

public static SignatureInformation create(String label, String documentation, ParameterInformation... parameters) {
    final JSONObject json = new JSONObject();
    json.put("label", label);
    json.putOpt("documentation", documentation);
    if (parameters != null) {
        JSONArray parametersJsonArr = new JSONArray();
        for (ParameterInformation parameterInformation : parameters) {
            parametersJsonArr.put(parameterInformation.jsonData);
        }
        json.put("parameters", parametersJsonArr);
    }
    return new SignatureInformation(json);
}
Also used : JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) JSONArray(com.oracle.truffle.tools.utils.json.JSONArray)

Example 97 with JSONArray

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

the class SignatureInformation method getParameters.

/**
 * The parameters of this signature.
 */
public List<ParameterInformation> getParameters() {
    final JSONArray json = jsonData.optJSONArray("parameters");
    if (json == null) {
        return null;
    }
    final List<ParameterInformation> list = new ArrayList<>(json.length());
    for (int i = 0; i < json.length(); i++) {
        list.add(new ParameterInformation(json.getJSONObject(i)));
    }
    return Collections.unmodifiableList(list);
}
Also used : JSONArray(com.oracle.truffle.tools.utils.json.JSONArray) ArrayList(java.util.ArrayList)

Example 98 with JSONArray

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

the class TextDocumentRegistrationOptions method create.

public static TextDocumentRegistrationOptions 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 TextDocumentRegistrationOptions(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 99 with JSONArray

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

the class CodeAction method setDiagnostics.

public CodeAction setDiagnostics(List<Diagnostic> diagnostics) {
    if (diagnostics != null) {
        final JSONArray json = new JSONArray();
        for (Diagnostic diagnostic : diagnostics) {
            json.put(diagnostic.jsonData);
        }
        jsonData.put("diagnostics", json);
    }
    return this;
}
Also used : JSONArray(com.oracle.truffle.tools.utils.json.JSONArray)

Example 100 with JSONArray

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

the class CodeActionContext method getDiagnostics.

/**
 * An array of diagnostics known on the client side overlapping the range provided to the
 * `textDocument/codeAction` request. They are provied so that the server knows which errors are
 * currently presented to the user for the given range. There is no guarantee that these
 * accurately reflect the error state of the resource. The primary parameter to compute code
 * actions is the provided range.
 */
public List<Diagnostic> getDiagnostics() {
    final JSONArray json = jsonData.getJSONArray("diagnostics");
    final List<Diagnostic> list = new ArrayList<>(json.length());
    for (int i = 0; i < json.length(); i++) {
        list.add(new Diagnostic(json.getJSONObject(i)));
    }
    return Collections.unmodifiableList(list);
}
Also used : JSONArray(com.oracle.truffle.tools.utils.json.JSONArray) ArrayList(java.util.ArrayList)

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