Search in sources :

Example 61 with JSONObject

use of com.oracle.truffle.tools.utils.json.JSONObject 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 62 with JSONObject

use of com.oracle.truffle.tools.utils.json.JSONObject 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)

Example 63 with JSONObject

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

the class ResultsPrinter method printRawResults.

void printRawResults() {
    JSONArray output = new JSONArray();
    for (Results results : resultsList) {
        JSONObject jsonResults = new JSONObject();
        jsonResults.put("location", results.location);
        jsonResults.put("samples", new JSONArray(results.samples));
        output.put(jsonResults);
    }
    stream.print(output);
}
Also used : JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) JSONArray(com.oracle.truffle.tools.utils.json.JSONArray)

Example 64 with JSONObject

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

the class DelegateServers method mergeResults.

public Object mergeResults(Object id, Object result) {
    Object allResults = result;
    for (DelegateServer ds : delegateServers) {
        try {
            JSONObject message = ds.awaitMessage(id);
            if (message != null && logger.isLoggable(Level.FINER)) {
                String format = "[Trace - %s] Received response from %s: %s";
                logger.log(Level.FINER, String.format(format, Instant.now().toString(), ds.toString(), message.toString()));
            }
            allResults = mergeResults(allResults, message);
        } catch (InterruptedException iex) {
        }
    }
    return allResults;
}
Also used : JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) DelegateServer(org.graalvm.tools.lsp.server.types.LanguageServer.DelegateServer)

Example 65 with JSONObject

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

the class DelegateServers method findContextLanguage.

private String findContextLanguage(JSONObject params) {
    JSONObject textDocument = params != null ? params.optJSONObject("textDocument") : null;
    Object uri = textDocument != null ? textDocument.opt("uri") : null;
    return uri instanceof String ? truffleAdapter.getLanguageId(URI.create((String) uri)) : null;
}
Also used : JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) JSONObject(com.oracle.truffle.tools.utils.json.JSONObject)

Aggregations

JSONObject (com.oracle.truffle.tools.utils.json.JSONObject)318 JSONArray (com.oracle.truffle.tools.utils.json.JSONArray)71 ArrayList (java.util.ArrayList)20 Params (com.oracle.truffle.tools.chromeinspector.commands.Params)18 DebugValue (com.oracle.truffle.api.debug.DebugValue)14 DebugException (com.oracle.truffle.api.debug.DebugException)11 CommandProcessException (com.oracle.truffle.tools.chromeinspector.server.CommandProcessException)10 SourceSection (com.oracle.truffle.api.source.SourceSection)8 HashMap (java.util.HashMap)8 List (java.util.List)8 Collection (java.util.Collection)7 Breakpoint (com.oracle.truffle.api.debug.Breakpoint)6 Source (com.oracle.truffle.api.source.Source)6 Map (java.util.Map)6 LanguageInfo (com.oracle.truffle.api.nodes.LanguageInfo)5 NoSuspendedThreadException (com.oracle.truffle.tools.chromeinspector.InspectorExecutionContext.NoSuspendedThreadException)5 RemoteObject (com.oracle.truffle.tools.chromeinspector.types.RemoteObject)5 JSONTokener (com.oracle.truffle.tools.utils.json.JSONTokener)5 Test (org.junit.Test)5 Location (com.oracle.truffle.tools.chromeinspector.types.Location)4