clarified signature;
authorwenzelm
Wed May 20 22:07:41 2020 +0200 (11 days ago)
changeset 71850f640380aaf86
parent 71849 265bbad3d6af
child 71851 34ecb540a079
clarified signature;
src/Pure/System/scala.scala
src/Tools/jEdit/src/scala_console.scala
     1.1 --- a/src/Pure/System/scala.scala	Wed May 20 20:45:43 2020 +0200
     1.2 +++ b/src/Pure/System/scala.scala	Wed May 20 22:07:41 2020 +0200
     1.3 @@ -8,12 +8,39 @@
     1.4  
     1.5  
     1.6  import java.lang.reflect.{Method, Modifier, InvocationTargetException}
     1.7 +import java.io.{File => JFile}
     1.8  
     1.9  import scala.util.matching.Regex
    1.10 +import scala.tools.nsc.GenericRunnerSettings
    1.11  
    1.12  
    1.13  object Scala
    1.14  {
    1.15 +  /* compiler classpath and settings */
    1.16 +
    1.17 +  def compiler_classpath(jar_dirs: List[JFile]): String =
    1.18 +  {
    1.19 +    def find_jars(dir: JFile): List[String] =
    1.20 +      File.find_files(dir, file => file.getName.endsWith(".jar")).
    1.21 +        map(File.absolute_name)
    1.22 +
    1.23 +    val class_path =
    1.24 +      space_explode(JFile.pathSeparatorChar, System.getProperty("java.class.path", ""))
    1.25 +
    1.26 +    (class_path ::: jar_dirs.flatMap(find_jars)).mkString(JFile.pathSeparator)
    1.27 +  }
    1.28 +
    1.29 +  def compiler_settings(
    1.30 +    error: String => Unit = Exn.error,
    1.31 +    jar_dirs: List[JFile] = Nil): GenericRunnerSettings =
    1.32 +  {
    1.33 +    val settings = new GenericRunnerSettings(error)
    1.34 +    settings.classpath.value = compiler_classpath(jar_dirs)
    1.35 +    settings
    1.36 +  }
    1.37 +
    1.38 +
    1.39 +
    1.40    /** invoke JVM method via Isabelle/Scala **/
    1.41  
    1.42    /* method reflection */
     2.1 --- a/src/Tools/jEdit/src/scala_console.scala	Wed May 20 20:45:43 2020 +0200
     2.2 +++ b/src/Tools/jEdit/src/scala_console.scala	Wed May 20 22:07:41 2020 +0200
     2.3 @@ -25,23 +25,9 @@
     2.4  {
     2.5    /* reconstructed jEdit/plugin classpath */
     2.6  
     2.7 -  private def reconstruct_classpath(): String =
     2.8 -  {
     2.9 -    def find_jars(start: String): List[String] =
    2.10 -      if (start != null)
    2.11 -        File.find_files(new JFile(start), file => file.getName.endsWith(".jar")).
    2.12 -          map(File.absolute_name)
    2.13 -      else Nil
    2.14 -
    2.15 -    val initial_class_path =
    2.16 -      space_explode(JFile.pathSeparatorChar, System.getProperty("java.class.path", ""))
    2.17 -
    2.18 -    val path =
    2.19 -      initial_class_path :::
    2.20 -      find_jars(jEdit.getSettingsDirectory) :::
    2.21 -      find_jars(jEdit.getJEditHome)
    2.22 -    path.mkString(JFile.pathSeparator)
    2.23 -  }
    2.24 +  private def jar_dirs: List[JFile] =
    2.25 +    (proper_string(jEdit.getSettingsDirectory).toList :::
    2.26 +     proper_string(jEdit.getJEditHome).toList).map(new JFile(_))
    2.27  
    2.28  
    2.29    /* global state -- owned by GUI thread */
    2.30 @@ -127,8 +113,7 @@
    2.31      private val running = Synchronized[Option[Thread]](None)
    2.32      def interrupt { running.change(opt => { opt.foreach(_.interrupt); opt }) }
    2.33  
    2.34 -    private val settings = new GenericRunnerSettings(report_error)
    2.35 -    settings.classpath.value = reconstruct_classpath()
    2.36 +    private val settings = Scala.compiler_settings(error = report_error, jar_dirs = jar_dirs)
    2.37  
    2.38      private val interp = new IMain(settings, new PrintWriter(console_writer, true))
    2.39      {