-
Notifications
You must be signed in to change notification settings - Fork 18
/
GaptRepl.scala
37 lines (28 loc) · 1.1 KB
/
GaptRepl.scala
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
37
package gapt.cli
import gapt.formats.ClasspathInputFile
import scala.tools.nsc.Settings
import scala.tools.nsc.interpreter.shell.{ ILoop, ShellConfig }
import scala.tools.nsc.interpreter.InteractiveReader
case class GaptRepl() {
private val replSettings = new Settings
replSettings.usejavacp.value = true
replSettings.feature.value = true
replSettings.deprecation.value = true
replSettings.language.value = {
import replSettings.language.domain._
ValueSet( postfixOps, implicitConversions )
}
private val shellConfiguration = ShellConfig( replSettings )
sys.props( "scala.shell.prompt" ) = sys.props( "line.separator" ) + "gapt> "
private val repl = new ILoop( shellConfiguration ) {
override def createInterpreter( settings: Settings ) = {
super.createInterpreter( settings )
val predefCode: String = readPredefFile
intp.beQuietDuring( intp.interpret( predefCode ) )
}
override def printWelcome() = print( welcomeMessage )
}
def run(): Unit = repl.run( replSettings )
private def readPredefFile: String =
ClasspathInputFile( predefFileName ).read
}