Skip to content

Commit

Permalink
use longer names
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenesvk committed Nov 7, 2024
1 parent bd23db9 commit 5876ba0
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
10 changes: 5 additions & 5 deletions plugin/code_actions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions plugin/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions plugin/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
4 changes: 2 additions & 2 deletions plugin/execute_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions plugin/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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())
Expand Down
34 changes: 17 additions & 17 deletions plugin/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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")
Expand All @@ -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.
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5876ba0

Please sign in to comment.