blob: 9c24273cd7305419ce31dcecfe4b64cb52174aa1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package scala.reflect.macros
package runtime
trait Settings {
self: Context =>
def settings: List[String] = {
val us = universe.settings
import us._
userSetSettings collectFirst { case x: MultiStringSetting if x.name == XmacroSettings.name => x.value } getOrElse Nil
}
def compilerSettings: List[String] = universe.settings.recreateArgs
def setCompilerSettings(options: String): this.type =
// todo. is not going to work with quoted arguments with embedded whitespaces
setCompilerSettings(options.split(" ").toList)
def setCompilerSettings(options: List[String]): this.type = {
val settings = new tools.nsc.Settings(_ => ())
// [Eugene] what settings should we exclude?
settings.copyInto(universe.settings)
this
}
def withCompilerSettings[T](options: String)(op: => T): T =
// todo. is not going to work with quoted arguments with embedded whitespaces
withCompilerSettings(options.split(" ").toList)(op)
def withCompilerSettings[T](options: List[String])(op: => T): T = {
val old = options
setCompilerSettings(options)
try op
finally setCompilerSettings(old)
}
}
|