1
0
forked from VimPlug/jedi

fix problems (end_pos of positions was wrong) with user_scopes

This commit is contained in:
David Halter
2012-12-17 22:19:39 +01:00
parent 8bbd2108bd
commit 7e7006e142
2 changed files with 8 additions and 4 deletions

View File

@@ -19,6 +19,9 @@ class Module(parsing.Simple, parsing.Module):
""" This module does a whole lot of caching, because it uses different """ This module does a whole lot of caching, because it uses different
parsers. """ parsers. """
self.cache = {} self.cache = {}
for p in self.parsers:
p.user_scope = None
p.user_stmt = None
def _get(self, name, operation, execute=False, *args, **kwargs): def _get(self, name, operation, execute=False, *args, **kwargs):
key = (name, args, frozenset(kwargs.items())) key = (name, args, frozenset(kwargs.items()))
@@ -213,12 +216,12 @@ class FastParser(use_metaclass(CachedFastParser)):
h = hash(code_part) h = hash(code_part)
p = None p = None
if h in hashes: if h in hashes and hashes[h].code == code_part:
p = hashes[h] p = hashes[h]
m = p.module m = p.module
m.line_offset += line_offset + 1 - m.start_pos[0] m.line_offset += line_offset + 1 - m.start_pos[0]
if self.user_position is not None and \ if self.user_position is not None and \
m.start_pos >= self.user_position >= m.end_pos: m.start_pos <= self.user_position <= m.end_pos:
#print(h, line_offset, m.start_pos, lines) #print(h, line_offset, m.start_pos, lines)
p = None p = None
else: else:
@@ -231,6 +234,7 @@ class FastParser(use_metaclass(CachedFastParser)):
top_module=self.module) top_module=self.module)
p.hash = h p.hash = h
p.code = code_part
p.module.parent = self.module p.module.parent = self.module
self.parsers.insert(parser_order, p) self.parsers.insert(parser_order, p)

View File

@@ -483,7 +483,7 @@ class Flow(Scope):
for s in self.inits: for s in self.inits:
stmts.append(s.get_code(new_line=False)) stmts.append(s.get_code(new_line=False))
stmt = ', '.join(stmts) stmt = ', '.join(stmts)
string = "%s %s:\n" % (self.command, vars, stmt) string = "%s %s:\n" % (self.command, stmt)
string += super(Flow, self).get_code(True, indention) string += super(Flow, self).get_code(True, indention)
if self.next: if self.next:
string += self.next.get_code() string += self.next.get_code()
@@ -1235,7 +1235,7 @@ class PyFuzzyParser(object):
d.parent = self.module d.parent = self.module
self.start_pos = self.module.start_pos self.start_pos = self.module.start_pos
self.end_pos = self.module.start_pos self.module.end_pos = self.end_pos
def __repr__(self): def __repr__(self):
return "<%s: %s>" % (type(self).__name__, self.module) return "<%s: %s>" % (type(self).__name__, self.module)