proper Presentation.Entity_Context for hyperlinks (amending da1108a6d249);
authorwenzelm
Fri, 25 Feb 2022 16:54:50 +0100
changeset 75154 3b5aa38282bd
parent 75153 e7b7764d0977
child 75155 0b6c43a87fa6
proper Presentation.Entity_Context for hyperlinks (amending da1108a6d249);
src/Tools/VSCode/src/dynamic_output.scala
src/Tools/VSCode/src/state_panel.scala
--- a/src/Tools/VSCode/src/dynamic_output.scala	Fri Feb 25 16:12:42 2022 +0100
+++ b/src/Tools/VSCode/src/dynamic_output.scala	Fri Feb 25 16:54:50 2022 +0100
@@ -35,25 +35,19 @@
             else this
         }
       if (st1.output != output) {
-        val elements = Presentation.Elements(
-          html = Presentation.elements2.html,
-          language = Presentation.elements2.language,
-          entity = Markup.Elements.full)
-
-        def entity_link(props: Properties.T, body: XML.Body): Option[XML.Tree] =
-          for {
-            thy_file <- Position.Def_File.unapply(props)
-            def_line <- Position.Def_Line.unapply(props)
-            source <- resources.source_file(thy_file)
-            uri = Path.explode(source).absolute_file.toURI
-          } yield HTML.link(uri.toString + "#" + def_line, body)
-
-        val htmlBody = Presentation.make_html(
-          Presentation.Entity_Context.empty,  // FIXME
-          elements,
-          Pretty.separate(st1.output))
-
-        channel.write(LSP.Dynamic_Output(HTML.source(htmlBody).toString))
+        val context =
+          new Presentation.Entity_Context {
+            override def make_ref(props: Properties.T, body: XML.Body): Option[XML.Elem] =
+              for {
+                thy_file <- Position.Def_File.unapply(props)
+                def_line <- Position.Def_Line.unapply(props)
+                source <- resources.source_file(thy_file)
+                uri = Path.explode(source).absolute_file.toURI
+              } yield HTML.link(uri.toString + "#" + def_line, body)
+          }
+        val elements = Presentation.elements2.copy(entity = Markup.Elements.full)
+        val html = Presentation.make_html(context, elements, Pretty.separate(st1.output))
+        channel.write(LSP.Dynamic_Output(HTML.source(html).toString))
       }
       st1
     }
--- a/src/Tools/VSCode/src/state_panel.scala	Fri Feb 25 16:12:42 2022 +0100
+++ b/src/Tools/VSCode/src/state_panel.scala	Fri Feb 25 16:54:50 2022 +0100
@@ -63,25 +63,19 @@
     new Query_Operation(server.editor, (), "print_state", _ => (),
       (_, _, body) =>
         if (output_active.value && body.nonEmpty){
-          val elements = Presentation.Elements(
-            html = Presentation.elements2.html,
-            language = Presentation.elements2.language,
-            entity = Markup.Elements.full)
-
-          def entity_link(props: Properties.T, body: XML.Body): Option[XML.Tree] =
-            for {
-              thy_file <- Position.Def_File.unapply(props)
-              def_line <- Position.Def_Line.unapply(props)
-              source <- server.resources.source_file(thy_file)
-              uri = Path.explode(source).absolute_file.toURI
-            } yield HTML.link(uri.toString + "#" + def_line, body)
-
-          val htmlBody = Presentation.make_html(
-            Presentation.Entity_Context.empty,  // FIXME
-            elements,
-            Pretty.separate(body))
-
-          output(HTML.source(htmlBody).toString)
+          val context =
+            new Presentation.Entity_Context {
+              override def make_ref(props: Properties.T, body: XML.Body): Option[XML.Elem] =
+                for {
+                  thy_file <- Position.Def_File.unapply(props)
+                  def_line <- Position.Def_Line.unapply(props)
+                  source <- server.resources.source_file(thy_file)
+                  uri = Path.explode(source).absolute_file.toURI
+                } yield HTML.link(uri.toString + "#" + def_line, body)
+            }
+          val elements = Presentation.elements2.copy(entity = Markup.Elements.full)
+          val html = Presentation.make_html(context, elements, Pretty.separate(body))
+          output(HTML.source(html).toString)
         })
 
   def locate(): Unit = print_state.locate_query()