Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 488763

Summary: [parse] We need a tolerant JSON parser
Product: [ECD] Orion Reporter: Michael Rennie <Michael_Rennie>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P2 CC: curtis.windatt.public, kuschel, Olivier_Thomann, snorthov
Version: 11.0Keywords: triaged
Target Milestone: 14.0   
Hardware: All   
OS: All   
Whiteboard: 2017-02-24

Description Michael Rennie CLA 2016-03-01 09:54:53 EST
With interesting work happening in package.json and .tern-project files (and soon .eslintrc), we need a way to parse these files (possibly with errors) and be able to provide:

1. validation
2. fixes
3. content assist
4. hovers

At a minimum we would need a parser that can:

1. return the tokens from the file
2. provide some kind of AST
3. provide ranges / location infos for nodes / tokens

Perhaps there is already a lib out there that can do this (although I have not found on e yet).
Comment 1 Michael Rennie CLA 2016-10-24 11:38:36 EDT
Found one:

https://github.com/Microsoft/node-jsonc-parser

This is the parser that backs the VS code JSON language service. We could easily make use of this parser to power our tools.
Comment 2 Michael Rennie CLA 2017-02-01 14:50:17 EST
Opened the CQ: https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12612
Comment 3 Michael Rennie CLA 2017-02-14 17:44:37 EST
Pushed the new parser in: 

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=f5ffaf47e9a51ce2ec4613c075547134aec24623

I also provided:

1. the shared AST provider (for other plugins to make use of
2. made the JSON plugin a first-class plugin since it needs access to file client / service registry (which can't happen as part of the languagesPlugin

Will wait until the build is complete to makes sure it is building / loading properly.
Comment 4 Michael Rennie CLA 2017-02-15 00:47:52 EST
The new plugin is in the latest build and working as expected.

I will open separate bugs to provide features built on the parser.