It is a specific class (instead of using a Array) to track the parent/child relation when nodes are added or removed
nitc :: ANodes :: accept_pretty_printer
nitc :: ANodes :: defaultinit
nitc :: ANodes :: hook_remove
nitc :: ANodes :: replace_child
nitc :: ANodes :: unsafe_add_all
Used in parent constructor to fill elementsnitc $ ANodes :: reverse_iterator
Gets an iterator starting at the end and going backwardscore :: Collection :: CONCURRENT
Type of the concurrent variant of this collectionserialization :: 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 MessagePacknitc :: ANodes :: accept_pretty_printer
serialization :: 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.
core :: Collection :: combinations
Allr
-length combinations on self (in same order) without repeated elements.
core :: Collection :: combinations_with_replacement
Allr
-length combination on self (in same order) with repeated elements.
serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
core :: Cloneable :: defaultinit
core :: Object :: defaultinit
nitc :: ANodes :: defaultinit
core :: SequenceRead :: defaultinit
core :: SimpleCollection :: defaultinit
core :: Sequence :: defaultinit
core :: Collection :: defaultinit
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
core :: SequenceRead :: get_or_default
Try to get an element, returndefault
if the index
is invalid.
core :: SequenceRead :: get_or_null
Try to get an element, returnnull
if the index
is invalid.
core :: Collection :: has_all
Does the collection contain at least each element ofother
?
core :: Collection :: has_any
Does the collection contain at least one element ofother
?
core :: Collection :: has_exactly
Does the collection contain exactly all the elements ofother
?
nitc :: ANodes :: hook_remove
core :: SequenceRead :: index_of_from
The index of the first occurrence ofitem
, starting from pos.
core :: Sequence :: insert_all
Insert all elements at a given position, following elements are shifted.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.
core :: SequenceRead :: iterator_from
Gets a new Iterator starting at positionpos
core :: SequenceRead :: last_index_of
The index of the last occurrence ofitem
.
core :: SequenceRead :: last_index_of_from
The index of the last occurrence ofitem
starting from pos
and decrementing.
core :: SequenceRead :: modulo_index
Returns the real index for a modulo index.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).core :: Collection :: permutations
Allr
-length permutations on self (all possible ordering) without repeated elements.
core :: Collection :: product
Cartesian product, overr
times self
.
core :: RemovableCollection :: remove
Remove an occurrence ofitem
core :: RemovableCollection :: remove_all
Remove all occurrences ofitem
nitc :: ANodes :: replace_child
core :: SequenceRead :: reverse_iterator
Gets an iterator starting at the end and going backwardscore :: SequenceRead :: reverse_iterator_from
Gets an iterator on the chars of self starting frompos
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
)
core :: Collection :: serialize_to_pure_json
Utility to serialize a normal Json arraycore :: Collection :: to_concurrent
Wrapsself
in a thread-safe collection
core :: Collection :: to_counter
Create and fill up a counter with the elements of `self.core :: Collection :: to_curlslist
Convert Collection[String] to CURLSListserialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
core :: Collection :: to_shuffle
Return a new array made of elements in a random order.nitc :: ANodes :: unsafe_add_all
Used in parent constructor to fill elementsSerializer::serialize
# A sequence of nodes
# It is a specific class (instead of using a Array) to track the parent/child relation when nodes are added or removed
class ANodes[E: ANode]
super Sequence[E]
private var parent: ANode
private var items = new Array[E]
redef fun iterator do return items.iterator
redef fun reverse_iterator do return items.reverse_iterator
redef fun length do return items.length
redef fun is_empty do return items.is_empty
redef fun push(e)
do
hook_add(e)
items.push(e)
end
redef fun pop
do
var res = items.pop
hook_remove(res)
return res
end
redef fun unshift(e)
do
hook_add(e)
items.unshift(e)
end
redef fun shift
do
var res = items.shift
hook_remove(res)
return res
end
redef fun has(e)
do
return items.has(e)
end
redef fun [](index)
do
return items[index]
end
redef fun []=(index, e)
do
hook_remove(self[index])
hook_add(e)
items[index]=e
end
redef fun remove_at(index)
do
hook_remove(items[index])
items.remove_at(index)
end
private fun hook_add(e: E)
do
#assert e.parent == null
e.parent = parent
end
private fun hook_remove(e: E)
do
assert e.parent == parent
e.parent = null
end
# Used in parent constructor to fill elements
private fun unsafe_add_all(nodes: Collection[Object])
do
var parent = self.parent
for n in nodes do
assert n isa E
add n
n.parent = parent
end
end
private fun replace_child(old_child: ANode, new_child: nullable ANode): Bool
do
var parent = self.parent
for i in [0..length[ do
if self[i] == old_child then
if new_child != null then
assert new_child isa E
self[i] = new_child
new_child.parent = parent
else
self.remove_at(i)
end
return true
end
end
return false
end
private fun visit_all(v: Visitor)
do
for n in self do v.enter_visit(n)
end
end
src/parser/parser_nodes.nit:248,1--343,3
redef class ANodes[E]
private fun accept_pretty_printer(v: PrettyPrinterVisitor) do
for e in self do
var e_can_inline = v.can_inline(e)
if v.current_token isa TComma then v.skip
if e != first then
if not e_can_inline then
v.add ","
v.forcen
v.indent += 1
v.addt
v.indent -= 1
else
v.add ", "
end
end
v.visit e
end
end
end
src/pretty.nit:295,1--317,3