Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced JSON Editor #253

Closed
angelozerr opened this issue Feb 14, 2015 · 24 comments
Closed

Advanced JSON Editor #253

angelozerr opened this issue Feb 14, 2015 · 24 comments

Comments

@angelozerr
Copy link
Owner

Here a sample of .tern-project :

{
  "libs": [
    "browser",
    "jquery"
  ],
   "plugins": {
    "requirejs": {
      "baseURL": "./",
      "paths": {}
    }
  }
}

I would like to provide a JSON editor for the .tern-project file :

  • Color text highlighting
  • An Outline Tree view
  • JSON validation
  • Text formatting
  • Text folding on JSON Objects and Arrays

But too :

  • completion for tern modules (inside libs and plugins json fields)
  • validation for tern modules (check that modules exists)

It exists several JSON Editor :

But there are some limitations :

  • not possible to update the JSON Editor with an JSON model kind like WTP IDOMModel and ICSSModel.
  • not extensible to extends completion and validation

I tell me it should be very cool to have a JSON Editor based on WTP like CSS or DOM WTP.

This JSON Editor could be extended to support other file like JSHint config file .jshintrc

@vrubezhny @dgolovin @mickaelistria @maxandersen @pascalleclercq @gamerson @paulvi @fbricon @piotrtomiak What do you think about that?

@mickaelistria
Copy link
Contributor

Adding @xcoulon to this discussion as he's made some experiment about some json editor for JBoss Tools.

@angelozerr
Copy link
Owner Author

Adding @xcoulon to this discussion as he's made some experiment about some json editor for JBoss Tools.

Thanks @mickaelistria

I suppose you mean https://github.com/xcoulon/jbosstools-jsoneditor project . It is based on XText. I'm not sure that WTP Project accept XText? I would like that WTP provide :

  • org.eclipse.wst.json.core
  • org.eclipse.wst.json.ui

with IJSONModel like like WTP CSS & XML projects, I will study if it's easy to do.

@xcoulon
Copy link

xcoulon commented Feb 16, 2015

@angelozerr

I'm not familiar with the IDOMModel and ICSSModel you mentionned above. What are the benefits of such models ?
I'm actually not sure whether we could submit a JSON editor based on XText in WTP, but having one flexible enough to allow for custom content assist providers and hyperlink navigations would be a real plus, for sure!

@maxandersen
Copy link

I completely agree it would be great to have a json editor that is extensible like this.

@paulvi
Copy link
Contributor

paulvi commented Feb 16, 2015

There are 2 Editors without dependencies:

  • JSON Editor ~v0.9
  • JSON Tools ~v1.1 (is actually continuation of first, more features, but less stable)

They are already within @Nodeclipse http://www.nodeclipse.org/updates/ "Enide Tools Collection" group

see

@angelozerr
Copy link
Owner Author

I'm not familiar with the IDOMModel and ICSSModel you mentionned above. What are the benefits of such models ?

I don't know very well XText but if I have understood you have an editor wich maintains an EMF instance (in your case aen EMF JSONObject model), When user changes the code in the editor, the EMF insance is updated. Is that? ICSSModel, IDOMModel works like this. So if you change code in the editor, it updated the ICSSModel, IDOMModel. IDOMModel manages a IDOMDocument which is the DOM Document. So you have every time a valid DOM Document in memory even if the editor contains not XML valid. If you change the IDOMDocument (ex : you call with Java code IDOmDocument#createElement, it creates an element in this instance and the editor ir updated.) It's very cool mean to update a XML file by preserving spaces, tabulation, etc

I'm actually not sure whether we could submit a JSON editor based on XText in WTP,

Yes it's my fear. I think we should have a commons and advanced JSON Editor. The best place I think is WTP project. So we need to develop IJsonModel, JFlex grammar etc. It's more hard tasks than XText I think, but if we do that like existing XML and CSS editor, WTP could accept more this editor.

More I have seen that WTP will provide bower features (very cool!). Having a JSON Editor inside WTP could help a lot to provide an advanced JSON Editor for bower.json (compeltion, validation, etc).

but having one flexible enough to allow for custom content assist providers and hyperlink navigations would be a real plus, for sure!

Yes it's my goal too.

I completely agree it would be great to have a json editor that is extensible like this.

Cool!

There are 2 Editors without dependencies:

Yes I have seen that, but you cannot updated it with some JSON model and they ar enot extension to provide your custom completion, validation, etc

That's why I think WTP should provide a JSON Editor.

I will study that and create a github project for this WTP JSON Editor

