11import collections
22
33from . import json_helpers
4+ from .global_vars import IS_ST2
45from .node_client import CommClient
56from .text_helpers import Location
67
@@ -45,32 +46,32 @@ def completions(self, path, location=Location(1, 1), prefix="", on_completed=Non
4546 req_dict = self .create_req_dict ("completions" , args )
4647 json_str = json_helpers .encode (req_dict )
4748 self .__comm .sendCmd (
48- lambda json_dict : None if on_completed is None else on_completed (json_dict ),
4949 json_str ,
50+ lambda response_dict : None if on_completed is None else on_completed (response_dict ),
5051 req_dict ["seq" ]
5152 )
5253
5354 def async_completions (self , path , location = Location (1 , 1 ), prefix = "" , on_completed = None ):
5455 args = {"file" : path , "line" : location .line , "offset" : location .offset , "prefix" : prefix }
5556 req_dict = self .create_req_dict ("completions" , args )
5657 json_str = json_helpers .encode (req_dict )
57- self .__comm .sendCmdAsync (json_str , req_dict ["seq" ], on_completed )
58+ self .__comm .sendCmdAsync (json_str , on_completed , req_dict ["seq" ])
5859
5960 def signature_help (self , path , location = Location (1 , 1 ), prefix = "" , on_completed = None ):
6061 args = {"file" : path , "line" : location .line , "offset" : location .offset , "prefix" : prefix }
6162 req_dict = self .create_req_dict ("signatureHelp" , args )
6263 json_str = json_helpers .encode (req_dict )
6364 self .__comm .sendCmd (
64- lambda response_dict : None if on_completed is None else on_completed (response_dict ),
6565 json_str ,
66+ lambda response_dict : None if on_completed is None else on_completed (response_dict ),
6667 req_dict ["seq" ]
6768 )
6869
6970 def async_signature_help (self , path , location = Location (1 , 1 ), prefix = "" , on_completed = None ):
7071 args = {"file" : path , "line" : location .line , "offset" : location .offset , "prefix" : prefix }
7172 req_dict = self .create_req_dict ("signatureHelp" , args )
7273 json_str = json_helpers .encode (req_dict )
73- self .__comm .sendCmdAsync (json_str , req_dict ["seq" ], on_completed )
74+ self .__comm .sendCmdAsync (json_str , on_completed , req_dict ["seq" ])
7475
7576 def definition (self , path , location = Location (1 , 1 )):
7677 args = {"file" : path , "line" : location .line , "offset" : location .offset }
@@ -129,7 +130,7 @@ def reload_async(self, path, alternate_path, on_completed):
129130 args = {"file" : path , "tmpfile" : alternate_path }
130131 req_dict = self .create_req_dict ("reload" , args )
131132 json_str = json_helpers .encode (req_dict )
132- self .__comm .sendCmdAsync (json_str , req_dict ["seq" ], on_completed )
133+ self .__comm .sendCmdAsync (json_str , on_completed , req_dict ["seq" ])
133134
134135 def rename (self , path , location = Location (1 , 1 )):
135136 args = {"file" : path , "line" : location .line , "offset" : location .offset }
@@ -151,15 +152,23 @@ def type(self, path, location=Location(1, 1)):
151152 response_dict = self .__comm .sendCmdSync (json_str , req_dict ["seq" ])
152153 return response_dict
153154
154- def quick_info (self , path , location = Location (1 , 1 ), onCompleted = None ):
155+ def quick_info (self , path , location = Location (1 , 1 ), on_completed = None ):
155156 args = {"file" : path , "line" : location .line , "offset" : location .offset }
156157 req_dict = self .create_req_dict ("quickinfo" , args )
157158 json_str = json_helpers .encode (req_dict )
158- self .__comm .sendCmd (
159- lambda json_dict : None if onCompleted is None else onCompleted (json_dict ),
160- json_str ,
161- req_dict ["seq" ]
162- )
159+ callback = on_completed or (lambda : None )
160+ if not IS_ST2 :
161+ self .__comm .sendCmdAsync (
162+ json_str ,
163+ callback ,
164+ req_dict ["seq" ]
165+ )
166+ else :
167+ self .__comm .sendCmd (
168+ json_str ,
169+ callback ,
170+ req_dict ["seq" ]
171+ )
163172
164173 def get_event (self ):
165174 event_json_str = self .__comm .getEvent ()
0 commit comments