diff --git a/jedi/common.py b/jedi/common.py index 89eec32e..b12a5256 100644 --- a/jedi/common.py +++ b/jedi/common.py @@ -85,7 +85,7 @@ class NoErrorTokenizer(object): if self.closed: raise MultiLevelStopIteration() try: - last_previous = self.previous + self.last_previous = self.previous self.previous = self.current self.current = next(self.gen) except tokenize.TokenError: @@ -112,7 +112,7 @@ class NoErrorTokenizer(object): if c[0] == tokenize.ENDMARKER: self.current = self.previous - self.previous = last_previous + self.previous = self.last_previous raise MultiLevelStopIteration() # this is exactly the same check as in fast_parser, but this time with @@ -155,6 +155,9 @@ class NoErrorTokenizer(object): 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: diff --git a/jedi/evaluate.py b/jedi/evaluate.py index 8d68b050..a7516992 100644 --- a/jedi/evaluate.py +++ b/jedi/evaluate.py @@ -373,6 +373,7 @@ 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): diff --git a/jedi/fast_parser.py b/jedi/fast_parser.py index 61030737..cd5bada8 100644 --- a/jedi/fast_parser.py +++ b/jedi/fast_parser.py @@ -317,7 +317,7 @@ class FastParser(use_metaclass(CachedFastParser)): is_first = True for code_part in parts: lines = code_part.count('\n') + 1 - if is_first or self._line_offset >= p.end_pos[0] - 1: + if is_first or self._line_offset >= p.end_pos[0]: indent = len(re.match(r'[ \t]*', code_part).group(0)) if is_first and self.current_node is not None: nodes = [self.current_node] @@ -330,6 +330,7 @@ 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 p, node = self._get_parser(code_part, nodes) if is_first: @@ -347,11 +348,13 @@ class FastParser(use_metaclass(CachedFastParser)): self.parsers.append(p) is_first = False + else: + print '#'*45, self._line_offset, p.end_pos, 'theheck\n', code_part 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) diff --git a/jedi/parsing.py b/jedi/parsing.py index 0ce923be..f01de43d 100644 --- a/jedi/parsing.py +++ b/jedi/parsing.py @@ -80,6 +80,8 @@ class Parser(object): if self.current[0] in (tokenize.NL, tokenize.NEWLINE): # we added a newline before, so we need to "remove" it again. self.end_pos = self._gen.previous[2] + if self.current[0] == tokenize.INDENT: + self.end_pos = self._gen.last_previous[2] self.start_pos = self.module.start_pos self.module.end_pos = self.end_pos diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index 3a7ff64a..df63df80 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -454,7 +454,7 @@ class Function(Scope): string += "def %s(%s):\n" % (self.name, params) string += super(Function, self).get_code(True, indention) if self.is_empty(): - string += "pass\n" + string += indention + 'pass\n' return string def is_empty(self):