diff --git a/code_examples/Reporting2.pm b/code_examples/Reporting2.pm index 18ad6a0..b2a338b 100644 --- a/code_examples/Reporting2.pm +++ b/code_examples/Reporting2.pm @@ -13,8 +13,8 @@ drop table foog; select cast(plunk as timestamp) from blarg join plarg using(id_what) where x = 3; EOT -#@@:string:mode_sql.Sql my $foo = { + #@@:string:mode_sql.Sql 'drop table ', 'bar', }; diff --git a/method.py b/method.py index b9093e6..7698ade 100644 --- a/method.py +++ b/method.py @@ -463,13 +463,18 @@ class DumpTokens(Method): lines.append("LINE %d" % i) group = tokens[i] for token in group: - coord = '(%d, %d)' % (token.x, token.y) + fqname = token.fqname() + p1 = Point(token.x, token.y) if token.parent is None: pcoord = '' else: pcoord = '[%d, %d]' % (token.parent.x, token.parent.y) - fields = (coord, pcoord, token.fqname(), token.string) - lines.append(' %-10s %-10s %-30s %r' % fields) + if fqname in w.mode.ghist and p1 in w.mode.ghist[fqname]: + g = '[' + w.mode.ghist[fqname][p1].name() + ']' + else: + g = '' + fields = (str(p1), pcoord, token.fqname(), g, token.string) + lines.append(' %-10s %-10s %-20s %-10s %r' % fields) else: lines.append("no tokens") output = "\n".join(lines) diff --git a/mode2.py b/mode2.py index f4739c4..35e0525 100644 --- a/mode2.py +++ b/mode2.py @@ -216,15 +216,21 @@ class Fundamental(Handler): xdelta = len(newlines[-1]) ghist = {} for name in self.ghist: - for p2 in self.ghist[name]: - if p2.y > p.y: - newp = Point(p2.x, p2.y + ydelta) + for gp in self.ghist[name]: + if gp < p: + newp = gp elif ydelta == 0: - newp = Point(p2.x + xdelta, p2.y) + if p.y == gp.y: + newp = Point(gp.x + xdelta, gp.y) + else: + newp = gp else: - newp = Point(p2.x, p2.y + ydelta) + if gp.y == p.y: + newp = Point(gp.x + xdelta, gp.y + ydelta) + else: + newp = Point(gp.x, gp.y + ydelta) ghist.setdefault(name, {}) - ghist[name][newp] = self.ghist[name][p2] + ghist[name][newp] = self.ghist[name][gp] self.ghist = ghist def region_removed(self, p1, p2): if self.tabber is not None: @@ -234,21 +240,21 @@ class Fundamental(Handler): xdelta = p2.x - p1.x ghist = {} for name in self.ghist: - for p in self.ghist[name]: - if p < p1: - newp = p - elif p1 <= p and p < p2: + for gp in self.ghist[name]: + if gp < p1: + newp = gp + elif p1 <= gp and gp < p2: continue elif ydelta == 0: - if p.y == p2.y: - newp = Point(p.x - xdelta, p.y) + if gp.y == p2.y: + newp = Point(gp.x - xdelta, gp.y) else: - newp = p + newp = gp else: - if p.y == p2.y: - newp = Point(p.x - xdelta, p.y - ydelta) + if gp.y == p2.y: + newp = Point(gp.x - xdelta, gp.y - ydelta) else: - newp = Point(p.x, p.y - ydelta) + newp = Point(gp.x, gp.y - ydelta) ghist.setdefault(name, {}) - ghist[name][newp] = self.ghist[name][p] + ghist[name][newp] = self.ghist[name][gp] self.ghist = ghist