Skip to content
This repository was archived by the owner on Jul 27, 2023. It is now read-only.

Commit cea01c4

Browse files
committed
[json] Go to definition for $ref. Fixes #69411
1 parent 54dfd61 commit cea01c4

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The server implements the following capabilities of the language server protocol
2323
- [Code Formatting](https://microsoft.github.io/language-server-protocol/specification#textDocument_rangeFormatting) supporting ranges and formatting the whole document.
2424
- [Folding Ranges](https://microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange) for all folding ranges in the document.
2525
- Semantic Selection for semantic selection for one or multiple cursor positions.
26+
- [Goto Definition](https://microsoft.github.io/language-server-protocol/specification#textDocument_definition) for $ref references in JSON schemas
2627
- [Diagnostics (Validation)](https://microsoft.github.io/language-server-protocol/specification#textDocument_publishDiagnostics) are pushed for all open documents
2728
- syntax errors
2829
- structural validation based on the document's [JSON schema](http://json-schema.org/).

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"main": "./out/jsonServerMain",
1414
"dependencies": {
1515
"jsonc-parser": "^2.2.1",
16-
"request-light": "^0.2.5",
17-
"vscode-json-languageservice": "^3.5.2",
16+
"request-light": "^0.3.0",
17+
"vscode-json-languageservice": "^3.6.0",
1818
"vscode-languageserver": "^6.1.1",
1919
"vscode-uri": "^2.1.1"
2020
},

src/jsonServerMain.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
174174
documentRangeFormattingProvider: params.initializationOptions.provideFormatter === true,
175175
colorProvider: {},
176176
foldingRangeProvider: true,
177-
selectionRangeProvider: true
177+
selectionRangeProvider: true,
178+
definitionProvider: true
178179
};
179180

180181
return { capabilities };
@@ -516,5 +517,16 @@ connection.onSelectionRanges((params, token) => {
516517
}, [], `Error while computing selection ranges for ${params.textDocument.uri}`, token);
517518
});
518519

520+
connection.onDefinition((params, token) => {
521+
return runSafeAsync(async () => {
522+
const document = documents.get(params.textDocument.uri);
523+
if (document) {
524+
const jsonDocument = getJSONDocument(document);
525+
return languageService.findDefinition(document, params.position, jsonDocument);
526+
}
527+
return [];
528+
}, [], `Error while computing definitions for ${params.textDocument.uri}`, token);
529+
});
530+
519531
// Listen on the connection
520532
connection.listen();

yarn.lock

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ http-proxy-agent@^2.1.0:
5353
agent-base "4"
5454
debug "3.1.0"
5555

56-
https-proxy-agent@^2.2.3:
56+
https-proxy-agent@^2.2.4:
5757
version "2.2.4"
5858
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b"
5959
integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==
@@ -71,24 +71,24 @@ ms@2.0.0:
7171
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
7272
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
7373

74-
request-light@^0.2.5:
75-
version "0.2.5"
76-
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.2.5.tgz#38a3da7b2e56f7af8cbba57e8a94930ee2380746"
77-
integrity sha512-eBEh+GzJAftUnex6tcL6eV2JCifY0+sZMIUpUPOVXbs2nV5hla4ZMmO3icYKGuGVuQ2zHE9evh4OrRcH4iyYYw==
74+
request-light@^0.3.0:
75+
version "0.3.0"
76+
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.3.0.tgz#04daa783e7f0a70392328dda4b546f3e27845f2d"
77+
integrity sha512-xlVlZVT0ZvCT+c3zm3SjeFCzchoQxsUUmx5fkal0I6RIDJK+lmb1UYyKJ7WM4dTfnzHP4ElWwAf8Dli8c0/tVA==
7878
dependencies:
7979
http-proxy-agent "^2.1.0"
80-
https-proxy-agent "^2.2.3"
80+
https-proxy-agent "^2.2.4"
8181
vscode-nls "^4.1.1"
8282

83-
vscode-json-languageservice@^3.5.2:
84-
version "3.5.2"
85-
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.5.2.tgz#4b898140a8e581359c10660845a4cae15dcbb4f9"
86-
integrity sha512-9cUvBq00O08lpWVVOx6tQ1yLxCHss79nsUdEAVYGomRyMbnPBmc0AkYPcXI9WK1EM6HBo0R9Zo3NjFhcICpy4A==
83+
vscode-json-languageservice@^3.6.0:
84+
version "3.6.0"
85+
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.6.0.tgz#133a1e2c3a3dffe38564a1ba948516805c3c1869"
86+
integrity sha512-dXzFywypUZ9T0tjr4fREZiknXDz6vAGx1zsxbQY1+9DOpjMfbz0VLP873KmcbuvL4K3nseKTxc4TKHu8kLXRMw==
8787
dependencies:
8888
jsonc-parser "^2.2.1"
8989
vscode-languageserver-textdocument "^1.0.1"
9090
vscode-languageserver-types "^3.15.1"
91-
vscode-nls "^4.1.1"
91+
vscode-nls "^4.1.2"
9292
vscode-uri "^2.1.1"
9393

9494
vscode-jsonrpc@^5.0.1:
@@ -126,6 +126,11 @@ vscode-nls@^4.1.1:
126126
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.1.tgz#f9916b64e4947b20322defb1e676a495861f133c"
127127
integrity sha512-4R+2UoUUU/LdnMnFjePxfLqNhBS8lrAFyX7pjb2ud/lqDkrUavFUTcG7wR0HBZFakae0Q6KLBFjMS6W93F403A==
128128

129+
vscode-nls@^4.1.2:
130+
version "4.1.2"
131+
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.2.tgz#ca8bf8bb82a0987b32801f9fddfdd2fb9fd3c167"
132+
integrity sha512-7bOHxPsfyuCqmP+hZXscLhiHwe7CSuFE4hyhbs22xPIhQ4jv99FcR4eBzfYYVLP356HNFpdvz63FFb/xw6T4Iw==
133+
129134
vscode-uri@^2.1.1:
130135
version "2.1.1"
131136
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-2.1.1.tgz#5aa1803391b6ebdd17d047f51365cf62c38f6e90"

0 commit comments

Comments
 (0)