src/Pure/PIDE/document.scala
changeset 77004 8ecf99ac5359
parent 76933 dd53bb198eb1
child 77006 d9a4b3a73d8c
equal deleted inserted replaced
77000:ffc0774e0efe 77004:8ecf99ac5359
   672           val command = st.command
   672           val command = st.command
   673           val command_node = get_node(command.node_name)
   673           val command_node = get_node(command.node_name)
   674           if (command_node.commands.contains(command)) Some((command_node, command)) else None
   674           if (command_node.commands.contains(command)) Some((command_node, command)) else None
   675       }
   675       }
   676 
   676 
   677     def find_command_position(id: Document_ID.Generic, offset: Symbol.Offset)
   677     def find_command_position(
   678         : Option[Line.Node_Position] =
   678       id: Document_ID.Generic,
       
   679       offset: Symbol.Offset
       
   680     ): Option[Line.Node_Position] = {
   679       for ((node, command) <- find_command(id))
   681       for ((node, command) <- find_command(id))
   680       yield {
   682       yield {
   681         val name = command.node_name.node
   683         val name = command.node_name.node
   682         val sources_iterator =
   684         val sources_iterator =
   683           node.commands.iterator.takeWhile(_ != command).map(_.source) ++
   685           node.commands.iterator.takeWhile(_ != command).map(_.source) ++
   684             (if (offset == 0) Iterator.empty
   686             (if (offset == 0) Iterator.empty
   685              else Iterator.single(command.source(Text.Range(0, command.chunk.decode(offset)))))
   687              else Iterator.single(command.source(Text.Range(0, command.chunk.decode(offset)))))
   686         val pos = sources_iterator.foldLeft(Line.Position.zero)(_.advance(_))
   688         val pos = sources_iterator.foldLeft(Line.Position.zero)(_.advance(_))
   687         Line.Node_Position(name, pos)
   689         Line.Node_Position(name, pos)
   688       }
   690       }
       
   691     }
   689 
   692 
   690     def current_command(other_node_name: Node.Name, offset: Text.Offset): Option[Command] =
   693     def current_command(other_node_name: Node.Name, offset: Text.Offset): Option[Command] =
   691       if (other_node_name.is_theory) {
   694       if (other_node_name.is_theory) {
   692         val other_node = get_node(other_node_name)
   695         val other_node = get_node(other_node_name)
   693         val iterator = other_node.command_iterator(revert(offset) max 0)
   696         val iterator = other_node.command_iterator(revert(offset) max 0)