diff options
author | Den Shabalin <den.shabalin@gmail.com> | 2013-08-08 18:55:05 +0200 |
---|---|---|
committer | Den Shabalin <den.shabalin@gmail.com> | 2013-08-14 11:45:47 +0200 |
commit | b4598b4a7826b76cc6405b448b50d6c20f7a5732 (patch) | |
tree | 11c03a03ec45b8e4f1f53c13cfef0f24667c5fa2 /src/compiler | |
parent | d7ad291a0f93004fe9dc38f2414b77276f148c5c (diff) | |
download | scala-b4598b4a7826b76cc6405b448b50d6c20f7a5732.tar.gz scala-b4598b4a7826b76cc6405b448b50d6c20f7a5732.tar.bz2 scala-b4598b4a7826b76cc6405b448b50d6c20f7a5732.zip |
SI-7331 remove all the wrapping code from toolbox
Change toolbox parsing to use `parseStats` parser entry point
instead of current code-wrappign technique that makes positions
much less useful to end users.
There is also no need to create a compiler `Run` for parsing.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/reflect/ToolBoxFactory.scala | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index afaca3396c..8d2f200e99 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -269,17 +269,13 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => } def parse(code: String): Tree = { - val run = new Run reporter.reset() - val wrappedCode = "object wrapper {" + EOL + code + EOL + "}" - val file = new BatchSourceFile("<toolbox>", wrappedCode) + val file = new BatchSourceFile("<toolbox>", code) val unit = new CompilationUnit(file) - phase = run.parserPhase - val parser = newUnitParser(unit) - val wrappedTree = parser.parse() + val parsed = newUnitParser(unit).parseStats() throwIfErrors() - val PackageDef(_, List(ModuleDef(_, _, Template(_, _, _ :: parsed)))) = wrappedTree parsed match { + case Nil => EmptyTree case expr :: Nil => expr case stats :+ expr => Block(stats, expr) } |