src/Pure/PIDE/document.scala
changeset 38361 b609d0b271fa
parent 38356 443fb83a21e8
child 38363 af7f41a8a0a8
equal deleted inserted replaced
38360:53224a4d2f0e 38361:b609d0b271fa
    99     val document: Document
    99     val document: Document
   100     val node: Document.Node
   100     val node: Document.Node
   101     val is_outdated: Boolean
   101     val is_outdated: Boolean
   102     def convert(offset: Int): Int
   102     def convert(offset: Int): Int
   103     def revert(offset: Int): Int
   103     def revert(offset: Int): Int
   104     def state(command: Command): State
   104     def state(command: Command): Command.State
   105   }
   105   }
   106 
   106 
   107   object Change
   107   object Change
   108   {
   108   {
   109     val init = new Change(NO_ID, None, Nil, Future.value(Nil, Document.init))
   109     val init = new Change(NO_ID, None, Nil, Future.value(Nil, Document.init))
   144         val document = stable.get.join_document
   144         val document = stable.get.join_document
   145         val node = document.nodes(name)
   145         val node = document.nodes(name)
   146         val is_outdated = !(pending_edits.isEmpty && latest == stable.get)
   146         val is_outdated = !(pending_edits.isEmpty && latest == stable.get)
   147         def convert(offset: Int): Int = (offset /: edits)((i, edit) => edit.convert(i))
   147         def convert(offset: Int): Int = (offset /: edits)((i, edit) => edit.convert(i))
   148         def revert(offset: Int): Int = (offset /: reverse_edits)((i, edit) => edit.revert(i))
   148         def revert(offset: Int): Int = (offset /: reverse_edits)((i, edit) => edit.revert(i))
   149         def state(command: Command): State = document.current_state(command)
   149         def state(command: Command): Command.State = document.current_state(command)
   150       }
   150       }
   151     }
   151     }
   152   }
   152   }
   153 
   153 
   154 
   154 
   279   {
   279   {
   280     assignment.fulfill(tmp_states ++ new_states)
   280     assignment.fulfill(tmp_states ++ new_states)
   281     tmp_states = Map()
   281     tmp_states = Map()
   282   }
   282   }
   283 
   283 
   284   def current_state(cmd: Command): State =
   284   def current_state(cmd: Command): Command.State =
   285   {
   285   {
   286     require(assignment.is_finished)
   286     require(assignment.is_finished)
   287     (assignment.join).get(cmd) match {
   287     (assignment.join).get(cmd) match {
   288       case Some(cmd_state) => cmd_state.current_state
   288       case Some(cmd_state) => cmd_state.current_state
   289       case None => new State(cmd, Command.Status.UNDEFINED, 0, Nil, cmd.empty_markup)
   289       case None => new Command.State(cmd, Command.Status.UNDEFINED, 0, Nil, cmd.empty_markup)
   290     }
   290     }
   291   }
   291   }
   292 }
   292 }