From 00746e5c8d1d731d0a0cb581f3bddadde31d0d31 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sat, 1 Nov 2014 14:24:55 -0700 Subject: Things compile for now, error messages seem pretty good... --- book/src/main/scalatex/book/CanvasApp.scalatex | 2 +- .../src/main/scala/scalatex/stages/Compiler.scala | 21 ++++++++------------- .../main/scala/scalatex/stages/IndentHandler.scala | 2 +- .../src/test/scala/scalatex/BasicTests.scala | 2 +- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/book/src/main/scalatex/book/CanvasApp.scalatex b/book/src/main/scalatex/book/CanvasApp.scalatex index bdfa51a..2e05682 100644 --- a/book/src/main/scalatex/book/CanvasApp.scalatex +++ b/book/src/main/scalatex/book/CanvasApp.scalatex @@ -43,7 +43,7 @@ @p In general, you have access to all the DOM APIs through the @hl.scala{dom} package as well as through Javascript objects such as the @hl.scala{dom.HTMLCanvasElement}. Setting the @code{onmouseXXX} callbacks is just one way of interacting with the DOM. With Scala.js, you also get a very handy autocomplete in the editor, which you can use to browse the various other APIs that are available for use: - @img(src:="images/Dropdown.png", maxWidth:="100%") + @img(src:="images/Dropdown.png", maxWidth:="100%") @p Apart from mouse events, keyboard events, scroll events, input events, etc. are all usable from Scala.js as you'd expect 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 diff --git a/scalatexApi/src/test/scala/scalatex/BasicTests.scala b/scalatexApi/src/test/scala/scalatex/BasicTests.scala index f432e51..617841e 100644 --- a/scalatexApi/src/test/scala/scalatex/BasicTests.scala +++ b/scalatexApi/src/test/scala/scalatex/BasicTests.scala @@ -230,7 +230,7 @@ object BasicTests extends TestSuite{ @x } """), - Internals.twDebug(""" + tw(""" @ul @things.map x => @li -- cgit v1.2.3