From 4d178f10e2479d3c5a078924c2f934b33c769360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D1=80=D0=B0=D0=B3=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B8=D1=9B?= Date: Fri, 21 Jun 2024 14:31:55 +0200 Subject: [PATCH 1/3] add on_server_notification_async --- plugin/core/sessions.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index 8d06245f9..60fe7b383 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -1047,6 +1047,15 @@ def on_server_response_async(self, method: str, response: Response) -> None: """ pass + def on_server_notification_async(self, method: str, notification: Notification) -> None: + """ + Notifies about a notification message that has been received from the language server. + + :param method: The method of the notification. + :param notification: The notification object. + """ + pass + def on_open_uri_async(self, uri: DocumentUri, callback: Callable[[str, str, str], None]) -> bool: """ Called when a language server reports to open an URI. If you know how to handle this URI, then return True and @@ -2377,6 +2386,8 @@ def deduce_payload( else: res = (handler, result, None, "notification", method) self._logger.incoming_notification(method, result, res[0] is None) + if self._plugin: + self._plugin.on_server_notification_async(method, Notification(method, result)) return res elif "id" in payload: if payload["id"] is None: From ff6f86c966a3c570e0743398e65a16258ea2de73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D1=80=D0=B0=D0=B3=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B8=D1=9B?= Date: Fri, 21 Jun 2024 14:42:19 +0200 Subject: [PATCH 2/3] make the API more similar to on_pre_send_notification_async First I tired to make it look like on_server_response_async but the method argument is redundant --- plugin/core/sessions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index 60fe7b383..cb46012fa 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -1047,7 +1047,7 @@ def on_server_response_async(self, method: str, response: Response) -> None: """ pass - def on_server_notification_async(self, method: str, notification: Notification) -> None: + def on_server_notification_async(self, notification: Notification) -> None: """ Notifies about a notification message that has been received from the language server. @@ -2387,7 +2387,7 @@ def deduce_payload( res = (handler, result, None, "notification", method) self._logger.incoming_notification(method, result, res[0] is None) if self._plugin: - self._plugin.on_server_notification_async(method, Notification(method, result)) + self._plugin.on_server_notification_async(Notification(method, result)) return res elif "id" in payload: if payload["id"] is None: From d74e14d64eba737cba991b9d0c38af680c48ab7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D1=80=D0=B0=D0=B3=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B8=D1=9B?= Date: Fri, 21 Jun 2024 14:46:32 +0200 Subject: [PATCH 3/3] outdated comment --- plugin/core/sessions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index cb46012fa..ccb30b429 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -1051,7 +1051,6 @@ def on_server_notification_async(self, notification: Notification) -> None: """ Notifies about a notification message that has been received from the language server. - :param method: The method of the notification. :param notification: The notification object. """ pass