src/Pure/PIDE/resources.scala
changeset 66696 8f863dae78a0
parent 66695 91500c024c7f
child 66697 190834aa43a7
     1.1 --- a/src/Pure/PIDE/resources.scala	Tue Sep 26 20:54:40 2017 +0200
     1.2 +++ b/src/Pure/PIDE/resources.scala	Tue Sep 26 22:30:54 2017 +0200
     1.3 @@ -57,20 +57,32 @@
     1.4  
     1.5    /* theory files */
     1.6  
     1.7 -  def loaded_files(syntax: Outer_Syntax, text: String): List[String] =
     1.8 -    if (syntax.load_commands_in(text)) {
     1.9 -      val spans = syntax.parse_spans(text)
    1.10 -      spans.iterator.map(Command.span_files(syntax, _)._1).flatten.toList
    1.11 -    }
    1.12 -    else Nil
    1.13 -
    1.14    def loaded_files(syntax: Outer_Syntax, name: Document.Node.Name): List[Path] =
    1.15    {
    1.16      val text = with_thy_reader(name, reader => Symbol.decode(reader.source.toString))
    1.17 -    val dir = Path.explode(name.master_dir)
    1.18 -    loaded_files(syntax, text).map(a => dir + Path.explode(a))
    1.19 +    if (syntax.load_commands_in(text)) {
    1.20 +      val spans = syntax.parse_spans(text)
    1.21 +      val dir = Path.explode(name.master_dir)
    1.22 +      spans.iterator.map(Command.span_files(syntax, _)._1).flatten.
    1.23 +        map(a => dir + Path.explode(a)).toList
    1.24 +    }
    1.25 +    else Nil
    1.26    }
    1.27  
    1.28 +  def pure_files(syntax: Outer_Syntax, session: String, dir: Path): List[Path] =
    1.29 +    if (Sessions.is_pure(session)) {
    1.30 +      val roots =
    1.31 +        for { (name, theory) <- Thy_Header.ml_roots }
    1.32 +        yield ((dir + Path.explode(name)).expand, theory)
    1.33 +      val files =
    1.34 +        for {
    1.35 +          (path, theory) <- roots
    1.36 +          file <- loaded_files(syntax, Document.Node.Name(path.implode, path.dir.implode, theory))
    1.37 +        } yield file
    1.38 +      roots.map(_._1) ::: files
    1.39 +    }
    1.40 +    else Nil
    1.41 +
    1.42    def theory_qualifier(name: Document.Node.Name): String =
    1.43      session_base.global_theories.getOrElse(name.theory, Long_Name.qualifier(name.theory))
    1.44