use of org.eclipse.json.provisonnal.com.eclipsesource.json.JsonObject in project webtools.sourceediting by eclipse.
the class JSONSchemaNode method resolveReferences.
private void resolveReferences(JsonObject parent, String name, JsonValue value) {
if (value instanceof JsonObject) {
JsonObject json = value.asObject();
String ref = json.getString(REF, null);
if (ref != null && ref.startsWith(DEFINITIONS)) {
String r = ref.substring(DEFINITIONS.length());
JsonValue v = definitions.get(r);
parent.set(name, v);
// json.remove(REF);
} else {
Iterator<Member> members = json.iterator();
while (members.hasNext()) {
Member member = members.next();
JsonValue v = member.getValue();
resolveReferences(json, member.getName(), v);
}
}
} else if (value instanceof JsonArray) {
JsonArray jsonArray = (JsonArray) value;
for (int i = 0; i < jsonArray.size(); i++) {
JsonValue item = jsonArray.get(i);
if (item instanceof JsonObject) {
JsonObject json = item.asObject();
String ref = json.getString(REF, null);
if (ref != null && ref.startsWith(DEFINITIONS)) {
String r = ref.substring(DEFINITIONS.length());
JsonValue v = definitions.get(r);
jsonArray.set(i, v);
} else {
resolveReferences(json);
}
}
}
}
}
use of org.eclipse.json.provisonnal.com.eclipsesource.json.JsonObject in project webtools.sourceediting by eclipse.
the class JSONSchemaNode method walk.
private void walk(JsonObject json, IJSONSchemaNode schemaNode) {
JsonObject properties = (JsonObject) json.get(PROPERTIES);
addProperties(schemaNode, properties);
add(json, schemaNode, ALL_OF);
add(json, schemaNode, ANY_OF);
add(json, schemaNode, ONE_OF);
JsonValue notMember = json.get(NOT);
if (notMember != null) {
walk(notMember.asObject(), schemaNode);
}
}
use of org.eclipse.json.provisonnal.com.eclipsesource.json.JsonObject in project webtools.sourceediting by eclipse.
the class BowerDependencyCompletionProposalCollector method addProposals.
protected void addProposals(JsonValue json, ContentAssistRequest contentAssistRequest, CompletionProposalInvocationContext context, TargetType target) {
if (json.isArray()) {
// Ex :
// [{"name":"angular-mocks","url":"git://github.com/angular/bower-angular-mocks.git"},
// {"name":"angular-moment","url":"git://github.com/urish/angular-moment.git"}]
String dependency = null;
String replacementString = null;
JsonArray values = (JsonArray) json;
for (JsonValue value : values) {
if (value.isObject()) {
dependency = ((JsonObject) value).get("name").asString();
replacementString = ContentAssistHelper.getRequiredName(dependency, JSONSchemaType.String);
Image icon = BowerEditorPluginImageHelper.getInstance().getImage(BowerEditorPluginImages.IMG_OBJ_BOWER);
JSONKeyCompletionProposal proposal = new JSONKeyCompletionProposal(replacementString, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), replacementString.length() - 2, icon, dependency, null, null, JSONRelevanceConstants.R_OBJECT_KEY);
contentAssistRequest.addProposal(proposal);
}
}
}
// System.err.println(json);
}
use of org.eclipse.json.provisonnal.com.eclipsesource.json.JsonObject in project webtools.sourceediting by eclipse.
the class NPMDependencyCompletionProposalCollector method addProposals.
protected void addProposals(JsonValue json, ContentAssistRequest contentAssistRequest, CompletionProposalInvocationContext context, TargetType target) {
if (json.isArray()) {
// Ex :
// [{"value":"express"},{"value":"lodash"},{"value":"gulp"}]
String dependency = null;
String replacementString = null;
JsonArray values = (JsonArray) json;
for (JsonValue value : values) {
if (value.isObject()) {
dependency = ((JsonObject) value).get("value").asString();
replacementString = ContentAssistHelper.getRequiredName(dependency, JSONSchemaType.String);
Image icon = NPMEditorPluginImageHelper.getInstance().getImage(NPMEditorPluginImages.IMG_OBJ_NPM);
JSONKeyCompletionProposal proposal = new JSONKeyCompletionProposal(replacementString, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), replacementString.length() - 2, icon, dependency, null, null, JSONRelevanceConstants.R_OBJECT_KEY);
contentAssistRequest.addProposal(proposal);
}
}
}
// System.err.println(json);
}
Aggregations