Files
Python-With-Gtk-Template/src/libs/dto/code/lsp/lsp_message_structs.py
itdominator 220a8c2743 Moved plugins and add loaded file filtering
- Moved prettify_json and lsp_completer plugins to sub categories
- Add filter_out_loaded_files to prevent opening already-loaded files
- Refactor code events into single events module
- Fix signal blocking during file load operations
- Include READONLY state in source view lifecycle handling
2026-03-08 00:46:21 -06:00

96 lines
2.4 KiB
Python

# Python imports
import json
import enum
from dataclasses import dataclass
# Lib imports
# Application imports
from .lsp_structs import TextDocumentItem
class MessageEncoder(json.JSONEncoder):
"""
Encodes an object in JSON
"""
def default(self, o): # pylint: disable=E0202
return o.__dict__
@dataclass
class ClientRequest(object):
def __init__(self, id: int, method: str, params: dict):
"""
Constructs a new Client Request instance.
:param int id: Message id to track instance.
:param str method: The type of lsp request being made.
:param dict params: The arguments of the given method.
"""
self.jsonrpc = "2.0"
self.id = id
self.method = method
self.params = params
@dataclass
class ClientNotification(object):
def __init__(self, method: str, params: dict):
"""
Constructs a new Client Notification instance.
:param str method: The type of lsp notification being made.
:param dict params: The arguments of the given method.
"""
self.jsonrpc = "2.0"
self.method = method
self.params = params
@dataclass
class LSPResponseRequest(object):
"""
Constructs a new LSP Response Request instance.
:param id result: The id of the given message.
:param dict result: The arguments of the given method.
"""
jsonrpc: str
id: int
result: dict
@dataclass
class LSPResponseNotification(object):
"""
Constructs a new LSP Response Notification instance.
:param str method: The type of lsp notification being made.
:params dict result: The arguments of the given method.
"""
jsonrpc: str
method: str
params: dict
@dataclass
class LSPIDResponseNotification(object):
"""
Constructs a new LSP Response Notification instance.
:param str method: The type of lsp notification being made.
:params dict result: The arguments of the given method.
"""
jsonrpc: str
id: int
method: str
params: dict
class MessageTypes(ClientRequest, ClientNotification, LSPResponseRequest, LSPResponseNotification, LSPIDResponseNotification):
...
class ClientMessageTypes(ClientRequest, ClientNotification):
...
class LSPResponseTypes(LSPResponseRequest, LSPResponseNotification):
...