privatedef add_markup(
m: Text.Markup,
chunk_name: Symbol.Text_Chunk.Name = Symbol.Text_Chunk.Default,
status: Boolean = false
): State = { val markups1 = if (status || Document_Status.Command_Status.liberal_elements(m.info.name))
markups.add(Markup_Index(true, chunk_name), m) else markups val markups2 = markups1.add(Markup_Index(false, chunk_name), m) new State(command, results, exports, markups2, document_status)
}
def accumulate(
now: Date,
self_id: Document_ID.Generic => Boolean,
other_id: (Document.Node.Name, Document_ID.Generic) =>
Option[(Symbol.Text_Chunk.Id, Symbol.Text_Chunk)],
message: XML.Elem,
cache: XML.Cache): State =
message match { case XML.Elem(markup@Markup(Markup.Command_Timing.name, _), _) =>
add_status(now, markup)
case XML.Elem(Markup(Markup.STATUS, _), msgs) => if (command.span.is_theory) this else {
msgs.foldLeft(this) { case (state, msg) =>
msg match { case elem @ XML.Elem(markup, Nil) =>
state.
add_status(now, markup).
add_markup(Text.Info(command.core_range, elem), status = true) case _ =>
Output.warning("Ignored status message: " + msg)
state
}
}
}
case XML.Elem(Markup(Markup.REPORT, atts0), msgs) =>
msgs.foldLeft(this) { case (state, msg) => def bad(): Unit = Output.warning("Ignored report message: " + msg)
msg match { case XML.Elem(Markup(name, atts), args) =>
command.reported_position(atts) orElse command.reported_position(atts0) match { case Some((id, chunk_name, target_range)) => val target = if (self_id(id) && command.chunks.isDefinedAt(chunk_name))
Some((chunk_name, command.chunks(chunk_name))) elseif (chunk_name == Symbol.Text_Chunk.Default)
other_id(command.node_name, id) else None
(target, target_range) match { case (Some((target_name, target_chunk)), Some(symbol_range)) if !symbol_range.is_singularity =>
target_chunk.incorporate(symbol_range) match { case Some(range) => val props = atts.filterNot(Markup.position_property) val elem = cache.elem(XML.Elem(Markup(name, props), args))
state.add_markup(Text.Info(range, elem), chunk_name = target_name) case None => bad(); state
} case _ =>
// silently ignore excessive reports
state
}
case _ => bad(); state
} case _ => bad(); state
}
}
case XML.Elem(Markup(name, props), body) =>
props match { case Markup.Serial(i) => val markup_message = cache.elem(Protocol.make_message(body, name, props = props)) val message_markup = cache.elem(XML.elem(Markup(name, Markup.Serial(i))))
var st = add_result(now, i -> markup_message) if (Protocol.is_inlined(message)) { for {
(chunk_name, chunk) <- command.chunks.iterator
range <- command.message_positions(self_id, chunk_name, chunk, message)
} st = st.add_markup(Text.Info(range, message_markup), chunk_name = chunk_name)
}
st
case _ =>
Output.warning("Ignored message without serial number: " + message) this
}
}
}
object Perspective { val empty: Perspective = Perspective(Nil)
}
sealedcaseclass Perspective(
commands: List[Command] // visible commands in canonical order
) { def is_empty: Boolean = commands.isEmpty
def same(that: Perspective): Boolean = { val cmds1 = this.commands val cmds2 = that.commands
require(!cmds1.exists(_.is_undefined), "cmds1 not defined")
require(!cmds2.exists(_.is_undefined), "cmds2 not defined")
cmds1.length == cmds2.length &&
(cmds1.iterator zip cmds2.iterator).forall({ case (c1, c2) => c1.id == c2.id })
}
}
/* blobs: inlined errors and auxiliary files */
def blobs_info(
resources: Resources,
syntax: Outer_Syntax,
get_blob: Document.Node.Name => Option[Document.Blobs.Item],
can_import: Document.Node.Name => Boolean,
node_name: Document.Node.Name,
span: Command_Span.Span
): Blobs_Info = {
span.name match {
// inlined errors case Thy_Header.THEORY => val reader = span.content_reader val header = resources.check_thy(node_name, span.content_reader) val imports_pos = header.imports_pos val raw_imports = try { val read_imports = Thy_Header.read(node_name, reader).imports.map(_._1) if (imports_pos.length == read_imports.length) read_imports else error("")
} catch { case _: Throwable => List.fill(header.imports.length)("") }
val errors = for { ((import_name, pos), s) <- imports_pos zip raw_imports if !can_import(import_name) } yield { val completion = if (Url.is_base_name(s)) resources.complete_import_name(node_name, s) else Nil "Bad theory import " +
Markup.Path(import_name.node).markup(quote(import_name.toString)) +
Position.here(pos) + Completion.report_theories(pos, completion)
}
Blobs_Info.errors(errors)
// auxiliary files case _ => val loaded_files = span.loaded_files(syntax) val blobs =
loaded_files.files.map(file =>
(Exn.capture { val src_path = Path.explode(file) val name = Document.Node.Name(resources.append_path(node_name.master_dir, src_path)) val content = get_blob(name).map(blob => (blob.bytes.sha1_digest, blob.chunk))
Blob(0, name, src_path, content)
}).user_error)
Blobs_Info(blobs, index = loaded_files.index)
}
}
}
finalclass Command private( val id: Document_ID.Command, val node_name: Document.Node.Name, val blobs_info: Command.Blobs_Info, val span: Command_Span.Span, val source: String, val init_results: Command.Results, val init_exports: Command.Exports, val init_markups: Command.Markups, val init_document_status: Document_Status.Command_Status
) { overridedef toString: String = id.toString + "/" + span.kind.toString
def theory_parents(resources: Resources): List[Document.Node.Name] = if (span.name == Thy_Header.THEORY) { try { val header = Thy_Header.read(node_name, span.content_reader) for ((s, _) <- header.imports) yield { try { resources.import_name(node_name, s) } catch { case ERROR(_) => Document.Node.Name.empty }
}
} catch { case ERROR(_) => Nil }
} else Nil
/* reported positions */
def reported_position(
pos: Position.T
) : Option[(Document_ID.Generic, Symbol.Text_Chunk.Name, Option[Symbol.Range])] = {
pos match { case Position.Id(id) => val chunk_name =
pos match { case Position.File(name) if name != node_name.node =>
Symbol.Text_Chunk.File(name) case _ => Symbol.Text_Chunk.Default
}
Some((id, chunk_name, Position.Range.unapply(pos))) case _ => None
}
}
def message_positions(
self_id: Document_ID.Generic => Boolean,
chunk_name: Symbol.Text_Chunk.Name,
chunk: Symbol.Text_Chunk,
message: XML.Elem
): Set[Text.Range] = { def elem(props: Properties.T, set: Set[Text.Range]): Set[Text.Range] =
reported_position(props) match { case Some((id, name, reported_range)) if self_id(id) && name == chunk_name => val opt_range =
reported_range orElse { if (name == Symbol.Text_Chunk.Default)
Position.Range.unapply(span.position) else None
}
opt_range match { case Some(symbol_range) =>
chunk.incorporate(symbol_range) match { case Some(range) => set + range case _ => set
} case None => set
} case _ => set
} def tree(set: Set[Text.Range], t: XML.Tree): Set[Text.Range] =
t match { case XML.Wrapped_Elem(Markup(name, props), _, body) =>
body.foldLeft(if (Rendering.position_elements(name)) elem(props, set) else set)(tree) case XML.Elem(Markup(name, props), body) =>
body.foldLeft(if (Rendering.position_elements(name)) elem(props, set) else set)(tree) case XML.Text(_) => set
}
val set = tree(Set.empty, message) if (set.isEmpty) elem(message.markup.properties, set) else set
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.17Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.