Merge: Fix warnings in the JSON, SAX and SAXophoNit libraries and in the `neo_doxygen...
authorJean Privat <jean@pryen.org>
Sat, 29 Nov 2014 01:01:33 +0000 (20:01 -0500)
committerJean Privat <jean@pryen.org>
Sun, 30 Nov 2014 01:35:40 +0000 (20:35 -0500)
Fix all the warnings in the following directories:

* `/lib/json`
* `/lib/sax`
* `/lib/saxophonit`
* `/contrib/neo_doxygen`

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #946
Reviewed-by: Jean Privat <jean@pryen.org>

21 files changed:
contrib/neo_doxygen/src/doxml/compounddef.nit
contrib/neo_doxygen/src/doxml/doc.nit
contrib/neo_doxygen/src/doxml/language_specific.nit
contrib/neo_doxygen/src/doxml/listener.nit
contrib/neo_doxygen/src/model/class_compound.nit
contrib/neo_doxygen/src/model/graph.nit
contrib/neo_doxygen/src/model/location.nit
contrib/neo_doxygen/src/model/member.nit
contrib/neo_doxygen/src/tests/neo_doxygen_dump.nit
lib/json/dynamic.nit
lib/json/static.nit
lib/sax/helpers/attributes_impl.nit
lib/sax/helpers/namespace_support.nit
lib/sax/helpers/test_namespace_support.nit
lib/sax/input_source.nit
lib/saxophonit/.gitattributes [new file with mode: 0644]
lib/saxophonit/lexer.nit
lib/saxophonit/reader_model.nit
lib/saxophonit/saxophonit.nit
lib/saxophonit/test_testing.nit
lib/saxophonit/testing.nit

index 4cd42ca..64a301d 100644 (file)
@@ -22,7 +22,9 @@ import more_collections
 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
 
index 610bbf0..da9f09e 100644 (file)
@@ -21,7 +21,8 @@ import listener
 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
index 10757ea..fc03b0f 100644 (file)
@@ -131,7 +131,6 @@ abstract class SourceLanguage
 
                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
index 26de0d2..40d021f 100644 (file)
@@ -36,6 +36,7 @@ abstract class DoxmlListener
                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,
@@ -61,6 +62,9 @@ abstract class DoxmlListener
        # 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
@@ -197,7 +201,10 @@ 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
index 47a95f9..dd73976 100644 (file)
@@ -109,8 +109,16 @@ end
 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
@@ -119,6 +127,14 @@ class ClassDef
                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
@@ -127,6 +143,7 @@ class ClassDef
                end
        end
 
+       # Append the specified member.
        fun declare_member(member: Member) do
                var full_name = self["full_name"]
 
@@ -193,6 +210,7 @@ class ClassType
        # 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
index ffd4eec..98244eb 100644 (file)
@@ -20,7 +20,10 @@ import location
 
 # 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.
@@ -31,14 +34,17 @@ class NeoGraph
        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]
@@ -46,11 +52,11 @@ class ProjectGraph
        # 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)
@@ -85,10 +91,10 @@ abstract class Entity
        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
 
index 8652577..f025a12 100644 (file)
@@ -21,10 +21,19 @@ import neo4j
 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
index f29892e..58c25a4 100644 (file)
@@ -92,6 +92,15 @@ abstract class Member
                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
@@ -174,6 +183,7 @@ class UnknownMember
        redef fun put_edges do end
 end
 
+# A local definition of a method.
 class Method
        super Member
 
@@ -216,6 +226,7 @@ class Method
        end
 end
 
+# A local definition of an attribute.
 class Attribute
        super Member
 
@@ -256,9 +267,19 @@ abstract class MemberIntroducer
                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.
index 326a030..f52cd01 100644 (file)
@@ -36,6 +36,9 @@ redef class NeoDoxygenCommand
        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
 
index 2f73fea..1ee3ce7 100644 (file)
 # 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?
index 29e5c22..bb578fd 100644 (file)
@@ -319,7 +319,8 @@ end
 # 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
@@ -348,7 +349,8 @@ redef class Nvalue_null
 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
@@ -398,7 +400,8 @@ redef class Nvalue_object
 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
@@ -415,8 +418,11 @@ redef class Nmembers_head
 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
@@ -433,7 +439,8 @@ 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
index ce84faf..97f16d8 100644 (file)
@@ -30,7 +30,7 @@ import sax::attributes
 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
index e682321..ce8682e 100644 (file)
@@ -74,8 +74,8 @@ class NamespaceSupport
        # 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
@@ -398,38 +398,35 @@ end
 # 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.
        #
@@ -649,7 +646,7 @@ private class 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]
index 5798c33..3892e12 100644 (file)
@@ -132,7 +132,6 @@ class TestNamespaceSupport
        end
 
        fun test_prefixes do
-               var subject = sample
                var res = sample.prefixes
 
                assert 3 == res.length else
@@ -171,7 +170,6 @@ class TestNamespaceSupport
        end
 
        fun test_declared_prefixes do
-               var subject = sample
                var res = sample.declared_prefixes
 
                assert 2 == res.length else
index b3a27d8..cdf7afb 100644 (file)
@@ -41,8 +41,6 @@ module sax::input_source
 # 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,
diff --git a/lib/saxophonit/.gitattributes b/lib/saxophonit/.gitattributes
new file mode 100644 (file)
index 0000000..a1c762f
--- /dev/null
@@ -0,0 +1 @@
+/lexer.nit     diff
index 4f77ab8..07277ef 100644 (file)
@@ -20,8 +20,14 @@ import reader_model
 # 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
index ff2299a..a5e1365 100644 (file)
@@ -36,6 +36,7 @@ class XophonReaderModel
        # “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
 
 
index 1860db7..02e6104 100644 (file)
@@ -125,7 +125,6 @@ class XophonReader
        end
 
        redef fun parse(input: InputSource) do
-               var stream: IStream
                var system_id: nullable MaybeError[String, Error] = null
                model.locator = new SAXLocatorImpl
 
@@ -182,7 +181,6 @@ class XophonReader
 
        # Expect a `document` production.
        private fun expect_document: Bool do
-               var success = true
                var got_doctype = false
                var got_element = false
 
index 3bedb3b..c2ace75 100644 (file)
@@ -35,8 +35,8 @@ class TestSaxEventLogger
        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
 
index c940b15..a3f4b15 100644 (file)
@@ -40,7 +40,7 @@ class SAXEventLogger
        # 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
@@ -190,8 +190,6 @@ class SAXEventLogger
        # 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,
@@ -547,10 +545,10 @@ abstract class SAXTestSuite
        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