nitc :: HLCode :: code_mirror_update
JavaScript code to update an existing codemirror editor.nitc :: HLCode :: defaultinit
nitc $ HLCode :: core_serialize_to
Actual serialization ofself
to serializer
serialization :: Serializable :: accept_inspect_serializer_core
serialization :: Serializable :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONserialization :: Serializable :: accept_msgpack_attribute_counter
Hook to customize the behavior of theAttributeCounter
serialization :: Serializable :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePackserialization :: Serializable :: add_to_bundle
Called by[]=
to dynamically choose the appropriate method according
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: HLCode :: code_mirror_update
JavaScript code to update an existing codemirror editor.serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
core :: Object :: defaultinit
nitc :: HLCode :: defaultinit
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
serialization :: Serializable :: serialize_to_or_delay
Accept references or force direct serialization (usingserialize_to
)
serialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
Serializer::serialize
# A standalone highlighted piece of code
class HLCode
super Serializable
# The highlighter used
var hl: HtmlightVisitor
# The raw code source
var content: String
# The pseudo source-file
var source: SourceFile
# JavaScript code to update an existing codemirror editor.
fun code_mirror_update: Template
do
var res = new Template
res.add """
function nitmessage() {
editor.operation(function(){
for (var i = 0; i < widgets.length; ++i)
editor.removeLineWidget(widgets[i]);
widgets.length = 0;
"""
for m in source.messages do
res.add """
var l = document.createElement("div");
l.className = "lint-error"
l.innerHTML = "<span class='glyphicon glyphicon-warning-sign lint-error-icon'></span> {{{m.text.html_escape}}}";
var w = editor.addLineWidget({{{m.location.line_start-1}}}, l);
widgets.push(w);
"""
end
res.add """});}"""
return res
end
redef fun core_serialize_to(v)
do
v.serialize_attribute("code", hl.html.write_to_string)
var msgs = new Array[Map[String, Serializable]]
for m in source.messages do
var o = new Map[String, Serializable]
msgs.add o
o["line"] = m.location.line_start-1
o["message"] = m.text
end
v.serialize_attribute("messages", msgs)
end
end
src/htmlight.nit:23,1--74,3