refactor(lsp): restructure lsp plugin controller architecture and simplify provider cache
- Replace LSPManager usage with LSPController integration - Move UI access through lsp_controller.lsp_manager_ui - Remove legacy ProviderResponseCache client management - Simplify completion filtering and matcher handling - Improve typing annotations and modernize union syntax - Clean up unused imports and dead code - Fix completion item parsing for insertText/textEdit fallbacks - Add async-safe scrolling via GLib.idle_add
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