Search in sources :

Example 26 with JSONArray

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

Example 27 with JSONArray

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

Example 28 with JSONArray

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

Example 29 with JSONArray

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

Example 30 with JSONArray

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

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