diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-03-22 21:25:35 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-03-22 21:28:27 +0100 |
commit | 6cb50acfb5ee4df342e83d8505116d4607f45d1c (patch) | |
tree | bd37410452b625a74c5337f9a5509ae8451b5189 /src/repl/scala/tools/nsc/interpreter/PresentationCompilation.scala | |
parent | ad48e5918081c679546f50b6f52dd8e0813754e7 (diff) | |
download | scala-6cb50acfb5ee4df342e83d8505116d4607f45d1c.tar.gz scala-6cb50acfb5ee4df342e83d8505116d4607f45d1c.tar.bz2 scala-6cb50acfb5ee4df342e83d8505116d4607f45d1c.zip |
Enable flat classpath by default
Implements VirtualDirectoryFlatClassPath, which is required for the
presentation compiler created for the repl's tab-completion.
Various minor cleanups in the flat classpath implementation.
Diffstat (limited to 'src/repl/scala/tools/nsc/interpreter/PresentationCompilation.scala')
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/PresentationCompilation.scala | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/PresentationCompilation.scala b/src/repl/scala/tools/nsc/interpreter/PresentationCompilation.scala index c8cd201bf5..e3dc72b717 100644 --- a/src/repl/scala/tools/nsc/interpreter/PresentationCompilation.scala +++ b/src/repl/scala/tools/nsc/interpreter/PresentationCompilation.scala @@ -5,12 +5,14 @@ package scala.tools.nsc.interpreter import scala.reflect.internal.util.RangePosition +import scala.reflect.io.AbstractFile import scala.tools.nsc.backend.JavaPlatform +import scala.tools.nsc.settings.ClassPathRepresentationType +import scala.tools.nsc.util.ClassPath.DefaultJavaContext +import scala.tools.nsc.util.{ClassPath, MergedClassPath, DirectoryClassPath} import scala.tools.nsc.{interactive, Settings} -import scala.tools.nsc.io._ import scala.tools.nsc.reporters.StoreReporter -import scala.tools.nsc.util.ClassPath.DefaultJavaContext -import scala.tools.nsc.util.{DirectoryClassPath, MergedClassPath} +import scala.tools.nsc.classpath._ trait PresentationCompilation { self: IMain => @@ -55,8 +57,14 @@ trait PresentationCompilation { * You may downcast the `reporter` to `StoreReporter` to access type errors. */ def newPresentationCompiler(): interactive.Global = { - val replOutClasspath: DirectoryClassPath = new DirectoryClassPath(replOutput.dir, DefaultJavaContext) - val mergedClasspath = new MergedClassPath[AbstractFile](replOutClasspath :: global.platform.classPath :: Nil, DefaultJavaContext) + def mergedFlatClasspath = { + val replOutClasspath = FlatClassPathFactory.newClassPath(replOutput.dir, settings) + AggregateFlatClassPath(replOutClasspath :: global.platform.flatClassPath :: Nil) + } + def mergedRecursiveClasspath = { + val replOutClasspath: DirectoryClassPath = new DirectoryClassPath(replOutput.dir, DefaultJavaContext) + new MergedClassPath[AbstractFile](replOutClasspath :: global.platform.classPath :: Nil, DefaultJavaContext) + } def copySettings: Settings = { val s = new Settings(_ => () /* ignores "bad option -nc" errors, etc */) s.processArguments(global.settings.recreateArgs, processAll = false) @@ -65,10 +73,18 @@ trait PresentationCompilation { } val storeReporter: StoreReporter = new StoreReporter val interactiveGlobal = new interactive.Global(copySettings, storeReporter) { self => - override lazy val platform: ThisPlatform = new JavaPlatform { - val global: self.type = self - - override def classPath: PlatformClassPath = mergedClasspath + override lazy val platform: ThisPlatform = { + if (settings.YclasspathImpl.value == ClassPathRepresentationType.Flat) { + new JavaPlatform { + val global: self.type = self + override private[nsc] lazy val flatClassPath: FlatClassPath = mergedFlatClasspath + } + } else { + new JavaPlatform { + val global: self.type = self + override def classPath: ClassPath[AbstractFile] = mergedRecursiveClasspath + } + } } } new interactiveGlobal.TyperRun() |