From 049b56816ab82e66f637e3f9e7fd0f356b96983d Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sat, 1 Nov 2014 14:19:16 -0700 Subject: quick hack to make book compile, even though the tree-position math is slightly off --- scalatexApi/src/main/scala/scalatex/stages/Compiler.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'scalatexApi/src') diff --git a/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala b/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala index f30ee57..84c1c09 100644 --- a/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala +++ b/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala @@ -18,7 +18,7 @@ object Compiler{ def posFor(offset: Int) = { new OffsetPosition( literalPos.source, - offset + math.min(offset, literalPos.source.length - 1) ).asInstanceOf[c.universe.Position] } def compileTree(frag: WN.TemplateTree): Tree = { @@ -27,16 +27,20 @@ object Compiler{ object fragPos{ private val fragPos = posFor(literalPos.point + frag.offset) private def fragPosFor(offset: Int) = { - println(posFor(fragPos.point + offset)) - posFor(fragPos.point + offset) + val res = posFor(fragPos.point + offset) + println(res.lineContent) + res } def at(t: Tree, offset: Int) = { println(t) - atPos(fragPosFor(offset))(t) + val res = atPos(fragPosFor(offset))(t) + println("-") + res } def set(t: Tree, offset: Int) = { println(t) c.internal.setPos(t, fragPosFor(offset)) + println("+") t } } -- cgit v1.2.3