refactor(lsp): replace LSPManager with controller-based architecture
- Remove legacy LSPManager dialog implementation - Introduce LSPController as the central LSP entry point - Route UI interactions through lsp_controller.lsp_manager_ui - Move client lifecycle handling out of ProviderResponseCache - Simplify completion cache and matcher filtering - Improve LSP completion item parsing with safer fallbacks - Modernize typing (Python 3.10 union syntax) - Remove unused imports and dead code - Use GLib.idle_add for safe UI scrolling operations - Minor comment and spelling fixes
This commit is contained in:
49
plugins/code/ui/lsp_manager/handlers/registry.py
Normal file
49
plugins/code/ui/lsp_manager/handlers/registry.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
from ..mixins.lsp_server_events_mixin import LSPServerEventsMixin
|
||||
|
||||
from .base import BaseHandler
|
||||
from .default import DefaultHandler
|
||||
from .python import PythonHandler
|
||||
from .java import JavaHandler
|
||||
|
||||
|
||||
|
||||
class HandlerRegistry(LSPServerEventsMixin):
|
||||
def __init__(self):
|
||||
|
||||
self._instances: dict = {}
|
||||
self._lang_handlers: dict = {
|
||||
"default": DefaultHandler,
|
||||
"python": PythonHandler,
|
||||
"java": JavaHandler,
|
||||
}
|
||||
|
||||
|
||||
def _get_instance(self, handler_cls: type[BaseHandler]) -> BaseHandler:
|
||||
if handler_cls in self._instances: return self._instances[handler_cls]
|
||||
|
||||
self._instances[handler_cls] = handler_cls()
|
||||
|
||||
return self._instances[handler_cls]
|
||||
|
||||
def register_handler(self, lang_id: str, handler_cls: type[BaseHandler]):
|
||||
self._lang_handlers[lang_id] = handler_cls
|
||||
|
||||
def get_handler(self, lang_id: str = "", method: str = ""):
|
||||
handler_cls = self._lang_handlers.get(
|
||||
lang_id, self._lang_handlers.get("default", DefaultHandler)
|
||||
)
|
||||
|
||||
if not handler_cls: return None
|
||||
|
||||
return self._get_instance(handler_cls)
|
||||
|
||||
def close_handler(self, lang_id: str):
|
||||
if not lang_id in self._lang_handlers: return
|
||||
|
||||
handler_cls = self._lang_handlers[lang_id]
|
||||
self._instances.pop(handler_cls, None)
|
||||
Reference in New Issue
Block a user