forked from VimPlug/jedi
Move is_scope and get_parent_scope out of the parser.
This commit is contained in:
@@ -59,19 +59,6 @@ class DocstringMixin(object):
|
||||
|
||||
|
||||
class PythonMixin(object):
|
||||
def get_parent_scope(self, include_flows=False):
|
||||
"""
|
||||
Returns the underlying scope.
|
||||
"""
|
||||
scope = self.parent
|
||||
while scope is not None:
|
||||
if include_flows and isinstance(scope, Flow):
|
||||
return scope
|
||||
if scope.is_scope():
|
||||
break
|
||||
scope = scope.parent
|
||||
return scope
|
||||
|
||||
def get_definition(self):
|
||||
if self.type in ('newline', 'endmarker'):
|
||||
raise ValueError('Cannot get the indentation of whitespace or indentation.')
|
||||
@@ -90,10 +77,6 @@ class PythonMixin(object):
|
||||
break
|
||||
return scope
|
||||
|
||||
def is_scope(self):
|
||||
# Default is not being a scope. Just inherit from Scope.
|
||||
return False
|
||||
|
||||
def get_name_of_position(self, position):
|
||||
for c in self.children:
|
||||
if isinstance(c, Leaf):
|
||||
@@ -267,9 +250,6 @@ class Scope(PythonBaseNode, DocstringMixin):
|
||||
|
||||
return scan(self.children)
|
||||
|
||||
def is_scope(self):
|
||||
return True
|
||||
|
||||
def get_suite(self):
|
||||
"""
|
||||
Returns the part that is executed by the function.
|
||||
@@ -1057,9 +1037,6 @@ class CompFor(PythonBaseNode):
|
||||
type = 'comp_for'
|
||||
__slots__ = ()
|
||||
|
||||
def is_scope(self):
|
||||
return True
|
||||
|
||||
def get_defined_names(self):
|
||||
"""
|
||||
Returns the a list of `Name` that the comprehension defines.
|
||||
|
||||
Reference in New Issue
Block a user