use of org.eclipse.json.provisonnal.com.eclipsesource.json.JsonValue 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