From 5876ba08b69109263b8fc2fdba7d454dcd6061f5 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Thu, 7 Nov 2024 15:19:56 +0700 Subject: [PATCH] use longer names --- plugin/code_actions.py | 10 +++++----- plugin/core/logging.py | 16 ++++++++-------- plugin/core/workspace.py | 8 ++++---- plugin/execute_command.py | 4 ++-- plugin/rename.py | 10 +++++----- plugin/tooling.py | 34 +++++++++++++++++----------------- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/plugin/code_actions.py b/plugin/code_actions.py index 973d23d88..74e720388 100644 --- a/plugin/code_actions.py +++ b/plugin/code_actions.py @@ -1,5 +1,5 @@ from __future__ import annotations -from .core.logging import notify_err +from .core.logging import notify_error from .core.promise import Promise from .core.protocol import CodeAction from .core.protocol import CodeActionKind @@ -353,8 +353,8 @@ def run_async() -> None: def _handle_response_async(self, session_name: str, response: Any) -> None: if isinstance(response, Error): - msg = f"{session_name}: {str(response)}" - notify_err(msg, msg) + message = f"{session_name}: {str(response)}" + notify_error(message, message) # This command must be a WindowCommand in order to reliably hide corresponding menu entries when no view has focus. @@ -416,8 +416,8 @@ def run_async(self, index: int, event: dict | None) -> None: def _handle_response_async(self, session_name: str, response: Any) -> None: if isinstance(response, Error): - msg = f"{session_name}: {str(response)}" - notify_err(msg, msg) + message = f"{session_name}: {str(response)}" + notify_error(message, message) def _is_cache_valid(self, event: dict | None) -> bool: view = self.view diff --git a/plugin/core/logging.py b/plugin/core/logging.py index bbd337a14..2c0b24d9e 100644 --- a/plugin/core/logging.py +++ b/plugin/core/logging.py @@ -41,25 +41,25 @@ def printf(*args: Any, prefix: str = 'LSP') -> None: print(prefix + ":", *args) -def notify(win: sublime.Window, msg: str, status: str = 'LSP: see console log…') -> None: +def notify(window: sublime.Window, message: str, status: str = 'LSP: see console log…') -> None: """Pick either of the 2 ways to show a message: - via a blocking modal dialog - via a detailed console message and a short status message""" from .settings import userprefs if userprefs().suppress_error_dialogs: - win.status_message(status) - print(msg) + window.status_message(status) + print(message) else: - win.message_dialog(msg) + window.message_dialog(message) -def notify_err(win: sublime.Window, msg: str, status: str = '❗LSP: see console log…') -> None: +def notify_error(window: sublime.Window, message: str, status: str = '❗LSP: see console log…') -> None: """Pick either of the 2 ways to show a message: - via a blocking modal dialog - via a detailed console message and a short status message""" from .settings import userprefs if userprefs().suppress_error_dialogs: - win.status_message(status) - print(msg) + window.status_message(status) + print(message) else: - sublime.error_message(msg) + sublime.error_message(message) diff --git a/plugin/core/workspace.py b/plugin/core/workspace.py index 8a7dcc9c4..cc87dd070 100644 --- a/plugin/core/workspace.py +++ b/plugin/core/workspace.py @@ -147,9 +147,9 @@ def enable_in_project(window: sublime.Window, config_name: str) -> None: project_client_settings['enabled'] = True window.set_project_data(project_data) else: - msg = f"Can't enable {config_name} in the current workspace. Ensure that the project is saved first." + message = f"Can't enable {config_name} in the current workspace. Ensure that the project is saved first." status = f"LSP: Can't enable {config_name} in this workspace… See console" - notify(window, msg, status) + notify(window, message, status) def disable_in_project(window: sublime.Window, config_name: str) -> None: @@ -161,6 +161,6 @@ def disable_in_project(window: sublime.Window, config_name: str) -> None: project_client_settings['enabled'] = False window.set_project_data(project_data) else: - msg = f"Can't disable {config_name} in the current workspace. Ensure that the project is saved first." + message = f"Can't disable {config_name} in the current workspace. Ensure that the project is saved first." status = f"LSP: Can't enable {config_name} in this workspace… See console" - notify(window, msg, status) + notify(window, message, status) diff --git a/plugin/execute_command.py b/plugin/execute_command.py index fea7e8ca6..d89fe4e65 100644 --- a/plugin/execute_command.py +++ b/plugin/execute_command.py @@ -59,9 +59,9 @@ def handle_error_async(self, error: Error, command_name: str) -> None: :param error: The Error object. :param command_name: The name of the command that was executed. """ - msg = f"command {command_name} failed. Reason: {str(error)}" + message = f"command {command_name} failed. Reason: {str(error)}" status = f"LSP: {command_name} failed… See console" - notify(self.view.window(), msg, status) + notify(self.view.window(), message, status) def _expand_variables(self, command_args: list[Any]) -> list[Any]: view = self.view diff --git a/plugin/rename.py b/plugin/rename.py index 6925f1b16..715536af8 100644 --- a/plugin/rename.py +++ b/plugin/rename.py @@ -2,7 +2,7 @@ from .core.edit import parse_range from .core.edit import parse_workspace_edit from .core.edit import WorkspaceChanges -from .core.logging import notify_err +from .core.logging import notify_error from .core.protocol import PrepareRenameParams from .core.protocol import PrepareRenameResult from .core.protocol import Range @@ -212,8 +212,8 @@ def _on_rename_result_async(self, session: Session, response: WorkspaceEdit | No def _on_prepare_result(self, pos: int, session_name: str | None, response: PrepareRenameResult | None) -> None: if response is None: - msg = "The current selection cannot be renamed" - notify_err(msg, msg) + message = "The current selection cannot be renamed" + notify_error(message, message) return if is_range_response(response): r = range_to_region(response, self.view) @@ -228,8 +228,8 @@ def _on_prepare_result(self, pos: int, session_name: str | None, response: Prepa self.view.run_command("lsp_symbol_rename", args) def _on_prepare_error(self, error: Any) -> None: - msg = "Rename error: {}".format(error["message"]) - notify_err(msg, msg) + message = "Rename error: {}".format(error["message"]) + notify_error(message, message) def _get_relative_path(self, file_path: str) -> str: wm = windows.lookup(self.view.window()) diff --git a/plugin/tooling.py b/plugin/tooling.py index 3f5fd09e9..aa1a982fd 100644 --- a/plugin/tooling.py +++ b/plugin/tooling.py @@ -2,7 +2,7 @@ from .core.css import css from .core.logging import debug from .core.logging import notify -from .core.logging import notify_err +from .core.logging import notify_error from .core.registry import windows from .core.sessions import get_plugin from .core.transports import create_transport @@ -132,19 +132,19 @@ def run(self, base_package_name: str) -> None: try: urllib.parse.urlparse(base_url) except Exception: - msg = "The clipboard content must be a URL to a package.json file." + message = "The clipboard content must be a URL to a package.json file." status = "Clipboard must be a URL to package.json" - notify_err(sublime.active_window(), msg, status) + notify_error(sublime.active_window(), message, status) return if not base_url.endswith("package.json"): - msg = "URL must end with 'package.json'" - notify_err(sublime.active_window(), msg, msg) + message = "URL must end with 'package.json'" + notify_error(sublime.active_window(), message, message) return try: package = json.loads(urllib.request.urlopen(base_url).read().decode("utf-8")) except Exception as ex: - msg = f'Unable to load "{base_url}": {ex}' - notify_err(sublime.active_window(), msg, msg) + message = f'Unable to load "{base_url}": {ex}' + notify_error(sublime.active_window(), message, message) return # There might be a translations file as well. @@ -156,13 +156,13 @@ def run(self, base_package_name: str) -> None: contributes = package.get("contributes") if not isinstance(contributes, dict): - msg = 'No "contributes" key found!' - notify_err(sublime.active_window(), msg, msg) + message = 'No "contributes" key found!' + notify_error(sublime.active_window(), message, message) return configuration = contributes.get("configuration") if not isinstance(configuration, dict) and not isinstance(configuration, list): - msg = 'No "contributes.configuration" key found!' - notify_err(sublime.active_window(), msg, msg) + message = 'No "contributes.configuration" key found!' + notify_error(sublime.active_window(), message, message) return if isinstance(configuration, dict): properties = configuration.get("properties") @@ -171,8 +171,8 @@ def run(self, base_package_name: str) -> None: for configuration_item in configuration: properties.update(configuration_item.get("properties")) if not isinstance(properties, dict): - msg = 'No "contributes.configuration.properties" key found!' - notify_err(sublime.active_window(), msg, msg) + message = 'No "contributes.configuration.properties" key found!' + notify_error(sublime.active_window(), message, message) return # Process each key-value pair of the server settings. @@ -312,8 +312,8 @@ def run(self) -> None: return view = wm.window.active_view() if not view: - msg = 'Troubleshooting must be run with a file opened' - notify(self.window, msg, msg) + message = 'Troubleshooting must be run with a file opened' + notify(self.window, message, message) return active_view = view configs = wm.get_config_manager().get_configs() @@ -467,9 +467,9 @@ def run(self, edit: sublime.Edit) -> None: return listener = wm.listener_for_view(self.view) if not listener or not any(listener.session_views_async()): - msg = "There is no language server running for this view." + message = "There is no language server running for this view." status = "No language server for this view" - notify_err(wm.window, msg, status) + notify_error(wm.window, message, status) return v = wm.window.new_file() v.set_scratch(True)