@xcoulon
Copy link

xcoulon commented Feb 16, 2015

@angelozerr why JFlex grammar and not something like Antlr ? There's already a grammar for JSON with Antlr v4: https://github.com/antlr/grammars-v4/blob/master/json/JSON.g4
At sone point, I was thinking about building a prototype based on that grammar, but I did not have time to further dig into it. Do you think it could be a good solution ?

@angelozerr
Copy link
Owner Author

@angelozerr why JFlex grammar and not something like Antlr

because all XML, CSS, DTD parsers are based on JFlex. The very hard thing is that it must be a tolerant parser.

You can find the XML jflex at https://eclipse.googlesource.com/sourceediting/webtools.sourceediting/+/07297d3f285530630c6b6712f1c0306911b700c8/bundles/org.eclipse.wst.sse.core/DevTimeSupport/SedModel/HTMLTokenizer/devel/XMLTokenizer.jflex

I have created teh WTP JSON project at https://github.com/angelozerr/eclipse-wtp-json

I have started teh JSONTokenizer at https://github.com/angelozerr/eclipse-wtp-json/blob/master/org.eclipse.wst.json.core/Resource/parserTools/highlighting/JSONTokenizer.jflex which is a copy/paste of XMLTokenizer and I have renamed XML to JSON and remove some unused state.

To generate the class. You have an Ant Task https://github.com/angelozerr/eclipse-wtp-json/blob/master/org.eclipse.wst.json.core/Resource/parserTools/highlighting/generateJSONTokenizer.xml and to run it I have created a main at https://github.com/angelozerr/eclipse-wtp-json/blob/master/org.eclipse.wst.json.core/src/JSONTokenizerTest.java

It should be very fantastic if you can help me. You could work on teh parser and me on IJsonModel Thanks!

@piotrtomiak
Copy link
Contributor

@angelozerr ,

We have spent some time on fixing http://marketplace.eclipse.org/content/json-editor-plugin to provide all required support, that is among others, scientific notation, correct validation, outline fixes etc. Validation works only on save, and only in projects with WTP validation builder. Please check it in MyEclipse. If you are interested in getting the source code we can provide it.

JSON is freaking simple and making the structure too complex will not work well for you, I think. That editor already has tokenizer and error tolerant parsers. Simple, but working. I think you should be able to reuse it with probably with minor enhancements to support regions.

Important thing to do also, is it to decide on the model API. There are various JSON libraries, but you need to locate something like org.w3c.dom library for XML or org.w3c.dom.css for CSS. A standard for accessing JSON objects.

Very interesting project :)

@maxandersen
Copy link

@piotrtomiak if you want to contribute it to WTP we are all for this. @vrubezhny is a committer on JSDT where this would fit very well so we can make this happen if you are interested.

@angelozerr
Copy link
Owner Author

Important thing to do also, is it to decide on the model API.

I though use the JSON model https://json-processing-spec.java.net/nonav/releases/1.0/fcs/javadocs/index.html

JSON is freaking simple and making the structure too complex will not work well for you, I think. That editor already has tokenizer and error tolerant parsers. Simple, but working. I think you should be able to reuse it with probably with minor enhancements to support regions.

I would like to do the same thing than WTP for CSS and DOM (usse JFlex parser).

@xcoulon are you interested to help me for https://github.com/angelozerr/eclipse-wtp-json/blob/master/org.eclipse.wst.json.core/Resource/parserTools/highlighting/JSONTokenizer.jflex ?

@angelozerr
Copy link
Owner Author

@vrubezhny @dgolovin @mickaelistria @maxandersen @pascalleclercq @gamerson @paulvi @fbricon @piotrtomiak, @xcoulon @kaloyan-raev I have started the JSON Editor based on WTP and I can highlight JSON content. This highlight is based on JFlex lexer (like WTP CSS and DOM). The editor is based on WTP org.eclipse.wst.sse.ui.StructuredTextEditor. Today only highlight is avaiable. My goal is to provide extensible editor to manage easily same feature than PhpStorm http://blog.jetbrains.com/phpstorm/2015/01/working-with-composer-json-in-phpstorm/ You can see screenshot and explanation at https://github.com/angelozerr/eclipse-wtp-json

IMHO I think everybody could be interested with this JSON Editor kind. Any contribution are welcome!

I close this issue since https://github.com/angelozerr/eclipse-wtp-json exists.

@mickaelistria
Copy link
Contributor

