forked from VimPlug/jedi
optimize call_def stuff with multiple flows, may help #20
This commit is contained in:
@@ -318,6 +318,10 @@ class Script(object):
|
||||
return call, index
|
||||
|
||||
def check_cache():
|
||||
""" Do the parsing with a part parser, therefore reduce ressource
|
||||
costs.
|
||||
TODO this is not working with multi-line docstrings, improve.
|
||||
"""
|
||||
if self.source_path is None:
|
||||
return None, 0
|
||||
|
||||
@@ -352,11 +356,13 @@ class Script(object):
|
||||
debug.speed('func_call parsed')
|
||||
|
||||
if call is None:
|
||||
# This is a backup, if the above is not successful.
|
||||
user_stmt = self.parser.user_stmt
|
||||
call, index = check_user_stmt(user_stmt)
|
||||
if call is None:
|
||||
return None
|
||||
|
||||
debug.speed('func_call user_stmt')
|
||||
with helpers.scale_speed_settings(settings.scale_get_in_function_call):
|
||||
origins = evaluate.follow_call(call)
|
||||
debug.speed('func_call followed')
|
||||
|
||||
@@ -232,20 +232,25 @@ class Scope(Simple):
|
||||
|
||||
@Python3Method
|
||||
def get_statement_for_position(self, pos):
|
||||
for s in self.statements:
|
||||
checks = self.statements + self.asserts
|
||||
if self.isinstance(Function):
|
||||
checks += self.params + self.decorators + self.returns
|
||||
for s in checks:
|
||||
if isinstance(s, Flow):
|
||||
p = s.get_statement_for_position(pos)
|
||||
if s.next and not p:
|
||||
p = s.next.get_statement_for_position(pos)
|
||||
while s.next and not p:
|
||||
s = s.next
|
||||
p = s.get_statement_for_position(pos)
|
||||
if p:
|
||||
return p
|
||||
elif s.start_pos <= pos < s.end_pos:
|
||||
return s
|
||||
|
||||
for s in self.subscopes:
|
||||
p = s.get_statement_for_position(pos)
|
||||
if p:
|
||||
return p
|
||||
if s.start_pos <= pos <= s.end_pos:
|
||||
p = s.get_statement_for_position(pos)
|
||||
if p:
|
||||
return p
|
||||
|
||||
def __repr__(self):
|
||||
try:
|
||||
@@ -1621,6 +1626,13 @@ class PyFuzzyParser(object):
|
||||
self.gen = PushBackIterator(tokenize.generate_tokens(
|
||||
self.buf.readline))
|
||||
return self.next()
|
||||
except StopIteration:
|
||||
# set end_pos correctly, if we finish
|
||||
s = self.scope
|
||||
while s is not None:
|
||||
s.end_pos = self.end_pos
|
||||
s = s.parent()
|
||||
raise
|
||||
|
||||
type, tok, self._tokenize_start_pos, self._tokenize_end_pos, \
|
||||
self.parserline = self._current_full
|
||||
|
||||
Reference in New Issue
Block a user