[json] Go to definition for $ref. Fixes #69411

This commit is contained in:
Martin Aeschlimann
2020-04-27 22:30:58 +02:00
parent c610dd7fc7
commit 4a3bd05497
6 changed files with 50 additions and 27 deletions

View File

@@ -174,7 +174,8 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
documentRangeFormattingProvider: params.initializationOptions.provideFormatter === true,
colorProvider: {},
foldingRangeProvider: true,
selectionRangeProvider: true
selectionRangeProvider: true,
definitionProvider: true
};
return { capabilities };
@@ -516,5 +517,16 @@ connection.onSelectionRanges((params, token) => {
}, [], `Error while computing selection ranges for ${params.textDocument.uri}`, token);
});
connection.onDefinition((params, token) => {
return runSafeAsync(async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
const jsonDocument = getJSONDocument(document);
return languageService.findDefinition(document, params.position, jsonDocument);
}
return [];
}, [], `Error while computing definitions for ${params.textDocument.uri}`, token);
});
// Listen on the connection
connection.listen();