Hey @angelozerr , would you be interested in contributing this editor to WTP? Since it uses the same dependencies, it would be pretty straightforward to include it.
http://git.eclipse.org/c/sourceediting/webtools.sourceediting.git would be a good candidate.
The immediate benefit is that Eclipse IDE would finally be able to ship a JSON editor our of the box.

@angelozerr
Copy link
Owner Author

would you be interested in contributing this editor to WTP?

@mickaelistria it's exaclty my wish. I had a comment about that at https://github.com/angelozerr/eclipse-wtp-json

@mickaelistria
Copy link
Contributor

@angelozerr So maybe you should try to have it in WTP immediatly, before everyone gets used to your GitHub repo and migration becomes costly.

@angelozerr
Copy link
Owner Author

So maybe you should try to have it in WTP immediatly

To be honnest with you, I don't prefer doing that. I would like to have users feedback, manage my wiki as I wish, create release every time, like I do with tern.java.

The packag ename follows the sam ename than css, xml : org.eclipse.wst.json.*

@mickaelistria
Copy link
Contributor

You'd get more user feedback by including it in WTP directly, and trying to get in into Mars release train, than by having it on a separate project. If it's on GitHub, it appears as yet-another-JSON-editor. If it's in WTP, it becomes the "official" JSON editor of Eclipse IDE.
You are free to manage wiki pages as you want on wiki.eclipse.org.
Also, while your component is incubating, you are free to bump versions often and make "component" releases. If WTP release train is too slow for you, I'd be glad to help you in having a dedicated build for the JSON editor, so you'll be able to release more often.

@fbricon
Copy link
Contributor

fbricon commented Feb 21, 2015

Angelo, 

I just have a couple of boring remarks :

  • you just can't use the org.eclipse namespace, not until you move the project to the Eclipse Foundation
  • it's very unlikely you'll be able to hop onto the Mars release train, we're very late in the process already. But it's fine, it's not the end of the world. You'll need a few stable releases before the project can be considered for inclusion in an EPP distro.
  • see https://www.eclipse.org/community/eclipse_newsletter/2014/july/article2.php for more info on how to start a project at the EF.

Maybe @waynebeaton can chime in and give you more details on what's reasonable to expect, from a timeframe standpoint. 

@angelozerr
Copy link
Owner Author

@mickaelistria for the moment it's just a POC. I must find time to improve it. So I don't prefer setting this project in WTP Incubation. More I find github tooling (like issues, wiki etc) more user friendly than Eclipse wiki, bugzilla.

My idea is to contribute to WTP once JSON Editor will be stable. My idea is to use this JSON Editor inside tern.java too to have an editor for .jshintrc, .eslintrc, .tern-project JSON file. (But the installation of JSON Editor will not be required).

you just can't use the org.eclipse namespace, not until you move the project to the Eclipse Foundation

Argh-( I use this namespace for my other projects :

I would like to contribute to Eclipse with those projects. Waiting for just that they become a little more stable.

@mickaelistria
Copy link
Contributor

I would like to contribute to Eclipse with those projects. Waiting for
just that they become a little more stable.
IMHO, it's a chicken-egg problem: your projects will get more user
reports and external contributions, and as a consequence more stability,
by sharing them under the Eclipse community process.

@maxandersen
Copy link

is fine using org.eclipse if intent is to contribute upstream, but shouldn't be including them in final/public releases. For that you really should step up on wtp-dev and ask for having incubator status or something of that sort. The longer we wait for that the harder everything is going to be.

@kaloyan-raev
Copy link

@angelozerr Developing this (and any other) plug-in under the Eclipse Foundation will indeed attract more contributions. Some companies, especially big corporations, have complex internal processes for allowing their employees contributing to open source projects. Such process goes much simpler if the project is under Eclipse Foundation compared to those "in the wild". This was the case in my previous company.

@kaloyan-raev
Copy link

@angelozerr and BTW, the same is valid for the adoption. Those big corporations would be more willing to include an Eclipse.org project in their products than one from the wild. It's another big fat process for adoption of open source projects.

@angelozerr
Copy link
Owner Author

Ok it seems that everybody wish to host WTP JSON in WTP repository incubation.

My fear is that I can create a release when I wish. I don't know how to create release with maven, etc It's @pascalleclercq who does that. This topic interest me, but I have no time and I would like really provide a JSON Editor based on WTP.

For the moment, it's just a POC, I don't know if I will able to implement my ideas. If I see that JSON Editor start working, I will create a bugzilla and @mickaelistria I hope you will have time to port the JSON Editor in WTP (Thanks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants