summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/Global.scala
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-09-06 18:28:44 +0200
committerDen Shabalin <den.shabalin@gmail.com>2013-09-12 12:43:23 +0200
commit95fe19545d60ae9aa79d2c8d5665c7f3b0cbdb1a (patch)
tree7848cd767ac44c0e6e5790553d29afac9439a030 /src/compiler/scala/tools/nsc/Global.scala
parent5607bd137d8a22c6933e3692a4a1626928acf67f (diff)
downloadscala-95fe19545d60ae9aa79d2c8d5665c7f3b0cbdb1a.tar.gz
scala-95fe19545d60ae9aa79d2c8d5665c7f3b0cbdb1a.tar.bz2
scala-95fe19545d60ae9aa79d2c8d5665c7f3b0cbdb1a.zip
SI-6489 parsing in macros should provide proper positions
1. macro parsing doesn't use toolbox any more but calls parser directly 2. in order for this to work parser has to be refactored to limit usage of currentUnit and rewire it into parser's local unit method which might use currentUnit for some parsers but will user proper unit for UnitParser 3. similar change has to be done to make compilation unit's reporter overridable
Diffstat (limited to 'src/compiler/scala/tools/nsc/Global.scala')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 0e3b2993c7..8b9ef2178b 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -110,7 +110,10 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
}
/** A spare instance of TreeBuilder left for backwards compatibility. */
- lazy val treeBuilder: TreeBuilder { val global: Global.this.type } = new syntaxAnalyzer.ParserTreeBuilder
+ lazy val treeBuilder: TreeBuilder { val global: Global.this.type } = new UnitTreeBuilder {
+ val global: Global.this.type = Global.this;
+ val unit = currentUnit
+ }
/** Fold constants */
object constfold extends {
@@ -1139,11 +1142,20 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
warning("there were %d %s warning(s); re-run with %s for details".format(warnings.size, what, option.name))
}
- def newCompilationUnit(code: String) = new CompilationUnit(newSourceFile(code))
- def newSourceFile(code: String) = new BatchSourceFile("<console>", code)
- def newUnitScanner(unit: CompilationUnit): UnitScanner = new UnitScanner(unit)
- def newUnitParser(unit: CompilationUnit): UnitParser = new UnitParser(unit)
- def newUnitParser(code: String): UnitParser = newUnitParser(newCompilationUnit(code))
+ def newSourceFile(code: String, filename: String = "<console>") =
+ new BatchSourceFile(filename, code)
+
+ def newCompilationUnit(code: String, filename: String = "<console>") =
+ new CompilationUnit(newSourceFile(code, filename))
+
+ def newUnitScanner(unit: CompilationUnit): UnitScanner =
+ new UnitScanner(unit)
+
+ def newUnitParser(unit: CompilationUnit): UnitParser =
+ new UnitParser(unit)
+
+ def newUnitParser(code: String, filename: String = "<console>"): UnitParser =
+ newUnitParser(newCompilationUnit(code, filename))
/** A Run is a single execution of the compiler on a sets of units
*/