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
|
return call, index
|
||||||
|
|
||||||
def check_cache():
|
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:
|
if self.source_path is None:
|
||||||
return None, 0
|
return None, 0
|
||||||
|
|
||||||
@@ -352,11 +356,13 @@ class Script(object):
|
|||||||
debug.speed('func_call parsed')
|
debug.speed('func_call parsed')
|
||||||
|
|
||||||
if call is None:
|
if call is None:
|
||||||
|
# This is a backup, if the above is not successful.
|
||||||
user_stmt = self.parser.user_stmt
|
user_stmt = self.parser.user_stmt
|
||||||
call, index = check_user_stmt(user_stmt)
|
call, index = check_user_stmt(user_stmt)
|
||||||
if call is None:
|
if call is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
debug.speed('func_call user_stmt')
|
||||||
with helpers.scale_speed_settings(settings.scale_get_in_function_call):
|
with helpers.scale_speed_settings(settings.scale_get_in_function_call):
|
||||||
origins = evaluate.follow_call(call)
|
origins = evaluate.follow_call(call)
|
||||||
debug.speed('func_call followed')
|
debug.speed('func_call followed')
|
||||||
|
|||||||
@@ -232,17 +232,22 @@ class Scope(Simple):
|
|||||||
|
|
||||||
@Python3Method
|
@Python3Method
|
||||||
def get_statement_for_position(self, pos):
|
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):
|
if isinstance(s, Flow):
|
||||||
p = s.get_statement_for_position(pos)
|
p = s.get_statement_for_position(pos)
|
||||||
if s.next and not p:
|
while s.next and not p:
|
||||||
p = s.next.get_statement_for_position(pos)
|
s = s.next
|
||||||
|
p = s.get_statement_for_position(pos)
|
||||||
if p:
|
if p:
|
||||||
return p
|
return p
|
||||||
elif s.start_pos <= pos < s.end_pos:
|
elif s.start_pos <= pos < s.end_pos:
|
||||||
return s
|
return s
|
||||||
|
|
||||||
for s in self.subscopes:
|
for s in self.subscopes:
|
||||||
|
if s.start_pos <= pos <= s.end_pos:
|
||||||
p = s.get_statement_for_position(pos)
|
p = s.get_statement_for_position(pos)
|
||||||
if p:
|
if p:
|
||||||
return p
|
return p
|
||||||
@@ -1621,6 +1626,13 @@ class PyFuzzyParser(object):
|
|||||||
self.gen = PushBackIterator(tokenize.generate_tokens(
|
self.gen = PushBackIterator(tokenize.generate_tokens(
|
||||||
self.buf.readline))
|
self.buf.readline))
|
||||||
return self.next()
|
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, \
|
type, tok, self._tokenize_start_pos, self._tokenize_end_pos, \
|
||||||
self.parserline = self._current_full
|
self.parserline = self._current_full
|
||||||
|
|||||||
Reference in New Issue
Block a user