Skip to content
Angelo edited this page Jul 8, 2015 · 2 revisions

Here the todos features for the JSON Editor. The first thing to improve is to manage synch of IJSONModel with the StructuredTextEditor (when user is typing JSON content). See tests at https://github.com/angelozerr/eclipse-wtp-json/tree/master/core/org.eclipse.wst.json.core.tests/src/org/eclipse/wst/json/core/document.

Syntax Coloring (DONE)

See here

Text Folding (DONE)

See here

Text Hover (DONE + TODOS)

See here.

TODO:

  • support text hover from a JSON Schema property.
  • support custom text hover.

Outline (DONE)

See here.

Format (TODOS)

Format was implemented by copying/pasting format classes of the XML Editor (see FormatProcessorJSON). You can do Ctrl+Shift+F, but formating is totally bugged. Synch with IJSONModel should be done and clean classes of format.

Completion

  • Custom completion is available. Se samples with bower dependencies (very slowly and it's just a POC, there are a lot of bugs):

Completion JSON Schema

  • Completion for JSON property (TODO) which was already added. Ex inside Array:

{[{"text": ""}, {" // here Ctrl+Space shows "text"

  • Completion from JSON Schema (DONE), but works only when JSON is loaded (when editor is opened). If you change the JSON content of the editor, completion doesn't work because synch model must be fixed.

Here a sample with bower which uses the JSON Schema https://github.com/angelozerr/eclipse-wtp-json/blob/master/core/org.eclipse.wst.json.core/schemastore/bower:

Completion JSON Schema

Validation

WTP Validator for JSON is available.

TODOS :

  • improve JSON syntax error validation.
  • implement validation with JSON Schema.

JSON Schema

To support validation, completion, hover with JSON Schema (like we have this feature inside XML Editor with XML Schema), we need a JSON Schema document.

Why not using an existing JSON Schema processor written in Java?

It exists several JSON Schema processor like https://github.com/fge/json-schema-validator, but they have 2 limitations :

  • they cannot support location for the error when a JSON is validated. For a JSON Editor we need location to highlight error.
  • they doesn't provide a DOM like (eg : retrieve list of properties of a JSON Schema). For a JSON Editor we need a DOM like to provides completion and validation.

That's why I have created [JSONSchemaDocument]https://github.com/angeloz(err/eclipse-wtp-json/blob/master/core/org.eclipse.json/src/org/eclipse/json/impl/schema/JSONSchemaDocument.java) which will be used for validation, completion and hover.

How JSONSchemaDocument is working?

The JSONSchemaDocument load a JSON Schema stream with minimal-json (0.9.3):

  • it stores list of properties in the document that we will able to query to support hover and completion.
  • it provides a validate method which must be implemented.

Why not using minimal-json bundles?

To load JSON stream, I have copied/pasted minimal-json sources (0.9.3) to https://github.com/angelozerr/eclipse-wtp-json/tree/master/core/org.eclipse.json/src/org/eclipse/json/provisonnal/com/eclipsesource/json because I need to add location for each JsonValue which will be used by JSONSchemaDocument when errors occurs.

Once Streaming API will be available (see https://github.com/ralfstx/minimal-json/issues/17#issuecomment-119548897) we will able to use minimal-json bundle.

My idea is that minimal-json provides a JSON Schema (see https://github.com/ralfstx/minimal-json/issues/45). When streaming API will be implemented (https://github.com/ralfstx/minimal-json/issues/17) we could implement it with a custom JsonValue which contains location.

In other words, we cannot use minimal-json bundles for the moment.