Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type definitions #125

Merged
merged 6 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ 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])
- 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
[#117]: https://github.com/openlawlibrary/pygls/pull/117

Expand Down
64 changes: 40 additions & 24 deletions pygls/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -678,16 +680,24 @@ class Trace(str, enum.Enum):
Verbose = 'verbose'


class ClientInfo:
def __init__(self, name: str = 'unknown', version: Optional[str] = None):
self.name = name
self.version = version


class InitializeParams:
def __init__(self,
process_id: int,
capabilities: ClientCapabilities,
client_info: Optional[ClientInfo] = None,
root_uri: str = None,
root_path: Optional[str] = None,
initialization_options: Optional[Any] = None,
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
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -1129,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


Expand Down Expand Up @@ -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


Expand All @@ -1236,6 +1251,13 @@ def __init__(self,
self.context = context


class HoverParams(TextDocumentPositionParams):
def __init__(self,
text_document: 'TextDocumentIdentifier',
position: 'Position'):
super().__init__(text_document, position)


class ReferenceParams(TextDocumentPositionParams):
def __init__(self,
text_document: 'TextDocumentIdentifier',
Expand Down Expand Up @@ -1286,9 +1308,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

Expand Down Expand Up @@ -1344,12 +1366,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
Expand Down