Merge pull request #17 from smathot/minor_fixes

Two minor fixes
This commit is contained in:
Yeger 2021-01-04 19:02:49 +02:00 committed by GitHub
commit fc6e645261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 18 deletions

View File

@ -5,7 +5,7 @@ from pylspclient import lsp_structs
class LspEndpoint(threading.Thread): class LspEndpoint(threading.Thread):
def __init__(self, json_rpc_endpoint, method_callbacks={}, notify_callbacks={}): def __init__(self, json_rpc_endpoint, method_callbacks={}, notify_callbacks={}, timeout=2):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.json_rpc_endpoint = json_rpc_endpoint self.json_rpc_endpoint = json_rpc_endpoint
self.notify_callbacks = notify_callbacks self.notify_callbacks = notify_callbacks
@ -13,6 +13,7 @@ class LspEndpoint(threading.Thread):
self.event_dict = {} self.event_dict = {}
self.response_dict = {} self.response_dict = {}
self.next_id = 0 self.next_id = 0
self._timeout = timeout
self.shutdown_flag = False self.shutdown_flag = False
@ -93,7 +94,8 @@ class LspEndpoint(threading.Thread):
if self.shutdown_flag: if self.shutdown_flag:
return None return None
cond.wait() if not cond.wait(timeout=self._timeout):
raise TimeoutError()
cond.release() cond.release()
self.event_dict.pop(current_id) self.event_dict.pop(current_id)

View File

@ -176,8 +176,8 @@ class VersionedTextDocumentIdentifier(TextDocumentIdentifier):
open notification before) the server can send `null` to indicate open notification before) the server can send `null` to indicate
that the version is known and the content on disk is the truth (as that the version is known and the content on disk is the truth (as
speced with document content ownership). speced with document content ownership).
The version number of a document will increase after each change, including The version number of a document will increase after each change, including
undo/redo. The number doesn't need to be consecutive. undo/redo. The number doesn't need to be consecutive.
""" """
super(VersionedTextDocumentIdentifier, self).__init__(uri) super(VersionedTextDocumentIdentifier, self).__init__(uri)
self.version = version self.version = version
@ -301,7 +301,7 @@ class SymbolInformation(object):
""" """
Represents information about programming constructs like variables, classes, interfaces etc. Represents information about programming constructs like variables, classes, interfaces etc.
""" """
def __init__(self, name, kind, location, containerName, deprecated=False): def __init__(self, name, kind, location, containerName=None, deprecated=False):
""" """
Constructs a new SymbolInformation instance. Constructs a new SymbolInformation instance.
@ -481,6 +481,34 @@ class CompletionItem(object):
self.score = score self.score = score
class CompletionItemKind(enum.Enum):
Text = 1
Method = 2
Function = 3
Constructor = 4
Field = 5
Variable = 6
Class = 7
Interface = 8
Module = 9
Property = 10
Unit = 11
Value = 12
Enum = 13
Keyword = 14
Snippet = 15
Color = 16
File = 17
Reference = 18
Folder = 19
EnumMember = 20
Constant = 21
Struct = 22
Event = 23
Operator = 24
TypeParameter = 25
class CompletionList(object): class CompletionList(object):
""" """
Represents a collection of [completion items](#CompletionItem) to be presented in the editor. Represents a collection of [completion items](#CompletionItem) to be presented in the editor.
@ -496,20 +524,20 @@ class CompletionList(object):
self.items = [to_type(i, CompletionItem) for i in items] self.items = [to_type(i, CompletionItem) for i in items]
class ErrorCodes(enum.Enum): class ErrorCodes(enum.Enum):
# Defined by JSON RPC # Defined by JSON RPC
ParseError = -32700 ParseError = -32700
InvalidRequest = -32600 InvalidRequest = -32600
MethodNotFound = -32601 MethodNotFound = -32601
InvalidParams = -32602 InvalidParams = -32602
InternalError = -32603 InternalError = -32603
serverErrorStart = -32099 serverErrorStart = -32099
serverErrorEnd = -32000 serverErrorEnd = -32000
ServerNotInitialized = -32002 ServerNotInitialized = -32002
UnknownErrorCode = -32001 UnknownErrorCode = -32001
# Defined by the protocol. # Defined by the protocol.
RequestCancelled = -32800 RequestCancelled = -32800
ContentModified = -32801 ContentModified = -32801
class ResponseError(Exception): class ResponseError(Exception):
def __init__(self, code, message, data = None): def __init__(self, code, message, data = None):