Skip to content

Commit e45ab35

Browse files
authored
LSP: Add more logs for debugging (#130)
1 parent 0b8948e commit e45ab35

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

auto_typing_final/lsp.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,25 @@ def path_from_uri(uri: str) -> Path | None:
5454

5555
def parse_settings(raw_full_client_settings: Any) -> FullClientSettings | None: # noqa: ANN401
5656
if not isinstance(raw_full_client_settings, dict):
57+
LSP_SERVER.show_message_log(
58+
f"invalid settings format: expected a dictionary. Settings: {raw_full_client_settings}"
59+
)
5760
return None
5861
client_settings: Final = raw_full_client_settings.get("auto-typing-final")
5962
if not isinstance(client_settings, dict):
63+
LSP_SERVER.show_message_log(
64+
f"invalid settings format: 'auto-typing-final' is not a dictionary. Settings: {raw_full_client_settings}"
65+
)
6066
return None
6167
if client_settings.get("import-style") not in {"typing-final", "final"}:
68+
LSP_SERVER.show_message_log(
69+
f"invalid import-style setting: must be 'typing-final' or 'final'. Settings: {raw_full_client_settings}"
70+
)
6271
return None
6372
if not isinstance(client_settings.get("ignore-global-vars"), bool):
73+
LSP_SERVER.show_message_log(
74+
f"invalid ignore-global-vars setting: must be a boolean. Settings: {raw_full_client_settings}"
75+
)
6476
return None
6577
return typing.cast("FullClientSettings", raw_full_client_settings)
6678

@@ -189,10 +201,12 @@ async def initialized(ls: CustomLanguageServer, _: lsp.InitializedParams) -> Non
189201
]
190202
)
191203
)
204+
LSP_SERVER.show_message_log("language server initialized")
192205

193206

194207
@LSP_SERVER.feature(lsp.WORKSPACE_DID_CHANGE_CONFIGURATION)
195208
def workspace_did_change_configuration(ls: CustomLanguageServer, params: lsp.DidChangeConfigurationParams) -> None:
209+
LSP_SERVER.show_message_log("handling workspace configuration change")
196210
ls.service = Service.try_from_settings(ls_name=ls.name, settings=params.settings) or ls.service
197211
if not ls.service:
198212
return

0 commit comments

Comments
 (0)