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

Send schema associations to JSON language server #2471

Closed
kaloyan-raev opened this issue Sep 16, 2016 · 4 comments
Closed

Send schema associations to JSON language server #2471

kaloyan-raev opened this issue Sep 16, 2016 · 4 comments
Assignees
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Milestone

Comments

@kaloyan-raev
Copy link
Contributor

kaloyan-raev commented Sep 16, 2016

The VS Code language server expects a custom (not part of the protocol) notification json/schemaAssociations to associate JSON files to JSON schemas. This activates capabilities like code completion, validation and hover without the need to add a $schema key.

Here is an example object passed with the json/schemaAssociations notification:

{
    "/bower.json": [
        "http://json.schemastore.org/bower"
    ],
    "/composer.json": [
        "https://getcomposer.org/schema.json"
    ],
}

Currently, Che does not send the json/schemaAssociations notification, which significantly limits the capabilities of the JSON language server integration. It is not realistic to expect that users will manually add the $schema key to each JSON file they work with.

Reproduction Steps:

  1. Open a bower.json file
  2. Try code completion

Expected behavior:

Code completion, validation and hover work without specifying a proper $schema key.

Observed behavior:

Code completion, validation and hover do not work without specifying a proper $schema key.

Che version: 5.0.0-M2-SNAPSHOT (latest master)
OS and version: Fedora 24
Docker version: 1.10.3
Che install: local build, run with the bin/che.sh script

Additional information:

  • Problem started happening recently, didn't happen in an older version of Che: [No]
  • Problem can be reliably reproduced, doesn't happen randomly: [Yes]
@TylerJewell TylerJewell added the kind/enhancement A feature request - must adhere to the feature request template. label Sep 16, 2016
kaloyan-raev added a commit to kaloyan-raev/che that referenced this issue Sep 16, 2016
The VS Code's JSON language server expects a 'json/schemaAssociations'
notification to associate JSON files to JSON schemas. This activates
capabilities like code completion, validation and hover without the need
to add a '$schema' key.

This change implements an extension of the JsonBasedLanguageServer that
registers as ServerInitializerObserver and sends the
'json/schemaAssociations' notification on the 'onServerInitialized'
event.

Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
@kaloyan-raev
Copy link
Contributor Author

kaloyan-raev commented Sep 16, 2016

I submitted PR #2474 with the fix.

Note that it contains a hardcoded list of associations. It's enough as a first step, but in future we should think about an extensible way to contribute to this list by plugins.

For example:

  • The JavaScript plugin should contribute the associations for bower.json
  • The Node plugin - for package.json
  • The PHP plugin - for composer.json
  • The TypeScript plugin - for tsconfig.json
  • etc.

For reference here is how the PHP plugin in VS Code contributes the schema association for composer.json: https://github.com/Microsoft/vscode/blob/master/extensions/php/package.json#L51-L56

@bmicklea bmicklea added this to the 5.0.0-M4 milestone Sep 20, 2016
@gazarenkov gazarenkov assigned kaloyan-raev and unassigned evidolob Sep 25, 2016
@riuvshin riuvshin modified the milestones: 5.0.0-M5, 5.0.0-M4 Sep 27, 2016
@bmicklea bmicklea mentioned this issue Sep 27, 2016
56 tasks
kaloyan-raev added a commit to kaloyan-raev/che that referenced this issue Sep 30, 2016
The VS Code's JSON language server expects a 'json/schemaAssociations'
notification to associate JSON files to JSON schemas. This activates
capabilities like code completion, validation and hover without the need
to add a '$schema' key.

This change implements an extension of the JsonBasedLanguageServer that
registers as ServerInitializerObserver and sends the
'json/schemaAssociations' notification on the 'onServerInitialized'
event.

Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
@bmicklea bmicklea modified the milestones: 5.0.0-M6, 5.0.0-M5 Oct 4, 2016
@bmicklea
Copy link

bmicklea commented Oct 4, 2016

@kaloyan-raev I'm moving this to M6 milestone because we're pushing to get M5 out ASAP.

kaloyan-raev added a commit to kaloyan-raev/che that referenced this issue Oct 4, 2016
The VS Code's JSON language server expects a 'json/schemaAssociations'
notification to associate JSON files to JSON schemas. This activates
capabilities like code completion, validation and hover without the need
to add a '$schema' key.

This change implements an extension of the JsonBasedLanguageServer that
registers as ServerInitializerObserver and sends the
'json/schemaAssociations' notification on the 'onServerInitialized'
event.

Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
@tolusha
Copy link
Contributor

tolusha commented Oct 6, 2016

@kaloyan-raev
Nice work.

Concerning implementation to have code cleaner I would change a bit your approach. I would add a new entity SchemeAssociator as observer of the ServerInitializer and wouldn't mix it with LanguageServer itself.

@kaloyan-raev
Copy link
Contributor Author

@tolusha OK. I am curious to see how this new approach looks like.

@bmicklea bmicklea mentioned this issue Oct 28, 2016
26 tasks
JPinkney pushed a commit to JPinkney/che that referenced this issue Aug 17, 2017
…pse-che#2474)

The VS Code's JSON language server expects a 'json/schemaAssociations'
notification to associate JSON files to JSON schemas. This activates
capabilities like code completion, validation and hover without the need
to add a '$schema' key.

This change implements an extension of the JsonBasedLanguageServer that
registers as ServerInitializerObserver and sends the
'json/schemaAssociations' notification on the 'onServerInitialized'
event.

Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Projects
None yet
Development

No branches or pull requests

6 participants