src/Pure/PIDE/command.scala
changeset 44385 e7fdb008aa7d
parent 44384 8f6054a63f96
child 44474 681447a9ffe5
equal deleted inserted replaced
44384:8f6054a63f96 44385:e7fdb008aa7d
    87 
    87 
    88 
    88 
    89   /* perspective */
    89   /* perspective */
    90 
    90 
    91   type Perspective = List[Command]  // visible commands in canonical order
    91   type Perspective = List[Command]  // visible commands in canonical order
       
    92 
       
    93   def equal_perspective(p1: Perspective, p2: Perspective): Boolean =
       
    94   {
       
    95     require(p1.forall(_.is_defined))
       
    96     require(p2.forall(_.is_defined))
       
    97     p1.length == p2.length &&
       
    98       (p1.iterator zip p2.iterator).forall({ case (c1, c2) => c1.id == c2.id })
       
    99   }
    92 }
   100 }
    93 
   101 
    94 
   102 
    95 class Command(
   103 class Command(
    96     val id: Document.Command_ID,
   104     val id: Document.Command_ID,
    97     val span: List[Token])
   105     val span: List[Token])
    98 {
   106 {
    99   /* classification */
   107   /* classification */
   100 
   108 
       
   109   def is_defined: Boolean = id != Document.no_id
       
   110 
   101   def is_command: Boolean = !span.isEmpty && span.head.is_command
   111   def is_command: Boolean = !span.isEmpty && span.head.is_command
   102   def is_ignored: Boolean = span.forall(_.is_ignored)
   112   def is_ignored: Boolean = span.forall(_.is_ignored)
   103   def is_malformed: Boolean = !is_command && !is_ignored
   113   def is_malformed: Boolean = !is_command && !is_ignored
   104 
       
   105   def is_unparsed = id == Document.no_id
       
   106 
   114 
   107   def name: String = if (is_command) span.head.content else ""
   115   def name: String = if (is_command) span.head.content else ""
   108   override def toString =
   116   override def toString =
   109     id + "/" + (if (is_command) name else if (is_ignored) "IGNORED" else "MALFORMED")
   117     id + "/" + (if (is_command) name else if (is_ignored) "IGNORED" else "MALFORMED")
   110 
   118