forked from VimPlug/jedi
Move search_ancestor to jedi.parser.tree.
This commit is contained in:
@@ -58,7 +58,8 @@ def parse(code=None, path=None, grammar=None, error_recovery=True,
|
||||
|
||||
:param code: A unicode string that contains Python code.
|
||||
:param path: The path to the file you want to open. Only needed for caching.
|
||||
:param grammar: A Python grammar file, created with load_grammar.
|
||||
:param grammar: A Python grammar file, created with load_grammar. You may
|
||||
not specify it. In that case it's the current Python version.
|
||||
:param error_recovery: If enabled, any code will be returned. If it is
|
||||
invalid, it will be returned as an error node. If disabled, you will
|
||||
get a ParseError when encountering syntax errors in your code.
|
||||
|
||||
@@ -30,17 +30,8 @@ See also :attr:`Scope.subscopes` and :attr:`Scope.statements`.
|
||||
from itertools import chain
|
||||
|
||||
from jedi._compatibility import utf8_repr, unicode
|
||||
from jedi.parser.tree import Node, BaseNode, Leaf, ErrorNode, ErrorLeaf
|
||||
|
||||
|
||||
def search_ancestor(node, node_type_or_types):
|
||||
if not isinstance(node_type_or_types, (list, tuple)):
|
||||
node_type_or_types = (node_type_or_types,)
|
||||
|
||||
while True:
|
||||
node = node.parent
|
||||
if node is None or node.type in node_type_or_types:
|
||||
return node
|
||||
from jedi.parser.tree import Node, BaseNode, Leaf, ErrorNode, ErrorLeaf, \
|
||||
search_ancestor
|
||||
|
||||
|
||||
class DocstringMixin(object):
|
||||
|
||||
Reference in New Issue
Block a user