summaryrefslogtreecommitdiff
path: root/scalatexApi/src/main/scala
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-01 14:24:55 -0700
committerLi Haoyi <haoyi@dropbox.com>2014-11-01 14:24:55 -0700
commit00746e5c8d1d731d0a0cb581f3bddadde31d0d31 (patch)
tree3303ec78cbf6185aed70cafb0215aeb1e6b2ed07 /scalatexApi/src/main/scala
parent049b56816ab82e66f637e3f9e7fd0f356b96983d (diff)
downloadhands-on-scala-js-00746e5c8d1d731d0a0cb581f3bddadde31d0d31.tar.gz
hands-on-scala-js-00746e5c8d1d731d0a0cb581f3bddadde31d0d31.tar.bz2
hands-on-scala-js-00746e5c8d1d731d0a0cb581f3bddadde31d0d31.zip
Things compile for now, error messages seem pretty good...
Diffstat (limited to 'scalatexApi/src/main/scala')
-rw-r--r--scalatexApi/src/main/scala/scalatex/stages/Compiler.scala21
-rw-r--r--scalatexApi/src/main/scala/scalatex/stages/IndentHandler.scala2
2 files changed, 9 insertions, 14 deletions
diff --git a/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala b/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala
index 84c1c09..5fdf998 100644
--- a/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala
+++ b/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala
@@ -15,32 +15,27 @@ object Compiler{
import c.universe._
def fragType = tq"scalatags.Text.all.Frag"
- def posFor(offset: Int) = {
- new OffsetPosition(
- literalPos.source,
- math.min(offset, literalPos.source.length - 1)
- ).asInstanceOf[c.universe.Position]
- }
+
def compileTree(frag: WN.TemplateTree): Tree = {
// println(frag)
object fragPos{
+ def posFor(offset: Int) = {
+ new OffsetPosition(
+ literalPos.source,
+ math.min(offset, literalPos.source.length - 1)
+ ).asInstanceOf[c.universe.Position]
+ }
private val fragPos = posFor(literalPos.point + frag.offset)
private def fragPosFor(offset: Int) = {
- val res = posFor(fragPos.point + offset)
- println(res.lineContent)
- res
+ posFor(fragPos.point + offset)
}
def at(t: Tree, offset: Int) = {
- println(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
}
}
diff --git a/scalatexApi/src/main/scala/scalatex/stages/IndentHandler.scala b/scalatexApi/src/main/scala/scalatex/stages/IndentHandler.scala
index 697ccc3..a39b498 100644
--- a/scalatexApi/src/main/scala/scalatex/stages/IndentHandler.scala
+++ b/scalatexApi/src/main/scala/scalatex/stages/IndentHandler.scala
@@ -88,7 +88,7 @@ object IndentHandler extends (String => String){
val newFirst =
if (!before.startsWith("@else")) before
else before.dropRight("@else".length)+ "} else"
- println(before, after, delta)
+// println(before, after, delta)
if (delta > 0 && noBraceLine(after)) newFirst + "{" + after
else if (delta <= 0 && noBraceLine(after) && after.trim != "") newFirst + "{" + after + "}" * (1 - elseCorrection)
else current