Skip to content

Commit

Permalink
Merge pull request #17 from smathot/minor_fixes
Browse files Browse the repository at this point in the history
Two minor fixes
  • Loading branch information
yeger00 authored Jan 4, 2021
2 parents 6bed7ef + d2572c9 commit fc6e645
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 19 deletions.
6 changes: 4 additions & 2 deletions pylspclient/lsp_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@


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)
self.json_rpc_endpoint = json_rpc_endpoint
self.notify_callbacks = notify_callbacks
self.method_callbacks = method_callbacks
self.event_dict = {}
self.response_dict = {}
self.next_id = 0
self._timeout = timeout
self.shutdown_flag = False


Expand Down Expand Up @@ -93,7 +94,8 @@ def call_method(self, method_name, **kwargs):
if self.shutdown_flag:
return None

cond.wait()
if not cond.wait(timeout=self._timeout):
raise TimeoutError()
cond.release()

self.event_dict.pop(current_id)
Expand Down
62 changes: 45 additions & 17 deletions pylspclient/lsp_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def __init__(self, uri, version):
open notification before) the server can send `null` to indicate
that the version is known and the content on disk is the truth (as
speced with document content ownership).
The version number of a document will increase after each change, including
undo/redo. The number doesn't need to be consecutive.
The version number of a document will increase after each change, including
undo/redo. The number doesn't need to be consecutive.
"""
super(VersionedTextDocumentIdentifier, self).__init__(uri)
self.version = version
Expand Down Expand Up @@ -301,7 +301,7 @@ class SymbolInformation(object):
"""
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.
Expand Down Expand Up @@ -481,6 +481,34 @@ def __init__(self, label, kind=None, detail=None, documentation=None, deprecated
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):
"""
Represents a collection of [completion items](#CompletionItem) to be presented in the editor.
Expand All @@ -496,20 +524,20 @@ def __init__(self, isIncomplete, items):
self.items = [to_type(i, CompletionItem) for i in items]

class ErrorCodes(enum.Enum):
# Defined by JSON RPC
ParseError = -32700
InvalidRequest = -32600
MethodNotFound = -32601
InvalidParams = -32602
InternalError = -32603
serverErrorStart = -32099
serverErrorEnd = -32000
ServerNotInitialized = -32002
UnknownErrorCode = -32001

# Defined by the protocol.
RequestCancelled = -32800
ContentModified = -32801
# Defined by JSON RPC
ParseError = -32700
InvalidRequest = -32600
MethodNotFound = -32601
InvalidParams = -32602
InternalError = -32603
serverErrorStart = -32099
serverErrorEnd = -32000
ServerNotInitialized = -32002
UnknownErrorCode = -32001

# Defined by the protocol.
RequestCancelled = -32800
ContentModified = -32801

class ResponseError(Exception):
def __init__(self, code, message, data = None):
Expand Down

0 comments on commit fc6e645

Please sign in to comment.