JSON language service extracted from VSCode to be reused, e.g in the Monaco editor.
Перейти к файлу
Martin Aeschlimann 1b453f9ab5
Schema Does Not Load With URI myproto:///schema.json (#248)
2024-10-31 12:19:35 +01:00
.github delete pr-chat action (#158) 2022-11-09 09:20:14 +01:00
.vscode add release pipeline & cleanup ci pipelines (#156) 2022-11-03 16:24:51 +01:00
build prepare 5.4.0 (#234) 2024-06-24 08:59:46 -07:00
src Schema Does Not Load With URI myproto:///schema.json (#248) 2024-10-31 12:19:35 +01:00
.eslintrc.json update dependencies 2020-09-16 10:15:49 +02:00
.gitignore update dependencies & adopt eslint 2020-04-27 22:12:17 +02:00
.mocharc.json update dependencies 2020-09-16 10:15:49 +02:00
.npmignore Provide a usage example in the readme. Fixes #39 2020-11-12 10:49:38 +01:00
CHANGELOG.md increased the version to 5.3.1 (#175) 2023-02-24 17:32:19 +01:00
LICENSE.md replace minimatch with globregexp 2021-07-16 16:55:49 +02:00
README.md add release pipeline & cleanup ci pipelines (#156) 2022-11-03 16:24:51 +01:00
SECURITY.md Microsoft mandatory file 2022-05-16 22:00:42 +00:00
package-lock.json prepare 5.4.1 (#242) 2024-08-26 12:23:21 -07:00
package.json prepare 5.4.1 (#242) 2024-08-26 12:23:21 -07:00

README.md

vscode-json-languageservice

JSON language service extracted from VSCode to be reused, e.g in the Monaco editor.

npm Package NPM Downloads Build Status License: MIT

Why?

The vscode-json-languageservice contains the language smarts behind the JSON editing experience of Visual Studio Code and the Monaco editor.

  • doValidation analyses an input string and returns syntax and lint errors.
  • doComplete provides completion proposals for a given location.
  • doResolve resolves a completion proposals.
  • doHover provides a hover text for a given location.
  • findDocumentSymbols provides all symbols in the given document.
  • findDocumentColors provides all color symbols in the given document.
  • getColorPresentations returns available color formats for a color symbol.
  • format formats the code at the given range.
  • getFoldingRanges gets folding ranges for the given document.
  • getSelectionRanges gets selection ranges for a given location.
  • getMatchingSchemas matches a document against its schema and returns all AST nodes along with the matching sub schemas.
  • parseJSONDocument creates a JSON document from source code.
  • newJSONDocument creates a JSON document from an AST.

For the complete API see jsonLanguageService.ts and jsonLanguageTypes.ts

Installation

npm install --save vscode-json-languageservice

Sample usage

See sample.ts for an example on how to use the JSON language service.

To run the sample use yarn sample

Development

git clone https://github.com/microsoft/vscode-json-languageservice
cd vscode-json-languageservice
yarn

Use yarn test to compile and run tests

How can I run and debug the service?

  • open the folder in VSCode.
  • set breakpoints, e.g. in jsonCompletion.ts
  • run the Unit tests from the run viewlet and wait until a breakpoint is hit: image

How can I run and debug the service inside an instance of VSCode?

  • run VSCode out of sources setup as described here: https://github.com/Microsoft/vscode/wiki/How-to-Contribute
  • use yarn link vscode-json-languageservice in vscode/extensions/json-language-features/server to run VSCode with the latest changes from vscode-json-languageservice
  • run VSCode out of source (vscode/scripts/code.sh|bat) and open a .json file
  • in VSCode window that is open on the vscode-json-languageservice sources, run command Debug: Attach to Node process and pick the code-oss process with the json-language-features path image
  • set breakpoints, e.g. in jsonCompletion.ts
  • in the instance run from sources, invoke code completion in the .json file