src/Pure/PIDE/document.scala
changeset 66043 f704c063e95d
parent 66041 c49bd8bb4839
child 66114 c137a9f038a6
equal deleted inserted replaced
66042:98aaeff47795 66043:f704c063e95d
   233           }
   233           }
   234         }
   234         }
   235         (blocks.toArray, Text.Range(0, last_stop))
   235         (blocks.toArray, Text.Range(0, last_stop))
   236       }
   236       }
   237 
   237 
   238       def full_range: Text.Range = full_index._2
   238       private def full_range: Text.Range = full_index._2
   239 
   239 
   240       def iterator(i: Text.Offset = 0): Iterator[(Command, Text.Offset)] =
   240       def iterator(i: Text.Offset = 0): Iterator[(Command, Text.Offset)] =
   241       {
   241       {
   242         if (commands.nonEmpty && full_range.contains(i)) {
   242         if (commands.nonEmpty && full_range.contains(i)) {
   243           val (cmd0, start0) = full_index._1(i / Commands.block_size)
   243           val (cmd0, start0) = full_index._1(i / Commands.block_size)
   300     def update_commands(new_commands: Linear_Set[Command]): Node =
   300     def update_commands(new_commands: Linear_Set[Command]): Node =
   301       if (new_commands eq _commands.commands) this
   301       if (new_commands eq _commands.commands) this
   302       else
   302       else
   303         new Node(get_blob, header, syntax, text_perspective, perspective,
   303         new Node(get_blob, header, syntax, text_perspective, perspective,
   304           Node.Commands(new_commands))
   304           Node.Commands(new_commands))
   305 
       
   306     def commands_range: Text.Range = _commands.full_range
       
   307 
   305 
   308     def command_iterator(i: Text.Offset = 0): Iterator[(Command, Text.Offset)] =
   306     def command_iterator(i: Text.Offset = 0): Iterator[(Command, Text.Offset)] =
   309       _commands.iterator(i)
   307       _commands.iterator(i)
   310 
   308 
   311     def command_iterator(range: Text.Range): Iterator[(Command, Text.Offset)] =
   309     def command_iterator(range: Text.Range): Iterator[(Command, Text.Offset)] =
   457 
   455 
   458     def commands_loading: List[Command]
   456     def commands_loading: List[Command]
   459     def commands_loading_ranges(pred: Node.Name => Boolean): List[Text.Range]
   457     def commands_loading_ranges(pred: Node.Name => Boolean): List[Text.Range]
   460     def current_command(other_node_name: Node.Name, offset: Text.Offset): Option[Command]
   458     def current_command(other_node_name: Node.Name, offset: Text.Offset): Option[Command]
   461 
   459 
   462     def markup_to_XML(restriction: Option[Text.Range], elements: Markup.Elements): XML.Body
   460     def markup_to_XML(range: Text.Range, elements: Markup.Elements): XML.Body
   463 
   461 
   464     def find_command(id: Document_ID.Generic): Option[(Node, Command)]
   462     def find_command(id: Document_ID.Generic): Option[(Node, Command)]
   465     def find_command_position(id: Document_ID.Generic, offset: Symbol.Offset)
   463     def find_command_position(id: Document_ID.Generic, offset: Symbol.Offset)
   466       : Option[Line.Node_Position]
   464       : Option[Line.Node_Position]
   467 
   465 
   775       Command.State.merge_markup(command_states(version, command), index, range, elements)
   773       Command.State.merge_markup(command_states(version, command), index, range, elements)
   776 
   774 
   777     def markup_to_XML(
   775     def markup_to_XML(
   778       version: Version,
   776       version: Version,
   779       node: Node,
   777       node: Node,
   780       restriction: Option[Text.Range],
   778       range: Text.Range,
   781       elements: Markup.Elements): XML.Body =
   779       elements: Markup.Elements): XML.Body =
   782     {
   780     {
   783       val range = restriction.getOrElse(node.commands_range)
       
   784       (for {
   781       (for {
   785         command <- node.commands.iterator
   782         command <- node.commands.iterator
   786         command_range <- command.range.try_restrict(range).iterator
   783         command_range <- command.range.try_restrict(range).iterator
   787         markup =
   784         markup =
   788           command_markup(version, command, Command.Markup_Index.markup, command_range, elements)
   785           command_markup(version, command, Command.Markup_Index.markup, command_range, elements)
   856             }
   853             }
   857             else other_node.commands.reverse.iterator.find(command => !command.is_ignored)
   854             else other_node.commands.reverse.iterator.find(command => !command.is_ignored)
   858           }
   855           }
   859           else version.nodes.commands_loading(other_node_name).headOption
   856           else version.nodes.commands_loading(other_node_name).headOption
   860 
   857 
   861         def markup_to_XML(restriction: Option[Text.Range], elements: Markup.Elements): XML.Body =
   858         def markup_to_XML(range: Text.Range, elements: Markup.Elements): XML.Body =
   862           state.markup_to_XML(version, node, restriction, elements)
   859           state.markup_to_XML(version, node, range, elements)
   863 
   860 
   864 
   861 
   865         /* find command */
   862         /* find command */
   866 
   863 
   867         def find_command(id: Document_ID.Generic): Option[(Node, Command)] =
   864         def find_command(id: Document_ID.Generic): Option[(Node, Command)] =