use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class SelectionRangeRegistrationOptions method setDocumentSelector.
public SelectionRangeRegistrationOptions 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 SelectionRangeRegistrationOptions method create.
public static SelectionRangeRegistrationOptions 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 SelectionRangeRegistrationOptions(json);
}
use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class SignatureHelp method create.
public static SignatureHelp create(List<SignatureInformation> signatures, Integer activeSignature, Integer activeParameter) {
final JSONObject json = new JSONObject();
JSONArray signaturesJsonArr = new JSONArray();
for (SignatureInformation signatureInformation : signatures) {
signaturesJsonArr.put(signatureInformation.jsonData);
}
json.put("signatures", signaturesJsonArr);
json.put("activeSignature", activeSignature == null ? JSONObject.NULL : activeSignature);
json.put("activeParameter", activeParameter == null ? JSONObject.NULL : activeParameter);
return new SignatureHelp(json);
}
use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class TypeDefinitionRegistrationOptions method getDocumentSelector.
/**
* A document selector to identify the scope of the registration. If set to null the document
* selector provided on the client side will be used.
*/
public List<Object> getDocumentSelector() {
final JSONArray json = jsonData.optJSONArray("documentSelector");
if (json == null) {
return null;
}
final List<Object> list = new ArrayList<>(json.length());
for (int i = 0; i < json.length(); i++) {
Object obj = json.get(i);
if (obj instanceof JSONObject) {
list.add(new DocumentFilter((JSONObject) obj));
}
list.add(obj);
}
return Collections.unmodifiableList(list);
}
use of com.oracle.truffle.tools.utils.json.JSONArray in project graal by oracle.
the class TypeDefinitionRegistrationOptions method create.
public static TypeDefinitionRegistrationOptions 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 TypeDefinitionRegistrationOptions(json);
}
Aggregations