src/Pure/PIDE/document.scala
changeset 65332 7dbb780f24a9
parent 65221 6af51a47545b
child 65355 403eabd73c9a
equal deleted inserted replaced
65331:999864cdf96c 65332:7dbb780f24a9
   447 
   447 
   448     def node_name: Node.Name
   448     def node_name: Node.Name
   449     def node: Node
   449     def node: Node
   450     def commands_loading: List[Command]
   450     def commands_loading: List[Command]
   451     def commands_loading_ranges(pred: Node.Name => Boolean): List[Text.Range]
   451     def commands_loading_ranges(pred: Node.Name => Boolean): List[Text.Range]
   452     def command_results(command: Command): Command.Results
       
   453     def current_command(other_node_name: Node.Name, offset: Text.Offset): Option[Command]
   452     def current_command(other_node_name: Node.Name, offset: Text.Offset): Option[Command]
   454 
   453 
   455     def find_command(id: Document_ID.Generic): Option[(Node, Command)]
   454     def find_command(id: Document_ID.Generic): Option[(Node, Command)]
   456     def find_command_position(id: Document_ID.Generic, offset: Symbol.Offset)
   455     def find_command_position(id: Document_ID.Generic, offset: Symbol.Offset)
   457       : Option[Line.Node_Position]
   456       : Option[Line.Node_Position]
   466     def select[A](
   465     def select[A](
   467       range: Text.Range,
   466       range: Text.Range,
   468       elements: Markup.Elements,
   467       elements: Markup.Elements,
   469       result: List[Command.State] => Text.Markup => Option[A],
   468       result: List[Command.State] => Text.Markup => Option[A],
   470       status: Boolean = false): List[Text.Info[A]]
   469       status: Boolean = false): List[Text.Info[A]]
       
   470 
       
   471     def command_results(range: Text.Range): Command.Results
       
   472     def command_results(command: Command): Command.Results
   471   }
   473   }
   472 
   474 
   473 
   475 
   474   /* model */
   476   /* model */
   475 
   477 
   824             cmd <- node.load_commands.iterator
   826             cmd <- node.load_commands.iterator
   825             blob_name <- cmd.blobs_names.iterator
   827             blob_name <- cmd.blobs_names.iterator
   826             if pred(blob_name)
   828             if pred(blob_name)
   827             start <- node.command_start(cmd)
   829             start <- node.command_start(cmd)
   828           } yield convert(cmd.proper_range + start)).toList
   830           } yield convert(cmd.proper_range + start)).toList
   829 
       
   830         def command_results(command: Command): Command.Results =
       
   831           state.command_results(version, command)
       
   832 
   831 
   833         def current_command(other_node_name: Node.Name, offset: Text.Offset): Option[Command] =
   832         def current_command(other_node_name: Node.Name, offset: Text.Offset): Option[Command] =
   834           if (other_node_name.is_theory) {
   833           if (other_node_name.is_theory) {
   835             val other_node = version.nodes(other_node_name)
   834             val other_node = version.nodes(other_node_name)
   836             val iterator = other_node.command_iterator(revert(offset) max 0)
   835             val iterator = other_node.command_iterator(revert(offset) max 0)
   917           for (Text.Info(r, Some(x)) <- cumulate(range, None, elements, result1 _, status))
   916           for (Text.Info(r, Some(x)) <- cumulate(range, None, elements, result1 _, status))
   918             yield Text.Info(r, x)
   917             yield Text.Info(r, x)
   919         }
   918         }
   920 
   919 
   921 
   920 
       
   921         /* command results */
       
   922 
       
   923         def command_results(range: Text.Range): Command.Results =
       
   924           Command.State.merge_results(
       
   925             select[List[Command.State]](range, Markup.Elements.full, command_states =>
       
   926               { case _ => Some(command_states) }).flatMap(_.info))
       
   927 
       
   928         def command_results(command: Command): Command.Results =
       
   929           state.command_results(version, command)
       
   930 
       
   931 
   922         /* output */
   932         /* output */
   923 
   933 
   924         override def toString: String =
   934         override def toString: String =
   925           "Snapshot(node = " + node_name.node + ", version = " + version.id +
   935           "Snapshot(node = " + node_name.node + ", version = " + version.id +
   926             (if (is_outdated) ", outdated" else "") + ")"
   936             (if (is_outdated) ", outdated" else "") + ")"