class CompoundDefListener
super EntityDefListener
+ # The defined compound.
var compound: Compound is writable, noinit
+
private var memberdef: MemberDefListener is noinit
private var param_listener: TypeParamListener is noinit
class DocListener
super TextListener
- var doc: JsonArray = new JsonArray is writable
+ # The read documentation.
+ var doc = new JsonArray is writable
redef fun end_listening do
super
var content = text_array.last.as(String).r_trim
var link = text.links.first
- var found = false
if link == null and content.has_suffix(suffix) then
content = content.substring(0, content.length - suffix.length).r_trim
self.locator = locator
end
+ # The Doxygen’s namespace IRI.
protected fun dox_uri: String do return ""
redef fun start_element(uri: String, local_name: String, qname: String,
# See `ContentHandler.start_element` for the description of the parameters.
protected fun end_dox_element(local_name: String) do end
+ # Get the boolean value of the specified attribute.
+ #
+ # `false` by default.
protected fun get_bool(atts: Attributes, local_name: String): Bool do
return get_optional(atts, local_name, "no") == "yes"
end
class TextListener
super StackableListener
+ # The read text.
protected var buffer: Buffer = new FlatBuffer
+
+ # Is the last read chunk was ignorable white space?
private var sp: Bool = false
redef fun listen_until(uri: String, local_name: String) do
class ClassDef
super CodeBlock
+ # The defined class.
var class_compound: ClassCompound
+
+ # The `model_id` of the base classes.
var supers: SimpleCollection[String] = new Array[String]
+
+ # The set of the introduced/redefined members.
+ #
+ # To ensure that the `full_name` of each member is correctly set,
+ # `declare_member` should be used to add each member.
var members: SimpleCollection[Member] = new Array[Member]
init do
self["is_intro"] = true
end
+ # Declare a base compound (usually, a base class).
+ #
+ # Parameters:
+ #
+ # * `id`: `model_id` of the base compound. May be empty.
+ # * `full_name`: qualified name of the base compound. May be empty.
+ # * `prot`: visibility (proctection) of the relationship.
+ # * `virt`: level of virtuality of the relationship.
fun declare_super(id: String, full_name: String, prot: String,
virt: String) do
# TODO prot, virt, full_name
end
end
+ # Append the specified member.
fun declare_member(member: Member) do
var full_name = self["full_name"]
# Return the number of arguments.
fun arity: Int do return arguments.length
+ # Is the class generic?
fun is_generic: Bool do return arity > 0
redef fun put_in_graph do
# A Neo4j graph.
class NeoGraph
+ # All the nodes in the graph.
var all_nodes: SimpleCollection[NeoNode] = new Array[NeoNode]
+
+ # All the edges in the graph.
var all_edges: SimpleCollection[NeoEdge] = new Array[NeoEdge]
# Add a relationship between two nodes.
end
end
-# The project’s graph.
+# A project’s graph.
class ProjectGraph
super NeoGraph
+ # The project’s name.
+ var project_name: String
+
# The node reperesenting the project.
#
# Once the project’s graph is initialized, this node must not be edited.
- var project: NeoNode = new NeoNode
+ var project = new NeoNode
# Entities by `model_id`.
var by_id: Map[String, Entity] = new HashMap[String, Entity]
# Initialize a new project graph using the specified project name.
#
# The specified name will label all nodes of the project’s graph.
- init(name: String) do
- project.labels.add(name)
+ init do
+ project.labels.add(project_name)
project.labels.add("MEntity")
project.labels.add("MProject")
- project["name"] = name
+ project["name"] = project_name
all_nodes.add(project)
var root = new RootNamespace(self)
var model_id: String = "" is writable
# Associated documentation.
- var doc: JsonArray = new JsonArray is writable
+ var doc = new JsonArray is writable
init do
- self.labels.add(graph.project["name"].to_s)
+ self.labels.add(graph.project_name)
self.labels.add("MEntity")
end
class Location
super Jsonable
+ # The file’s path.
var path: nullable String = null is writable
+
+ # The one-based index of the first line.
var line_start: Int = 1 is writable
+
+ # The one-based index of the last line.
var line_end: Int = 1 is writable
+
+ # The one-based column index of the first character.
var column_start: Int = 1 is writable
+
+ # The one-based column index of the last character.
var column_end: Int = 1 is writable
redef fun to_s: String do
end
end
+ # Get the visibility.
+ #
+ # Return `""` by default.
+ fun visibility: String do
+ var visibility = self["visibility"]
+ if visibility isa String then return visibility
+ return ""
+ end
+
redef fun name=(name: String) do
super
if introducer != null then
redef fun put_edges do end
end
+# A local definition of a method.
class Method
super Member
end
end
+# A local definition of an attribute.
class Attribute
super Member
self["visibility"] = "public"
end
+ # Set the visibility.
fun visibility=(visibility: String) do
self["visibility"] = visibility
end
+
+ # Get the visibility.
+ #
+ # Return `""` by default.
+ fun visibility: String do
+ var visibility = self["visibility"]
+ if visibility isa String then return visibility
+ return ""
+ end
end
# A `MProperty` node for a method.
redef fun create_store(url) do return new DebugStore
end
+# Dummy storage medium that write a debugging output to the standard output.
+#
+# For testing purposes only.
class DebugStore
super GraphStore
# See the License for the specific language governing permissions and
# limitations under the License.
-# Dynamic interface to read Json strings.
+# Dynamic interface to read JSON strings.
#
# `String::to_json_value` returns a `JsonValue` which can be queried
-# to get the underlying Json data. It can also be used as any Json types.
+# to get the underlying JSON data.
module dynamic
import error
private import static
+# Wraps a JSON value.
+#
+# Offer methods to query the type, to dynamicaly cast the underlying value and
+# to query elements (in case of a JSON object or a JSON array).
+#
+# Use `String::to_json_value` to get a `JsonValue` from a string.
class JsonValue
+
+ # The wrapped JSON value.
var value: nullable Object
# Is this value null?
# Redef parser
redef class Nvalue
- fun to_nit_object: nullable Jsonable is abstract
+ # The represented value.
+ private fun to_nit_object: nullable Jsonable is abstract
end
redef class Nvalue_number
end
redef class Nstring
- fun to_nit_string: String do
+ # The represented string.
+ private fun to_nit_string: String do
var res = new FlatBuffer
var i = 1
while i < text.length - 1 do
end
redef class Nmembers
- fun pairs: Array[Npair] is abstract
+ # All the key-value pairs.
+ private fun pairs: Array[Npair] is abstract
end
redef class Nmembers_tail
end
redef class Npair
- fun name: String do return n_string.to_nit_string
- fun value: nullable Jsonable do return n_value.to_nit_object
+ # The represented key.
+ private fun name: String do return n_string.to_nit_string
+
+ # The represented value.
+ private fun value: nullable Jsonable do return n_value.to_nit_object
end
redef class Nvalue_array
end
redef class Nelements
- fun items: Array[Nvalue] is abstract
+ # All the items.
+ private fun items: Array[Nvalue] is abstract
end
redef class Nelements_tail
class AttributesImpl
super Attributes
- private var data: Array[String] = new Array[String]
+ private var data = new Array[String]
redef var length: Int = 0
redef fun uri(index: Int): nullable String do
# to the `xmlns` prefix.
var nsdecl = "http://www.w3.org/xmlns/2000/"
- private var contexts: Array[Context] = new Array[Context].with_capacity(32)
- private var current_context: Context = new Context
+ private var contexts = new Array[Context].with_capacity(32)
+ private var current_context = new Context
private var context_position: Int = 0
init do
# from [SAX 2.0](http://www.saxproject.org).
private class Context
- private var empty: Collection[String] = new Array[String].with_capacity(0)
+ var empty: Collection[String] = new Array[String].with_capacity(0)
# `prefix` -> `uri`
- private var prefix_table: nullable Map[String, String] = null
+ var prefix_table: nullable Map[String, String] = null
# Cache of `process_name` for elements.
#
# `qname -> [uri, local_name, qname]`
- private var element_name_table: nullable Map[String, Array[String]] = null
+ var element_name_table: nullable Map[String, Array[String]] = null
# Cache of `process_name` for attributes.
#
# `qname -> [uri, local_name, qname]`
- private var attribute_name_table: nullable Map[String, Array[String]] = null
+ var attribute_name_table: nullable Map[String, Array[String]] = null
# Namespace in absence of prefix.
- private var default_ns: nullable String = null
+ var default_ns: nullable String = null
# Can we currently declare prefixes in this context?
var decls_ok: Bool = true is writable
# All prefixes declared in this context.
- private var declarations: nullable Array[String] = null
+ var declarations: nullable Array[String] = null
# Was `copy_tables` called since the last call to `parent=`?
- private var decl_seen: Bool = false
+ var decl_seen: Bool = false
# Parent context.
- private var p_parent: nullable Context = null
-
- init do
- end
+ var p_parent: nullable Context = null
# (Re)set the parent of this Namespace context.
#
#
# This class is optimized for the normal case where most
# elements do not contain Namespace declarations.
- private fun copy_tables do
+ fun copy_tables do
if prefix_table != null then
var old_prefix_table = prefix_table.as(not null)
prefix_table = new HashMap[String, String]
end
fun test_prefixes do
- var subject = sample
var res = sample.prefixes
assert 3 == res.length else
end
fun test_declared_prefixes do
- var subject = sample
var res = sample.declared_prefixes
assert 2 == res.length else
# from [SAX 2.0](http://www.saxproject.org).
class InputSource
- init do end
-
# Create a new input source with the specified system identifier.
#
# Applications may use `public_id=` to include a public identifier as well,
--- /dev/null
+/lexer.nit diff
# They both foward the cursor to the next byte on success, but only `expect`
# functions fire a fatal error on mismatch.
class XophonLexer
+
+ # The model.
var reader_model: XophonReaderModel
+
+ # The input to read from.
var input: IStream is writable
+
+ # Alias to `reader_model.locator`.
private var locator: SAXLocatorImpl is noinit
init do
# “Namespaces in XML”.
private var qname_re: Regex = "^[^:]+(:[^:]+)?$".to_re
+ # The locator that is used to indicate the current location.
var locator: nullable SAXLocatorImpl = null is writable
end
redef fun parse(input: InputSource) do
- var stream: IStream
var system_id: nullable MaybeError[String, Error] = null
model.locator = new SAXLocatorImpl
# Expect a `document` production.
private fun expect_document: Bool do
- var success = true
var got_doctype = false
var got_element = false
private var del_em: String is noinit
- private var a: SAXEventLogger = new SAXEventLogger
- private var b: SAXEventLogger = new SAXEventLogger
+ private var a = new SAXEventLogger
+ private var b = new SAXEventLogger
private var init_done: Bool = false
# order they fired (the oldest first). Two event loggers have equivalent
# logs if and only if they received the same events in the same order and
# with equivalent arguments.
- private var log: Array[Array[String]] = new Array[Array[String]]
+ private var log = new Array[Array[String]]
# http://xml.org/sax/properties/declaration-handler
private var decl_handler: nullable DeclHandler = null
# in the specified entry.
private fun diff_append_deletion(buf: Buffer, log: Array[Array[String]],
entry_index: Int, sorted_mismatches: Collection[Int]) do
- var sub_buf = new FlatBuffer
-
buf.append(term_deletion)
buf.append("< {entry_index}|")
diff_append_mismatch_entry(buf, log[entry_index], sorted_mismatches,
super TestSuite
# Logger of the expected event sequence.
- var expected: SAXEventLogger = new SAXEventLogger
+ var expected = new SAXEventLogger
# Logger of the actual event sequence.
- var actual: SAXEventLogger = new SAXEventLogger
+ var actual = new SAXEventLogger
# The tested SAX reader.
var reader: XMLReader is noinit