diff options
author | Li Haoyi <haoyi@dropbox.com> | 2014-11-01 14:19:16 -0700 |
---|---|---|
committer | Li Haoyi <haoyi@dropbox.com> | 2014-11-01 14:19:16 -0700 |
commit | 049b56816ab82e66f637e3f9e7fd0f356b96983d (patch) | |
tree | c63dd93383489d1049f8c23da91cfeea92aa29a3 /scalatexApi/src/main/scala/scalatex/stages | |
parent | 76dab1a2729ada22c3c3a395aae98d3c4532d5ef (diff) | |
download | hands-on-scala-js-049b56816ab82e66f637e3f9e7fd0f356b96983d.tar.gz hands-on-scala-js-049b56816ab82e66f637e3f9e7fd0f356b96983d.tar.bz2 hands-on-scala-js-049b56816ab82e66f637e3f9e7fd0f356b96983d.zip |
quick hack to make book compile, even though the tree-position math is slightly off
Diffstat (limited to 'scalatexApi/src/main/scala/scalatex/stages')
-rw-r--r-- | scalatexApi/src/main/scala/scalatex/stages/Compiler.scala | 12 |
1 files changed, 8 insertions, 4 deletions
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 } } |