Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSnjezana Peco2016-06-06 02:16:08 +0000
committerVictor Rubezhny2016-07-12 19:48:19 +0000
commita858a2730bbe9b082a9b1af02abc5c04666230ba (patch)
treecff5b2eef17dee5331387afee814b1849213317b
parentbdbbbcc1182b1219cade50a2ae3469ba9a8940f5 (diff)
downloadwebtools.sourceediting-a858a2730bbe9b082a9b1af02abc5c04666230ba.tar.gz
webtools.sourceediting-a858a2730bbe9b082a9b1af02abc5c04666230ba.tar.xz
webtools.sourceediting-a858a2730bbe9b082a9b1af02abc5c04666230ba.zip
Bug 489452 - JSON schema references are not being resolved
Change-Id: I6bedb3cfaad956cf30d276ecee578486883a2827 Signed-off-by: Snjezana Peco <snjeza.peco@gmail.com>
-rw-r--r--bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaDocument.java79
-rw-r--r--bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaNode.java110
-rw-r--r--bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaProperty.java3
-rw-r--r--bundles/org.eclipse.json/src/org/eclipse/json/schema/IJSONSchemaNode.java19
-rw-r--r--bundles/org.eclipse.wst.json.core/plugin.xml2
-rw-r--r--bundles/org.eclipse.wst.json.core/schemastore/package267
-rw-r--r--bundles/org.eclipse.wst.json.core/schemastore/package-schema.json418
-rw-r--r--bundles/org.eclipse.wst.json.core/src/org/eclipse/wst/json/core/internal/document/JSONModelImpl.java5
-rw-r--r--bundles/org.eclipse.wst.json.ui/src/org/eclipse/wst/json/ui/contentassist/AbstractJSONCompletionProposalComputer.java4
-rw-r--r--bundles/org.eclipse.wst.json.ui/src/org/eclipse/wst/json/ui/internal/contentassist/JSONCompletionProposalComputer.java7
10 files changed, 622 insertions, 292 deletions
diff --git a/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaDocument.java b/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaDocument.java
index ce315aa944..76115b9820 100644
--- a/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaDocument.java
+++ b/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaDocument.java
@@ -12,6 +12,11 @@ package org.eclipse.json.impl.schema;
import java.io.IOException;
import java.io.Reader;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.eclipse.json.IValidationReporter;
import org.eclipse.json.jsonpath.IJSONPath;
@@ -21,11 +26,75 @@ import org.eclipse.json.schema.IJSONSchemaDocument;
import org.eclipse.json.schema.IJSONSchemaProperty;
import org.eclipse.json.schema.JSONSchemaType;
+@SuppressWarnings("serial")
public class JSONSchemaDocument extends JSONSchemaNode implements
IJSONSchemaDocument {
+ private static final String DEFINITIONS = "#/definitions/"; //$NON-NLS-1$
+ private final Map<String, IJSONSchemaProperty> definitions;
public JSONSchemaDocument(Reader reader) throws IOException {
super(JsonObject.readFrom(reader), null);
+ this.definitions = new HashMap<String, IJSONSchemaProperty>();
+ addDefinitions(getJsonObject());
+ resolveReferences();
+ }
+
+ private void resolveReferences() {
+ resolveReference(this);
+ for (IJSONSchemaProperty definition : definitions.values()) {
+ resolveReference(definition);
+ }
+ Collection<IJSONSchemaProperty> props = getProperties().values();
+ for (IJSONSchemaProperty property:props) {
+ resolveReference(property);
+ }
+ }
+
+ private void resolveReference(IJSONSchemaProperty node) {
+ String reference = node.getReference();
+ if (reference != null) {
+ String ref = reference.substring(DEFINITIONS.length());
+ IJSONSchemaProperty property = definitions.get(ref);
+ if (property != null) {
+ for (IJSONSchemaProperty p : property.getProperties().values()) {
+ node.addProperty(p);
+ }
+ Collection<IJSONSchemaProperty> props = property.getProperties().values();
+ for (IJSONSchemaProperty p : props) {
+ resolveReference(p);
+ }
+ }
+ }
+ Collection<IJSONSchemaProperty> props = node.getProperties().values();
+ for (IJSONSchemaProperty p:props) {
+ resolveReference(p);
+ }
+ List<String> references = node.getReferences();
+ for (String ref:references) {
+ String r = ref.substring(DEFINITIONS.length());
+ IJSONSchemaProperty property = definitions.get(r);
+ if (property != null) {
+ for (IJSONSchemaProperty p:property.getProperties().values()) {
+ node.addProperty(p);
+ }
+ }
+ }
+ }
+
+ private void addDefinitions(JsonObject json) {
+ Member member = null;
+ JsonObject definitions = (JsonObject) json.get("definitions");
+ if (definitions != null) {
+ Iterator<Member> members = definitions.iterator();
+ while (members.hasNext()) {
+ member = members.next();
+ addDefinition(new JSONSchemaProperty(member.getName(),
+ (JsonObject) member.getValue(), this));
+ }
+ }
+ }
+ private void addDefinition(IJSONSchemaProperty property) {
+ definitions.put(property.getName(), property);
}
@Override
@@ -38,11 +107,9 @@ public class JSONSchemaDocument extends JSONSchemaNode implements
if (segment == null) {
return null;
}
- IJSONSchemaProperty[] props = getProperties();
- for(IJSONSchemaProperty property:props) {
- if (segment.equals(property.getName())) {
- return getProperty(property, segments, 1);
- }
+ IJSONSchemaProperty property = getProperties().get(segment);
+ if (property != null) {
+ return getProperty(property, segments, 1);
}
return null;
}
@@ -52,7 +119,7 @@ public class JSONSchemaDocument extends JSONSchemaNode implements
return node;
}
String segment = segments[level];
- IJSONSchemaProperty[] props = node.getProperties();
+ Collection<IJSONSchemaProperty> props = node.getProperties().values();
for (IJSONSchemaProperty property : props) {
if (segment.equals(property.getName())) {
return getProperty(property, segments, level + 1);
diff --git a/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaNode.java b/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaNode.java
index 35922f203f..83522c093b 100644
--- a/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaNode.java
+++ b/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaNode.java
@@ -10,40 +10,102 @@
*/
package org.eclipse.json.impl.schema;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import org.eclipse.json.provisonnal.com.eclipsesource.json.JsonArray;
import org.eclipse.json.provisonnal.com.eclipsesource.json.JsonObject;
-import org.eclipse.json.provisonnal.com.eclipsesource.json.JsonObject.Member;
+import org.eclipse.json.provisonnal.com.eclipsesource.json.JsonValue;
import org.eclipse.json.schema.IJSONSchemaNode;
import org.eclipse.json.schema.IJSONSchemaProperty;
+@SuppressWarnings("serial")
public class JSONSchemaNode extends JsonObject implements IJSONSchemaNode {
private final IJSONSchemaNode parent;
private final Map<String, IJSONSchemaProperty> properties;
+ private final String reference;
+ private final List<String> references;
+ private JsonObject jsonObject;
public JSONSchemaNode(JsonObject jsonObject, IJSONSchemaNode parent) {
this.parent = parent;
+ this.jsonObject = jsonObject;
this.properties = new HashMap<String, IJSONSchemaProperty>();
- walk(jsonObject, this);
+ this.references = new ArrayList<String>();
+ this.reference = jsonObject.getString("$ref", null);
+ walk(jsonObject, this, true);
}
- private static void walk(JsonObject json, JSONSchemaNode schemaNode) {
- Member member = null;
+ private void add(JsonObject jsonObject, IJSONSchemaNode schemaNode, String pref) {
+ JsonValue values = jsonObject.get(pref);
+ if (values instanceof JsonArray) {
+ JsonArray array = (JsonArray) values;
+ Iterator<JsonValue> iter = array.iterator();
+ while (iter.hasNext()) {
+ JsonValue value = iter.next();
+ if (value != null) {
+ String ref = value.asObject().getString("$ref", null);
+ if (ref != null) {
+ references.add(ref);
+ } else {
+ walk(value.asObject(), schemaNode, true);
+ }
+ }
+ }
+ }
+ }
+
+ private void walk(JsonObject json, IJSONSchemaNode schemaNode, boolean add) {
JsonObject properties = (JsonObject) json.get("properties");
- if (properties != null) {
- Iterator<Member> members = properties.iterator();
- while (members.hasNext()) {
- member = members.next();
- schemaNode.addProperty(new JSONSchemaProperty(member.getName(),
- (JsonObject) member.getValue(), schemaNode));
+ addProperties(schemaNode, properties, add);
+ if (properties == null) {
+ JsonObject items = (JsonObject) json.get("items");
+ if (items != null) {
+ properties = (JsonObject) items.get("properties");
+ addProperties(schemaNode, properties, add);
+ String ref = items.getString("$ref", null);
+ if (ref != null) {
+ if (add) {
+ schemaNode.getReferences().add(ref);
+ } else {
+ schemaNode.getReferences().remove(ref);
+ }
+ } else {
+ walk(items, schemaNode, add);
+ }
}
}
+ add(json, schemaNode, "allOf");
+ add(json, schemaNode, "anyOf");
+ add(json, schemaNode, "oneOf");
+ JsonValue notMember = json.get("not");
+ if (notMember != null) {
+ walk(notMember.asObject(), schemaNode, false);
+ }
}
- private void addProperty(IJSONSchemaProperty property) {
+ private void addProperties(IJSONSchemaNode schemaNode, JsonObject properties, boolean add) {
+ if (properties == null) {
+ return;
+ }
+ Iterator<Member> members = properties.iterator();
+ while (members.hasNext()) {
+ Member member = members.next();
+ if (add) {
+ schemaNode.addProperty(
+ new JSONSchemaProperty(member.getName(), (JsonObject) member.getValue(), schemaNode));
+ } else {
+ schemaNode.getProperties().remove(member.getName());
+ }
+ }
+ }
+
+ @Override
+ public void addProperty(IJSONSchemaProperty property) {
properties.put(property.getName(), property);
}
@@ -53,8 +115,32 @@ public class JSONSchemaNode extends JsonObject implements IJSONSchemaNode {
}
@Override
- public IJSONSchemaProperty[] getProperties() {
+ public IJSONSchemaProperty[] getPropertyValues() {
return properties.values().toArray(IJSONSchemaProperty.EMPTY_PROPERTY);
}
+ @Override
+ public JsonObject getJsonObject() {
+ return jsonObject;
+ }
+
+ @Override
+ public void setJsonObject(JsonObject jsonObject) {
+ this.jsonObject = jsonObject;
+ }
+
+ @Override
+ public String getReference() {
+ return reference;
+ }
+
+ @Override
+ public List<String> getReferences() {
+ return references;
+ }
+
+ @Override
+ public Map<String, IJSONSchemaProperty> getProperties() {
+ return properties;
+ }
}
diff --git a/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaProperty.java b/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaProperty.java
index 3da0c05723..11449f1425 100644
--- a/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaProperty.java
+++ b/bundles/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaProperty.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2013-2014 Angelo ZERR.
+ * Copyright (c) 2013-2016 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,6 +20,7 @@ import org.eclipse.json.schema.IJSONSchemaNode;
import org.eclipse.json.schema.IJSONSchemaProperty;
import org.eclipse.json.schema.JSONSchemaType;
+@SuppressWarnings("serial")
public class JSONSchemaProperty extends JSONSchemaNode implements
IJSONSchemaProperty {
diff --git a/bundles/org.eclipse.json/src/org/eclipse/json/schema/IJSONSchemaNode.java b/bundles/org.eclipse.json/src/org/eclipse/json/schema/IJSONSchemaNode.java
index 4f7fe9666d..edd22cfb2d 100644
--- a/bundles/org.eclipse.json/src/org/eclipse/json/schema/IJSONSchemaNode.java
+++ b/bundles/org.eclipse.json/src/org/eclipse/json/schema/IJSONSchemaNode.java
@@ -10,9 +10,26 @@
*/
package org.eclipse.json.schema;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.json.provisonnal.com.eclipsesource.json.JsonObject;
+
public interface IJSONSchemaNode {
IJSONSchemaNode getParent();
- IJSONSchemaProperty[] getProperties();
+ IJSONSchemaProperty[] getPropertyValues();
+
+ List<String> getReferences();
+
+ Map<String, IJSONSchemaProperty> getProperties();
+
+ String getReference();
+
+ void setJsonObject(JsonObject jsonObject);
+
+ JsonObject getJsonObject();
+
+ void addProperty(IJSONSchemaProperty property);
}
diff --git a/bundles/org.eclipse.wst.json.core/plugin.xml b/bundles/org.eclipse.wst.json.core/plugin.xml
index ae4f9b04aa..76f645c4e3 100644
--- a/bundles/org.eclipse.wst.json.core/plugin.xml
+++ b/bundles/org.eclipse.wst.json.core/plugin.xml
@@ -107,7 +107,7 @@
description="NPM configuration file"
fileMatch="package.json"
url="http://json.schemastore.org/package"
- uri="schemastore/package" />
+ uri="schemastore/package-schema.json" />
</schemaCatalogContribution>
</extension>
diff --git a/bundles/org.eclipse.wst.json.core/schemastore/package b/bundles/org.eclipse.wst.json.core/schemastore/package
deleted file mode 100644
index 5c74748b58..0000000000
--- a/bundles/org.eclipse.wst.json.core/schemastore/package
+++ /dev/null
@@ -1,267 +0,0 @@
-{
- "title": "JSON schema for NPM package.json files",
- "$schema": "http://json-schema.org/draft-04/schema#",
-
- "type": "object",
- "required": [ "name", "version" ],
-
- "definitions": {
- "person": {
- "description": "A person who has been involved in creating or maintaining this package",
- "type": [ "object", "string" ],
- "required": [ "name" ],
- "properties": {
- "name": {
- "type": "string"
- },
- "url": {
- "type": "string",
- "format": "uri"
- },
- "email": {
- "type": "string",
- "format": "email"
- }
- }
- },
- "dependency": {
- "description": "Dependencies are specified with a simple hash of package name to version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.",
- "type": "object",
- "additionalProperties": {
- "type": "string"
- }
- }
- },
-
- "patternProperties": {
- "^_": {
- "description": "Any property starting with _ is valid.",
- "additionalProperties": true,
- "additionalItems": true
- }
- },
-
- "properties": {
- "name": {
- "description": "The name of the package.",
- "type": "string"
- },
- "version": {
- "description": "Version must be parseable by node-semver, which is bundled with npm as a dependency.",
- "type": "string"
- },
- "description": {
- "description": "This helps people discover your package, as it's listed in 'npm search'.",
- "type": "string"
- },
- "keywords": {
- "description": "This helps people discover your package as it's listed in 'npm search'.",
- "type": "array"
- },
- "homepage": {
- "description": "The url to the project homepage.",
- "type": "string"
- },
- "bugs": {
- "description": "The url to your project's issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.",
- "type": [ "object", "string" ],
- "properties": {
- "url": {
- "type": "string",
- "description": "The url to your project's issue tracker.",
- "format": "uri"
- },
- "email": {
- "type": "string",
- "description": "The email address to which issues should be reported."
- }
- }
- },
- "license": {
- "type": "string",
- "description": "You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you're placing on it."
- },
- "licenses": {
- "description": "You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you're placing on it.",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "type": {
- "type": "string"
- },
- "url": {
- "type": "string",
- "format": "uri"
- }
- }
- }
- },
- "author": {
- "$ref": "#/definitions/person"
- },
- "contributors": {
- "description": "A list of people who contributed to this package.",
- "type": "array",
- "items": {
- "$ref": "#/definitions/person"
- }
- },
- "maintainers": {
- "description": "A list of people who maintains this package.",
- "type": "array",
- "items": {
- "$ref": "#/definitions/person"
- }
- },
- "files": {
- "description": "The 'files' field is an array of files to include in your project. If you name a folder in the array, then it will also include the files inside that folder.",
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "main": {
- "description": "The main field is a module ID that is the primary entry point to your program.",
- "type": "string"
- },
- "bin": {
- "type": [ "string", "object" ],
- "additionalProperties": {
- "type": "string"
- }
- },
- "man": {
- "type": [ "array", "string" ],
- "description": "Specify either a single file or an array of filenames to put in place for the man program to find.",
- "items": {
- "type": "string"
- }
- },
- "directories": {
- "type": "object",
- "properties": {
- "bin": {
- "description": "If you specify a 'bin' directory, then all the files in that folder will be used as the 'bin' hash.",
- "type": "string"
- },
- "doc": {
- "description": "Put markdown files in here. Eventually, these will be displayed nicely, maybe, someday.",
- "type": "string"
- },
- "example": {
- "description": "Put example scripts in here. Someday, it might be exposed in some clever way.",
- "type": "string"
- },
- "lib": {
- "description": "Tell people where the bulk of your library is. Nothing special is done with the lib folder in any way, but it's useful meta info.",
- "type": "string"
- },
- "man": {
- "description": "A folder that is full of man pages. Sugar to generate a 'man' array by walking the folder.",
- "type": "string"
- },
- "test": {
- "type": "string"
- }
- }
- },
- "repository": {
- "description": "Specify the place where your code lives. This is helpful for people who want to contribute.",
- "type": "object",
- "properties": {
- "type": {
- "type": "string"
- },
- "url": {
- "type": "string"
- }
- }
- },
- "scripts": {
- "description": "The 'scripts' member is an object hash of script commands that are run at various times in the lifecycle of your package. The key is the lifecycle event, and the value is the command to run at that point.",
- "type": "object",
- "additionalProperties": {
- "type": "string"
- }
- },
- "config": {
- "description": "A 'config' hash can be used to set configuration parameters used in package scripts that persist across upgrades.",
- "type": "object",
- "additionalProperties": true
- },
- "dependencies": {
- "$ref": "#/definitions/dependency"
- },
- "devDependencies": {
- "$ref": "#/definitions/dependency"
- },
- "bundleDependencies": {
- "type": "array",
- "description": "Array of package names that will be bundled when publishing the package.",
- "items": {
- "type": "string"
- }
- },
- "bundledDependencies": {
- "type": "array",
- "description": "Array of package names that will be bundled when publishing the package.",
- "items": {
- "type": "string"
- }
- },
- "optionalDependencies": {
- "$ref": "#/definitions/dependency"
- },
- "peerDependencies": {
- "$ref": "#/definitions/dependency"
- },
- "engines": {
- "type": "object",
- "additionalProperties": {
- "type": "string"
- }
- },
- "engineStrict": {
- "type": "boolean"
- },
- "os": {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "cpu": {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "preferGlobal": {
- "type": "boolean",
- "description": "If your package is primarily a command-line application that should be installed globally, then set this value to true to provide a warning if it is installed locally."
- },
- "private": {
- "type": "boolean",
- "description": "If set to true, then npm will refuse to publish it."
- },
- "publishConfig": {
- "type": "object",
- "additionalProperties": true
- },
- "dist": {
- "type": "object",
- "properties": {
- "shasum": {
- "type": "string"
- },
- "tarball": {
- "type": "string"
- }
- }
- },
- "readme": {
- "type": "string"
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.json.core/schemastore/package-schema.json b/bundles/org.eclipse.wst.json.core/schemastore/package-schema.json
new file mode 100644
index 0000000000..c1b59b88fe
--- /dev/null
+++ b/bundles/org.eclipse.wst.json.core/schemastore/package-schema.json
@@ -0,0 +1,418 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "JSON schema for NPM package.json files",
+ "definitions": {
+ "person": {
+ "description": "A person who has been involved in creating or maintaining this package",
+ "type": [ "object", "string" ],
+ "required": [ "name" ],
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "url": {
+ "type": "string",
+ "format": "uri"
+ },
+ "email": {
+ "type": "string",
+ "format": "email"
+ }
+ }
+ },
+ "bundledDependency": {
+ "description": "Array of package names that will be bundled when publishing the package.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "dependency": {
+ "description": "Dependencies are specified with a simple hash of package name to version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.",
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "scriptsInstallAfter": {
+ "description": "Run AFTER the package is installed",
+ "type": "string"
+ },
+ "scriptsPublishAfter": {
+ "description": "Run AFTER the package is published",
+ "type": "string"
+ },
+ "scriptsRestart": {
+ "description": "Run by the 'npm restart' command. Note: 'npm restart' will run the stop and start scripts if no restart script is provided.",
+ "type": "string"
+ },
+ "scriptsStart": {
+ "description": "Run by the 'npm start' command",
+ "type": "string"
+ },
+ "scriptsStop": {
+ "description": "Run by the 'npm stop' command",
+ "type": "string"
+ },
+ "scriptsTest": {
+ "description": "Run by the 'npm test' command",
+ "type": "string"
+ },
+ "scriptsUninstallBefore": {
+ "description": "Run BEFORE the package is uninstalled",
+ "type": "string"
+ },
+ "scriptsVersionBefore": {
+ "description": "Run BEFORE bump the package version",
+ "type": "string"
+ },
+ "coreProperties": {
+ "type": "object",
+
+ "patternProperties": {
+ "^_": {
+ "description": "Any property starting with _ is valid.",
+ "additionalProperties": true,
+ "additionalItems": true
+ }
+ },
+
+ "properties": {
+ "name": {
+ "description": "The name of the package.",
+ "type": "string",
+ "maxLength": 214,
+ "minLength": 1,
+ "pattern": "^[^A-Z]+$"
+ },
+ "version": {
+ "description": "Version must be parseable by node-semver, which is bundled with npm as a dependency.",
+ "type": "string"
+ },
+ "description": {
+ "description": "This helps people discover your package, as it's listed in 'npm search'.",
+ "type": "string"
+ },
+ "keywords": {
+ "description": "This helps people discover your package as it's listed in 'npm search'.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "homepage": {
+ "description": "The url to the project homepage.",
+ "type": "string",
+ "format": "uri"
+ },
+ "bugs": {
+ "description": "The url to your project's issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.",
+ "type": [ "object", "string" ],
+ "properties": {
+ "url": {
+ "type": "string",
+ "description": "The url to your project's issue tracker.",
+ "format": "uri"
+ },
+ "email": {
+ "type": "string",
+ "description": "The email address to which issues should be reported.",
+ "format": "email"
+ }
+ }
+ },
+ "license": {
+ "type": "string",
+ "description": "You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you're placing on it."
+ },
+ "licenses": {
+ "description": "You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you're placing on it.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string"
+ },
+ "url": {
+ "type": "string",
+ "format": "uri"
+ }
+ }
+ }
+ },
+ "author": {
+ "$ref": "#/definitions/person"
+ },
+ "contributors": {
+ "description": "A list of people who contributed to this package.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/person"
+ }
+ },
+ "maintainers": {
+ "description": "A list of people who maintains this package.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/person"
+ }
+ },
+ "files": {
+ "description": "The 'files' field is an array of files to include in your project. If you name a folder in the array, then it will also include the files inside that folder.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "main": {
+ "description": "The main field is a module ID that is the primary entry point to your program.",
+ "type": "string"
+ },
+ "bin": {
+ "type": [ "string", "object" ],
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "man": {
+ "type": [ "array", "string" ],
+ "description": "Specify either a single file or an array of filenames to put in place for the man program to find.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "directories": {
+ "type": "object",
+ "properties": {
+ "bin": {
+ "description": "If you specify a 'bin' directory, then all the files in that folder will be used as the 'bin' hash.",
+ "type": "string"
+ },
+ "doc": {
+ "description": "Put markdown files in here. Eventually, these will be displayed nicely, maybe, someday.",
+ "type": "string"
+ },
+ "example": {
+ "description": "Put example scripts in here. Someday, it might be exposed in some clever way.",
+ "type": "string"
+ },
+ "lib": {
+ "description": "Tell people where the bulk of your library is. Nothing special is done with the lib folder in any way, but it's useful meta info.",
+ "type": "string"
+ },
+ "man": {
+ "description": "A folder that is full of man pages. Sugar to generate a 'man' array by walking the folder.",
+ "type": "string"
+ },
+ "test": {
+ "type": "string"
+ }
+ }
+ },
+ "repository": {
+ "description": "Specify the place where your code lives. This is helpful for people who want to contribute.",
+ "type": ["object", "string"],
+ "properties": {
+ "type": {
+ "type": "string"
+ },
+ "url": {
+ "type": "string",
+ "format": "uri"
+ }
+ }
+ },
+ "scripts": {
+ "description": "The 'scripts' member is an object hash of script commands that are run at various times in the lifecycle of your package. The key is the lifecycle event, and the value is the command to run at that point.",
+ "type": "object",
+ "properties": {
+ "prepublish": {
+ "type": "string",
+ "description": "Run BEFORE the package is published (Also run on local npm install without any arguments)"
+ },
+ "publish": {
+ "$ref": "#/definitions/scriptsPublishAfter"
+ },
+ "postpublish": {
+ "$ref": "#/definitions/scriptsPublishAfter"
+ },
+ "preinstall": {
+ "type": "string",
+ "description": "Run BEFORE the package is installed"
+ },
+ "install": {
+ "$ref": "#/definitions/scriptsInstallAfter"
+ },
+ "postinstall": {
+ "$ref": "#/definitions/scriptsInstallAfter"
+ },
+ "preuninstall": {
+ "$ref": "#/definitions/scriptsUninstallBefore"
+ },
+ "uninstall": {
+ "$ref": "#/definitions/scriptsUninstallBefore"
+ },
+ "postuninstall": {
+ "type": "string",
+ "description": "Run AFTER the package is uninstalled"
+ },
+ "preversion": {
+ "$ref": "#/definitions/scriptsVersionBefore"
+ },
+ "version": {
+ "$ref": "#/definitions/scriptsVersionBefore"
+ },
+ "postversion": {
+ "type": "string",
+ "description": "Run AFTER bump the package version"
+ },
+ "pretest": {
+ "$ref": "#/definitions/scriptsTest"
+ },
+ "test": {
+ "$ref": "#/definitions/scriptsTest"
+ },
+ "posttest": {
+ "$ref": "#/definitions/scriptsTest"
+ },
+ "prestop": {
+ "$ref": "#/definitions/scriptsStop"
+ },
+ "stop": {
+ "$ref": "#/definitions/scriptsStop"
+ },
+ "poststop": {
+ "$ref": "#/definitions/scriptsStop"
+ },
+ "prestart": {
+ "$ref": "#/definitions/scriptsStart"
+ },
+ "start": {
+ "$ref": "#/definitions/scriptsStart"
+ },
+ "poststart": {
+ "$ref": "#/definitions/scriptsStart"
+ },
+ "prerestart": {
+ "$ref": "#/definitions/scriptsRestart"
+ },
+ "restart": {
+ "$ref": "#/definitions/scriptsRestart"
+ },
+ "postrestart": {
+ "$ref": "#/definitions/scriptsRestart"
+ }
+ },
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "config": {
+ "description": "A 'config' hash can be used to set configuration parameters used in package scripts that persist across upgrades.",
+ "type": "object",
+ "additionalProperties": true
+ },
+ "dependencies": {
+ "$ref": "#/definitions/dependency"
+ },
+ "devDependencies": {
+ "$ref": "#/definitions/dependency"
+ },
+ "optionalDependencies": {
+ "$ref": "#/definitions/dependency"
+ },
+ "peerDependencies": {
+ "$ref": "#/definitions/dependency"
+ },
+ "engines": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "engineStrict": {
+ "type": "boolean"
+ },
+ "os": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "cpu": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "preferGlobal": {
+ "type": "boolean",
+ "description": "If your package is primarily a command-line application that should be installed globally, then set this value to true to provide a warning if it is installed locally."
+ },
+ "private": {
+ "type": "boolean",
+ "description": "If set to true, then npm will refuse to publish it."
+ },
+ "publishConfig": {
+ "type": "object",
+ "additionalProperties": true
+ },
+ "dist": {
+ "type": "object",
+ "properties": {
+ "shasum": {
+ "type": "string"
+ },
+ "tarball": {
+ "type": "string"
+ }
+ }
+ },
+ "readme": {
+ "type": "string"
+ }
+ }
+ },
+ "jspmDefinition": {
+ "properties": {
+ "jspm": { "$ref": "#/definitions/coreProperties" }
+ }
+ }
+ },
+ "allOf": [
+ { "$ref": "#/definitions/coreProperties" },
+ { "$ref": "#/definitions/jspmDefinition" },
+ {
+ "anyOf": [
+ {
+ "properties": {
+ "bundleDependencies": {
+ "$ref": "#/definitions/bundledDependency"
+ }
+ },
+ "not": {
+ "properties": {
+ "bundledDependencies": { }
+ },
+ "required": [ "bundledDependencies" ]
+ }
+ },
+ {
+ "properties": {
+ "bundledDependencies": {
+ "$ref": "#/definitions/bundledDependency"
+ }
+ },
+ "not": {
+ "properties": {
+ "bundleDependencies": { }
+ },
+ "required": [ "bundleDependencies" ]
+ }
+ }
+ ]
+ },
+ { "required": [ "name", "version" ] }
+ ]
+}
diff --git a/bundles/org.eclipse.wst.json.core/src/org/eclipse/wst/json/core/internal/document/JSONModelImpl.java b/bundles/org.eclipse.wst.json.core/src/org/eclipse/wst/json/core/internal/document/JSONModelImpl.java
index 1ece59a90d..0e8349e681 100644
--- a/bundles/org.eclipse.wst.json.core/src/org/eclipse/wst/json/core/internal/document/JSONModelImpl.java
+++ b/bundles/org.eclipse.wst.json.core/src/org/eclipse/wst/json/core/internal/document/JSONModelImpl.java
@@ -15,6 +15,7 @@
package org.eclipse.wst.json.core.internal.document;
import org.eclipse.wst.json.core.contenttype.ContentTypeIdForJSON;
+import org.eclipse.wst.json.core.document.IJSONArray;
import org.eclipse.wst.json.core.document.IJSONDocument;
import org.eclipse.wst.json.core.document.IJSONModel;
import org.eclipse.wst.json.core.document.IJSONNode;
@@ -290,7 +291,7 @@ public class JSONModelImpl extends AbstractStructuredModel implements
if (endStructuredDocumentRegion.getStart() <= offset) {
if (child instanceof IJSONPair) {
IJSONValue value = ((IJSONPair)child).getValue();
- if (value instanceof IJSONObject) {
+ if (value instanceof IJSONObject || value instanceof IJSONArray) {
if (value.getStartOffset() < offset) {
child = value;
continue;
@@ -333,7 +334,7 @@ public class JSONModelImpl extends AbstractStructuredModel implements
if (endStructuredDocumentRegion.getStart() <= offset) {
if (child instanceof IJSONPair) {
IJSONValue value = ((IJSONPair)child).getValue();
- if (value instanceof IJSONObject) {
+ if (value instanceof IJSONObject || value instanceof IJSONArray) {
if (value.getStartOffset() < offset) {
child = value;
continue;
diff --git a/bundles/org.eclipse.wst.json.ui/src/org/eclipse/wst/json/ui/contentassist/AbstractJSONCompletionProposalComputer.java b/bundles/org.eclipse.wst.json.ui/src/org/eclipse/wst/json/ui/contentassist/AbstractJSONCompletionProposalComputer.java
index 24b02a5804..b4974d1d9f 100644
--- a/bundles/org.eclipse.wst.json.ui/src/org/eclipse/wst/json/ui/contentassist/AbstractJSONCompletionProposalComputer.java
+++ b/bundles/org.eclipse.wst.json.ui/src/org/eclipse/wst/json/ui/contentassist/AbstractJSONCompletionProposalComputer.java
@@ -148,6 +148,7 @@ public abstract class AbstractJSONCompletionProposalComputer implements
if (treeNode.getNodeType() == IJSONNode.OBJECT_NODE) {
if (regionType == JSONRegionContexts.JSON_OBJECT_OPEN
|| regionType == JSONRegionContexts.JSON_OBJECT_CLOSE
+ || regionType == JSONRegionContexts.JSON_OBJECT_KEY
|| regionType == JSONRegionContexts.JSON_COMMA) {
contentAssistRequest = computeObjectKeyProposals(matchString,
completionRegion, treeNode, xmlnode, context);
@@ -155,6 +156,9 @@ public abstract class AbstractJSONCompletionProposalComputer implements
} else if ((treeNode.getNodeType() == IJSONNode.PAIR_NODE)) {
if (regionType == JSONRegionContexts.JSON_OBJECT_KEY
|| regionType == JSONRegionContexts.JSON_OBJECT_OPEN
+ || regionType == JSONRegionContexts.JSON_OBJECT_CLOSE
+ || regionType == JSONRegionContexts.JSON_ARRAY_OPEN
+ || regionType == JSONRegionContexts.JSON_ARRAY_CLOSE
|| regionType == JSONRegionContexts.JSON_COMMA) {
contentAssistRequest = computeObjectKeyProposals(matchString,
completionRegion, treeNode, xmlnode, context);
diff --git a/bundles/org.eclipse.wst.json.ui/src/org/eclipse/wst/json/ui/internal/contentassist/JSONCompletionProposalComputer.java b/bundles/org.eclipse.wst.json.ui/src/org/eclipse/wst/json/ui/internal/contentassist/JSONCompletionProposalComputer.java
index 27813d336b..632da31f6e 100644
--- a/bundles/org.eclipse.wst.json.ui/src/org/eclipse/wst/json/ui/internal/contentassist/JSONCompletionProposalComputer.java
+++ b/bundles/org.eclipse.wst.json.ui/src/org/eclipse/wst/json/ui/internal/contentassist/JSONCompletionProposalComputer.java
@@ -20,6 +20,8 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.json.core.JSONCorePlugin;
import org.eclipse.wst.json.core.document.IJSONNode;
import org.eclipse.wst.json.core.document.IJSONObject;
+import org.eclipse.wst.json.core.document.IJSONPair;
+import org.eclipse.wst.json.core.regions.JSONRegionContexts;
import org.eclipse.wst.json.ui.contentassist.AbstractJSONCompletionProposalComputer;
import org.eclipse.wst.json.ui.contentassist.ContentAssistHelper;
import org.eclipse.wst.json.ui.contentassist.ContentAssistRequest;
@@ -95,7 +97,7 @@ public class JSONCompletionProposalComputer extends
.getProperty(path);
if (parentProperty != null) {
for (IJSONSchemaProperty property : parentProperty
- .getProperties()) {
+ .getPropertyValues()) {
boolean showProperty = beginsWith(property.getName(),
matchString.trim());
if (showProperty) {
@@ -106,13 +108,14 @@ public class JSONCompletionProposalComputer extends
Image icon = JSONEditorPluginImageHelper
.getInstance().getImage(
property.getFirstType());
+ String displayString = property.getName();
JSONKeyCompletionProposal proposal = new JSONKeyCompletionProposal(
replacementString,
contentAssistRequest
.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(),
replacementString.length() - 2, icon,
- property.getName(), null,
+ displayString, null,
additionalProposalInfo,
JSONRelevanceConstants.R_OBJECT_KEY);
contentAssistRequest.addProposal(proposal);

Back to the top