more explicit lookup of loaded_theories: base names allowed here;
authorwenzelm
Fri, 07 Apr 2017 16:34:14 +0200
changeset 65429 fcff401fb609
parent 65428 f8dd71a0791a
child 65430 4433d189a77d
more explicit lookup of loaded_theories: base names allowed here; no base names for known_theories;
src/Pure/PIDE/resources.scala
src/Pure/Thy/sessions.scala
src/Pure/Thy/thy_info.scala
--- a/src/Pure/PIDE/resources.scala	Fri Apr 07 15:53:06 2017 +0200
+++ b/src/Pure/PIDE/resources.scala	Fri Apr 07 16:34:14 2017 +0200
@@ -74,15 +74,14 @@
       if (Long_Name.is_qualified(theory0) || session_base.global_theories.contains(theory0)) theory0
       else Long_Name.qualify(session_name, theory0)
 
-    session_base.known_theories.get(theory) orElse session_base.known_theories.get(theory0) match
-    {
-      case Some(name) =>
-        if (session_base.loaded_theory(name)) name.loaded_theory else name
-      case None =>
-        val path = Path.explode(s)
-        val node = append(dir, thy_path(path))
-        val master_dir = append(dir, path.dir)
-        Document.Node.Name(node, master_dir, theory)
+    session_base.loaded_theories.get(theory) orElse
+    session_base.loaded_theories.get(theory0) orElse
+    session_base.known_theories.get(theory) orElse
+    session_base.known_theories.get(theory0) getOrElse {
+      val path = Path.explode(s)
+      val node = append(dir, thy_path(path))
+      val master_dir = append(dir, path.dir)
+      Document.Node.Name(node, master_dir, theory)
     }
   }
 
--- a/src/Pure/Thy/sessions.scala	Fri Apr 07 15:53:06 2017 +0200
+++ b/src/Pure/Thy/sessions.scala	Fri Apr 07 16:34:14 2017 +0200
@@ -40,9 +40,7 @@
           known.get(name.theory) match {
             case Some(name1) if name != name1 =>
               error("Duplicate theory " + quote(name.node) + " vs. " + quote(name1.node))
-            case _ =>
-              known + (name.theory -> name) +
-                (Long_Name.base_name(name.theory) -> name)  // legacy
+            case _ => known + (name.theory -> name)
           }
         })
     }
@@ -50,7 +48,7 @@
 
   sealed case class Base(
     global_theories: Set[String] = Set.empty,
-    loaded_theories: Set[String] = Set.empty,
+    loaded_theories: Map[String, Document.Node.Name] = Map.empty,
     known_theories: Map[String, Document.Node.Name] = Map.empty,
     keywords: Thy_Header.Keywords = Nil,
     syntax: Outer_Syntax = Outer_Syntax.empty,
@@ -58,7 +56,7 @@
     session_graph: Graph_Display.Graph = Graph_Display.empty_graph)
   {
     def loaded_theory(name: Document.Node.Name): Boolean =
-      loaded_theories.contains(name.theory)
+      loaded_theories.isDefinedAt(name.theory)
   }
 
   sealed case class Deps(sessions: Map[String, Base])
--- a/src/Pure/Thy/thy_info.scala	Fri Apr 07 15:53:06 2017 +0200
+++ b/src/Pure/Thy/thy_info.scala	Fri Apr 07 16:34:14 2017 +0200
@@ -67,7 +67,7 @@
       val import_errors =
         (for {
           (theory, imports) <- seen_theory.iterator_list
-          if !resources.session_base.loaded_theories(theory)
+          if !resources.session_base.loaded_theories.isDefinedAt(theory)
           if imports.length > 1
         } yield {
           "Incoherent imports for theory " + quote(theory) + ":\n" +
@@ -80,11 +80,12 @@
     lazy val syntax: Outer_Syntax =
       resources.session_base.syntax.add_keywords(keywords).add_abbrevs(abbrevs)
 
-    def loaded_theories: Set[String] =
+    def loaded_theories: Map[String, Document.Node.Name] =
       (resources.session_base.loaded_theories /: rev_deps) {
         case (loaded, dep) =>
-          loaded + dep.name.theory +
-            Long_Name.base_name(dep.name.theory)  // legacy
+          val name = dep.name.loaded_theory
+          loaded + (name.theory -> name) +
+            (Long_Name.base_name(name.theory) -> name)  // legacy
       }
 
     def loaded_files: List[Path] =