From 8bc4375df21823e0aff04ac2590253339134570f Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Wed, 21 Feb 2024 08:11:50 -0500 Subject: [PATCH 1/2] Add `node` parameter to `JSONWorkerContribution.getInfoContribution` This should be backward compatible and allow implementers to discriminate between value and key nodes in order to only optionally return `undefined | Promise` --- src/jsonContributions.ts | 4 ++-- src/services/jsonHover.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jsonContributions.ts b/src/jsonContributions.ts index ac70b942..db6b1df5 100644 --- a/src/jsonContributions.ts +++ b/src/jsonContributions.ts @@ -2,10 +2,10 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Thenable, MarkedString, CompletionItem } from './jsonLanguageService'; +import { Thenable, MarkedString, CompletionItem, ASTNode } from './jsonLanguageService'; export interface JSONWorkerContribution { - getInfoContribution(uri: string, location: JSONPath): Thenable; + getInfoContribution(uri: string, location: JSONPath, node: ASTNode): Thenable; collectPropertyCompletions(uri: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Thenable; collectValueCompletions(uri: string, location: JSONPath, propertyKey: string, result: CompletionsCollector): Thenable; collectDefaultCompletions(uri: string, result: CompletionsCollector): Thenable; diff --git a/src/services/jsonHover.ts b/src/services/jsonHover.ts index e68f945b..cc26440f 100644 --- a/src/services/jsonHover.ts +++ b/src/services/jsonHover.ts @@ -53,7 +53,7 @@ export class JSONHover { const location = Parser.getNodePath(node); for (let i = this.contributions.length - 1; i >= 0; i--) { const contribution = this.contributions[i]; - const promise = contribution.getInfoContribution(document.uri, location); + const promise = contribution.getInfoContribution(document.uri, location, node); if (promise) { return promise.then(htmlContent => createHover(htmlContent)); } From f034b125e11ae2180a902471a97d0a7b40dfc230 Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Wed, 21 Feb 2024 08:21:01 -0500 Subject: [PATCH 2/2] Adjust `getInfoContribution` return type to implementation --- src/jsonContributions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jsonContributions.ts b/src/jsonContributions.ts index db6b1df5..e7ef897b 100644 --- a/src/jsonContributions.ts +++ b/src/jsonContributions.ts @@ -5,7 +5,7 @@ import { Thenable, MarkedString, CompletionItem, ASTNode } from './jsonLanguageService'; export interface JSONWorkerContribution { - getInfoContribution(uri: string, location: JSONPath, node: ASTNode): Thenable; + getInfoContribution(uri: string, location: JSONPath, node: ASTNode): undefined | Thenable; collectPropertyCompletions(uri: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Thenable; collectValueCompletions(uri: string, location: JSONPath, propertyKey: string, result: CompletionsCollector): Thenable; collectDefaultCompletions(uri: string, result: CompletionsCollector): Thenable;