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);
}
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);
}
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;
}
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);
}
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);
}
Aggregations