1
1
import collections
2
2
3
3
from . import json_helpers
4
+ from .global_vars import IS_ST2
4
5
from .node_client import CommClient
5
6
from .text_helpers import Location
6
7
@@ -45,32 +46,32 @@ def completions(self, path, location=Location(1, 1), prefix="", on_completed=Non
45
46
req_dict = self .create_req_dict ("completions" , args )
46
47
json_str = json_helpers .encode (req_dict )
47
48
self .__comm .sendCmd (
48
- lambda json_dict : None if on_completed is None else on_completed (json_dict ),
49
49
json_str ,
50
+ lambda response_dict : None if on_completed is None else on_completed (response_dict ),
50
51
req_dict ["seq" ]
51
52
)
52
53
53
54
def async_completions (self , path , location = Location (1 , 1 ), prefix = "" , on_completed = None ):
54
55
args = {"file" : path , "line" : location .line , "offset" : location .offset , "prefix" : prefix }
55
56
req_dict = self .create_req_dict ("completions" , args )
56
57
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" ])
58
59
59
60
def signature_help (self , path , location = Location (1 , 1 ), prefix = "" , on_completed = None ):
60
61
args = {"file" : path , "line" : location .line , "offset" : location .offset , "prefix" : prefix }
61
62
req_dict = self .create_req_dict ("signatureHelp" , args )
62
63
json_str = json_helpers .encode (req_dict )
63
64
self .__comm .sendCmd (
64
- lambda response_dict : None if on_completed is None else on_completed (response_dict ),
65
65
json_str ,
66
+ lambda response_dict : None if on_completed is None else on_completed (response_dict ),
66
67
req_dict ["seq" ]
67
68
)
68
69
69
70
def async_signature_help (self , path , location = Location (1 , 1 ), prefix = "" , on_completed = None ):
70
71
args = {"file" : path , "line" : location .line , "offset" : location .offset , "prefix" : prefix }
71
72
req_dict = self .create_req_dict ("signatureHelp" , args )
72
73
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" ])
74
75
75
76
def definition (self , path , location = Location (1 , 1 )):
76
77
args = {"file" : path , "line" : location .line , "offset" : location .offset }
@@ -129,7 +130,7 @@ def reload_async(self, path, alternate_path, on_completed):
129
130
args = {"file" : path , "tmpfile" : alternate_path }
130
131
req_dict = self .create_req_dict ("reload" , args )
131
132
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" ])
133
134
134
135
def rename (self , path , location = Location (1 , 1 )):
135
136
args = {"file" : path , "line" : location .line , "offset" : location .offset }
@@ -151,15 +152,23 @@ def type(self, path, location=Location(1, 1)):
151
152
response_dict = self .__comm .sendCmdSync (json_str , req_dict ["seq" ])
152
153
return response_dict
153
154
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 ):
155
156
args = {"file" : path , "line" : location .line , "offset" : location .offset }
156
157
req_dict = self .create_req_dict ("quickinfo" , args )
157
158
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
+ )
163
172
164
173
def get_event (self ):
165
174
event_json_str = self .__comm .getEvent ()
0 commit comments