forked from VimPlug/jedi
call signatures with whitespace seem to be working
This commit is contained in:
@@ -488,7 +488,7 @@ class Script(object):
|
|||||||
if call is None:
|
if call is None:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
user_stmt = self._parser.user_stmt()
|
user_stmt = self._parser.user_stmt(True)
|
||||||
with common.scale_speed_settings(settings.scale_call_signatures):
|
with common.scale_speed_settings(settings.scale_call_signatures):
|
||||||
_callable = lambda: self._evaluator.eval_call(call)
|
_callable = lambda: self._evaluator.eval_call(call)
|
||||||
origins = cache.cache_call_signatures(_callable, user_stmt)
|
origins = cache.cache_call_signatures(_callable, user_stmt)
|
||||||
@@ -502,7 +502,7 @@ class Script(object):
|
|||||||
debug.speed('func_call start')
|
debug.speed('func_call start')
|
||||||
call, index = None, 0
|
call, index = None, 0
|
||||||
if call is None:
|
if call is None:
|
||||||
user_stmt = self._parser.user_stmt()
|
user_stmt = self._parser.user_stmt(True)
|
||||||
if user_stmt is not None and isinstance(user_stmt, pr.Statement):
|
if user_stmt is not None and isinstance(user_stmt, pr.Statement):
|
||||||
call, index, _ = helpers.search_call_signatures(user_stmt, self._pos)
|
call, index, _ = helpers.search_call_signatures(user_stmt, self._pos)
|
||||||
debug.speed('func_call parsed')
|
debug.speed('func_call parsed')
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ class UserContext(object):
|
|||||||
+ (after.group(0) if after is not None else '')
|
+ (after.group(0) if after is not None else '')
|
||||||
|
|
||||||
def get_context(self, yield_positions=False):
|
def get_context(self, yield_positions=False):
|
||||||
|
self.get_path_until_cursor() # In case _start_cursor_pos is undefined.
|
||||||
pos = self._start_cursor_pos
|
pos = self._start_cursor_pos
|
||||||
while True:
|
while True:
|
||||||
# remove non important white space
|
# remove non important white space
|
||||||
@@ -200,18 +201,16 @@ class UserContextParser(object):
|
|||||||
return self.module().get_statement_for_position(self._position,
|
return self.module().get_statement_for_position(self._position,
|
||||||
include_imports=True)
|
include_imports=True)
|
||||||
|
|
||||||
def user_stmt(self, is_completion=False):
|
def user_stmt(self, check_whitespace=False):
|
||||||
user_stmt = self._get_user_stmt()
|
user_stmt = self._get_user_stmt()
|
||||||
|
|
||||||
debug.speed('parsed')
|
debug.speed('parsed')
|
||||||
|
|
||||||
if is_completion and not user_stmt:
|
if check_whitespace and not user_stmt:
|
||||||
# for statements like `from x import ` (cursor not in statement)
|
# for statements like `from x import ` (cursor not in statement)
|
||||||
|
# or `abs( ` where the cursor is out in the whitespace.
|
||||||
pos = next(self._user_context.get_context(yield_positions=True))
|
pos = next(self._user_context.get_context(yield_positions=True))
|
||||||
last_stmt = pos and \
|
user_stmt = self.module().get_statement_for_position(pos, include_imports=True)
|
||||||
self.module().get_statement_for_position(pos, include_imports=True)
|
|
||||||
if isinstance(last_stmt, representation.Import):
|
|
||||||
user_stmt = last_stmt
|
|
||||||
return user_stmt
|
return user_stmt
|
||||||
|
|
||||||
@cache.underscore_memoization
|
@cache.underscore_memoization
|
||||||
|
|||||||
Reference in New Issue
Block a user