forked from VimPlug/jedi
Fixes for the fast parser in nodes_to_execute.
This commit is contained in:
@@ -263,6 +263,10 @@ class Whitespace(LeafWithNewLines):
|
|||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
type = 'whitespace'
|
type = 'whitespace'
|
||||||
|
|
||||||
|
@utf8_repr
|
||||||
|
def __repr__(self):
|
||||||
|
return "<%s: %s>" % (type(self).__name__, repr(self.value))
|
||||||
|
|
||||||
|
|
||||||
class Name(Leaf):
|
class Name(Leaf):
|
||||||
"""
|
"""
|
||||||
@@ -765,7 +769,11 @@ class Class(ClassOrFunc):
|
|||||||
yield argument
|
yield argument
|
||||||
|
|
||||||
# care for the class suite:
|
# care for the class suite:
|
||||||
for node_to_execute in self.children[-1].nodes_to_execute():
|
for node in self.children[self.children.index(':'):]:
|
||||||
|
# This could be easier without the fast parser. But we need to find
|
||||||
|
# the position of the colon, because everything after it can be a
|
||||||
|
# part of the class, not just its suite.
|
||||||
|
for node_to_execute in node.nodes_to_execute():
|
||||||
yield node_to_execute
|
yield node_to_execute
|
||||||
|
|
||||||
|
|
||||||
@@ -877,7 +885,12 @@ class Function(ClassOrFunc):
|
|||||||
if param.default is not None:
|
if param.default is not None:
|
||||||
yield param.default
|
yield param.default
|
||||||
# care for the function suite:
|
# care for the function suite:
|
||||||
for node_to_execute in self.children[-1].nodes_to_execute():
|
for node in self.children[4:]:
|
||||||
|
# This could be easier without the fast parser. The fast parser
|
||||||
|
# allows that the 4th position is empty or that there's even a
|
||||||
|
# fifth element (another function/class). So just scan everything
|
||||||
|
# after colon.
|
||||||
|
for node_to_execute in node.nodes_to_execute():
|
||||||
yield node_to_execute
|
yield node_to_execute
|
||||||
|
|
||||||
|
|
||||||
@@ -1201,7 +1214,7 @@ class KeywordStatement(BaseNode):
|
|||||||
def nodes_to_execute(self, last_added=False):
|
def nodes_to_execute(self, last_added=False):
|
||||||
result = []
|
result = []
|
||||||
for child in self.children:
|
for child in self.children:
|
||||||
result += child.nodes_to_execute(last_added)
|
result += child.nodes_to_execute()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -1290,7 +1303,7 @@ class ExprStmt(BaseNode, DocstringMixin):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def nodes_to_execute(self, last_added=False):
|
def nodes_to_execute(self, last_added=False):
|
||||||
# I think evaluating the statment (and possibly returned arrays),
|
# I think evaluating the statement (and possibly returned arrays),
|
||||||
# should be enough for static analysis.
|
# should be enough for static analysis.
|
||||||
result = [self]
|
result = [self]
|
||||||
for child in self.children:
|
for child in self.children:
|
||||||
@@ -1377,3 +1390,6 @@ class CompFor(BaseNode):
|
|||||||
|
|
||||||
def get_defined_names(self):
|
def get_defined_names(self):
|
||||||
return _defined_names(self.children[1])
|
return _defined_names(self.children[1])
|
||||||
|
|
||||||
|
def nodes_to_execute(self, last_added=False):
|
||||||
|
return self.children[-1].nodes_to_execute()
|
||||||
|
|||||||
Reference in New Issue
Block a user