From 41356aced277afea3b50e52acf6aa3cd6890c963 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 16 May 2020 10:49:00 +0200 Subject: [PATCH 1/6] Fix type definitions --- pygls/types.py | 64 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/pygls/types.py b/pygls/types.py index ead7468f..ee238938 100644 --- a/pygls/types.py +++ b/pygls/types.py @@ -84,10 +84,10 @@ def __init__(self, class CodeActionAbstract: - def __init(self, - dynamic_registration: bool, - code_action_literal_support: - 'CodeActionLiteralSupportAbstract'): + def __init__(self, + dynamic_registration: bool, + code_action_literal_support: + 'CodeActionLiteralSupportAbstract'): self.dynamicRegistration = dynamic_registration self.codeActionLiteralSupport = code_action_literal_support @@ -475,7 +475,9 @@ class DocumentHighlightKind(enum.IntEnum): class DocumentHighlight: - def __init__(self, range: 'Range', kind: DocumentHighlightKind = DocumentHighlightKind.Text): + def __init__(self, + range: 'Range', + kind: DocumentHighlightKind = DocumentHighlightKind.Text): self.range = range self.kind = kind @@ -628,10 +630,10 @@ def __init__(self, class FoldingRangeAbstract: - def __init(self, - dynamic_registration: bool, - range_limit: NumType, - line_folding_only: bool): + def __init__(self, + dynamic_registration: bool, + range_limit: NumType, + line_folding_only: bool): self.dynamicRegistration = dynamic_registration self.rangeLimit = range_limit self.lineFoldingOnly = line_folding_only @@ -678,9 +680,16 @@ class Trace(str, enum.Enum): Verbose = 'verbose' +class ClientInfo: + def __init__(self, name: str = 'unknown', version: str = None): + self.name = name + self.version = version + + class InitializeParams: def __init__(self, process_id: int, + client_info: ClientInfo, capabilities: ClientCapabilities, root_uri: str = None, root_path: Optional[str] = None, @@ -688,6 +697,7 @@ def __init__(self, trace: Optional[Trace] = Trace.Off, workspace_folders: Optional[List['WorkspaceFolder']] = None) -> None: self.processId = process_id + self.clientInfo = client_info self.rootPath = root_path self.rootUri = root_uri self.initializationOptions = initialization_options @@ -850,7 +860,7 @@ def __repr__(self): class PublishDiagnosticsAbstract: - def __init(self, related_information: bool): + def __init__(self, related_information: bool): self.relatedInformation = related_information @@ -899,7 +909,7 @@ def __init__(self, registrations: List[Registration]): class RenameAbstract: - def __init(self, dynamic_registration: bool, prepare_support: bool): + def __init__(self, dynamic_registration: bool, prepare_support: bool): self.dynamicRegistration = dynamic_registration self.prepareSupport = prepare_support @@ -1207,15 +1217,20 @@ def __init__(self, uri: str): self.uri = uri -class TextDocumentItem: +class VersionedTextDocumentIdentifier(TextDocumentIdentifier): + def __init__(self, uri: str, version: NumType): + super().__init__(uri) + self.version = version + + +class TextDocumentItem(VersionedTextDocumentIdentifier): def __init__(self, uri: str, language_id: str, version: NumType, text: str): - self.uri = uri + super().__init__(uri, version) self.languageId = language_id - self.version = version self.text = text @@ -1236,6 +1251,15 @@ def __init__(self, self.context = context +class HoverParams(TextDocumentPositionParams): + def __init__(self, + textDocument: 'TextDocumentIdentifier', + position: 'Position', + workDoneToken: Optional[str] = None): + super().__init__(textDocument, position) + self.workDoneToken = workDoneToken + + class ReferenceParams(TextDocumentPositionParams): def __init__(self, text_document: 'TextDocumentIdentifier', @@ -1286,9 +1310,9 @@ def __init__(self, class SignatureHelpRegistrationOptions(TextDocumentRegistrationOptions): - def __init(self, - document_selector: DocumentSelectorType = None, - trigger_characters: List[str] = None): + def __init__(self, + document_selector: DocumentSelectorType = None, + trigger_characters: List[str] = None): super().__init__(document_selector) self.triggerCharacters = trigger_characters @@ -1344,12 +1368,6 @@ def __init__(self, unregisterations: List[Unregistration]): self.unregisterations = unregisterations -class VersionedTextDocumentIdentifier(TextDocumentIdentifier): - def __init__(self, uri: str, version: NumType): - super().__init__(uri) - self.version = version - - class WillSaveTextDocumentParams: def __init__(self, text_document: TextDocumentIdentifier, reason: int): self.textDocument = text_document From eacc5587aa2e030a5a3600759ed31db8a68e7313 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 17 May 2020 17:46:48 +0200 Subject: [PATCH 2/6] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bae5965a..18386608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,15 @@ and this project adheres to [Semantic Versioning][semver]. ### Added - Functions to convert positions from and to utf-16 code units ([#117]) +- Type definitions for `ClientInfo` and `HoverParams` ([#125]) ### Changed - Exit server normally when `ctrl+c` is pressed in command shell. - Optimize json-rpc message serialization ([#120]) +- Fixes `__init__()` constructors in several interface types ([#125]) +[#125]: https://github.com/openlawlibrary/pygls/pull/125 [#120]: https://github.com/openlawlibrary/pygls/pull/120 [#117]: https://github.com/openlawlibrary/pygls/pull/117 From aa83c02992838eae40a8d5fdcc5e7ebc53d81f66 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 17 May 2020 17:58:04 +0200 Subject: [PATCH 3/6] Fix optional client_info --- pygls/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygls/types.py b/pygls/types.py index ee238938..6a00571f 100644 --- a/pygls/types.py +++ b/pygls/types.py @@ -681,7 +681,7 @@ class Trace(str, enum.Enum): class ClientInfo: - def __init__(self, name: str = 'unknown', version: str = None): + def __init__(self, name: str = 'unknown', version: Optional[str] = None): self.name = name self.version = version @@ -689,8 +689,8 @@ def __init__(self, name: str = 'unknown', version: str = None): class InitializeParams: def __init__(self, process_id: int, - client_info: ClientInfo, capabilities: ClientCapabilities, + client_info: Optional[ClientInfo] = None, root_uri: str = None, root_path: Optional[str] = None, initialization_options: Optional[Any] = None, From 4202e0c503796023245cd31cdd5b3015c4fae026 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 17 May 2020 18:04:14 +0200 Subject: [PATCH 4/6] Fix SymbolKindAbstract Fixes #122 --- CHANGELOG.md | 3 ++- pygls/types.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18386608..8ce99783 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,8 @@ and this project adheres to [Semantic Versioning][semver]. - Exit server normally when `ctrl+c` is pressed in command shell. - Optimize json-rpc message serialization ([#120]) -- Fixes `__init__()` constructors in several interface types ([#125]) +- Fix `__init__()` constructors in several interface types ([#125]) +- Fix valueSet type in `SymbolKindAbstract` ([#125]) [#125]: https://github.com/openlawlibrary/pygls/pull/125 [#120]: https://github.com/openlawlibrary/pygls/pull/120 diff --git a/pygls/types.py b/pygls/types.py index 6a00571f..56823ed4 100644 --- a/pygls/types.py +++ b/pygls/types.py @@ -1139,7 +1139,7 @@ class SymbolKind(enum.IntEnum): class SymbolKindAbstract: - def __init__(self, value_set: SymbolKind): + def __init__(self, value_set: List[SymbolKind]): self.valueSet = value_set From a2e5a649462fc1ef458acde6471097f922911a49 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 18 May 2020 18:12:04 +0200 Subject: [PATCH 5/6] Convert HoverParams arguments to snake case --- pygls/types.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygls/types.py b/pygls/types.py index 56823ed4..544eff7c 100644 --- a/pygls/types.py +++ b/pygls/types.py @@ -1253,11 +1253,11 @@ def __init__(self, class HoverParams(TextDocumentPositionParams): def __init__(self, - textDocument: 'TextDocumentIdentifier', + text_document: 'TextDocumentIdentifier', position: 'Position', - workDoneToken: Optional[str] = None): - super().__init__(textDocument, position) - self.workDoneToken = workDoneToken + work_done_token: Optional[str] = None): + super().__init__(text_document, position) + self.workDoneToken = work_done_token class ReferenceParams(TextDocumentPositionParams): From a332f81bbe588644d2904125663bbff9cbff27b8 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 20 May 2020 18:40:59 +0200 Subject: [PATCH 6/6] Remove workDoneToken from HoverParams --- pygls/types.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygls/types.py b/pygls/types.py index 544eff7c..cda54d77 100644 --- a/pygls/types.py +++ b/pygls/types.py @@ -1254,10 +1254,8 @@ def __init__(self, class HoverParams(TextDocumentPositionParams): def __init__(self, text_document: 'TextDocumentIdentifier', - position: 'Position', - work_done_token: Optional[str] = None): + position: 'Position'): super().__init__(text_document, position) - self.workDoneToken = work_done_token class ReferenceParams(TextDocumentPositionParams):