forked from VimPlug/jedi
fixed parser change problems
This commit is contained in:
@@ -150,14 +150,12 @@ class NoErrorTokenizer(object):
|
||||
self.in_flow = False
|
||||
elif self.new_indent:
|
||||
self.parser_indent = indent
|
||||
self.new_indent = False
|
||||
|
||||
if not self.in_flow:
|
||||
if tok in FLOWS or tok in breaks:
|
||||
self.in_flow = tok in FLOWS
|
||||
if not self.is_decorator and not self.in_flow:
|
||||
print tok, c
|
||||
if 6230 < c[2][0] < 6290:
|
||||
print tok, c
|
||||
close()
|
||||
self.is_decorator = '@' == tok
|
||||
if not self.is_decorator:
|
||||
@@ -165,6 +163,8 @@ class NoErrorTokenizer(object):
|
||||
self.new_indent = True
|
||||
|
||||
if tok != '@':
|
||||
if self.first_stmt and not self.new_indent:
|
||||
self.parser_indent = indent
|
||||
self.first_stmt = False
|
||||
return c
|
||||
|
||||
|
||||
@@ -373,7 +373,6 @@ def find_name(scope, name_str, position=None, search_global=False,
|
||||
comparison_func = lambda name: (name.start_pos)
|
||||
|
||||
for nscope, name_list in scope_generator:
|
||||
print nscope, name_list
|
||||
break_scopes = []
|
||||
# here is the position stuff happening (sorting of variables)
|
||||
for name in sorted(name_list, key=comparison_func, reverse=True):
|
||||
|
||||
@@ -112,21 +112,23 @@ class CachedFastParser(type):
|
||||
class ParserNode(object):
|
||||
def __init__(self, parser, code, parent=None):
|
||||
self.parent = parent
|
||||
self.parser = parser
|
||||
self.code = code
|
||||
self.hash = hash(code)
|
||||
|
||||
self.children = []
|
||||
self._old_children = []
|
||||
# must be created before new things are added to it.
|
||||
self.save_contents(parser)
|
||||
|
||||
def save_contents(self, parser):
|
||||
self.parser = parser
|
||||
|
||||
try:
|
||||
# with fast_parser we have either 1 subscope or only statements.
|
||||
self._content_scope = self.parser.module.subscopes[0]
|
||||
except IndexError:
|
||||
self._content_scope = self.parser.module
|
||||
self.save_contents()
|
||||
|
||||
def save_contents(self):
|
||||
scope = self._content_scope
|
||||
self._contents = {}
|
||||
for c in SCOPE_CONTENTS:
|
||||
@@ -159,7 +161,10 @@ class ParserNode(object):
|
||||
try:
|
||||
el = module.statements[0]
|
||||
except IndexError:
|
||||
el = module.imports[0]
|
||||
try:
|
||||
el = module.imports[0]
|
||||
except IndexError:
|
||||
el = module.returns[0]
|
||||
return el.start_pos[1]
|
||||
|
||||
def _set_items(self, parser, set_parent=False):
|
||||
@@ -172,6 +177,9 @@ class ParserNode(object):
|
||||
for i in items:
|
||||
i.parent = scope
|
||||
content += items
|
||||
if str(parser.module.name) == 'ordering':
|
||||
#print scope.subscopes
|
||||
pass
|
||||
scope.is_generator |= parser.module.is_generator
|
||||
|
||||
def add_node(self, node):
|
||||
@@ -330,15 +338,14 @@ class FastParser(use_metaclass(CachedFastParser)):
|
||||
nodes += self.current_node._old_children
|
||||
|
||||
# check if code_part has already been parsed
|
||||
print '#'*45,self._line_offset, p and p.end_pos, '\n', code_part
|
||||
#print '#'*45,self._line_offset, p and p.end_pos, '\n', code_part
|
||||
p, node = self._get_parser(code_part, nodes)
|
||||
|
||||
if is_first:
|
||||
if self.current_node is None:
|
||||
self.current_node = ParserNode(p, code)
|
||||
else:
|
||||
self.current_node.parser = p
|
||||
self.current_node.save_contents()
|
||||
self.current_node.save_contents(p)
|
||||
else:
|
||||
if node is None:
|
||||
self.current_node = \
|
||||
@@ -349,12 +356,13 @@ class FastParser(use_metaclass(CachedFastParser)):
|
||||
|
||||
is_first = False
|
||||
else:
|
||||
print '#'*45, self._line_offset, p.end_pos, 'theheck\n', code_part
|
||||
#print '#'*45, self._line_offset, p.end_pos, 'theheck\n', code_part
|
||||
pass
|
||||
|
||||
self._line_offset += lines
|
||||
self._start += len(code_part) + 1 # +1 for newline
|
||||
|
||||
print(self.parsers[0].module.get_code())
|
||||
#print(self.parsers[0].module.get_code())
|
||||
#for p in self.parsers:
|
||||
# print(p.module.get_code())
|
||||
# print(p.module.start_pos, p.module.end_pos)
|
||||
|
||||
Reference in New Issue
Block a user