nitx: is now able to look for generic types
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 30 Aug 2013 02:53:44 +0000 (22:53 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 30 Aug 2013 02:53:44 +0000 (22:53 -0400)
ex:
"Array" # return class doc for Array
"Array[String]" # return doc for class Array
"return: Array" # return doc for mmethods returning the static type Array
"return: Array[String]" # return only doc for mmethods returning the static type Array[String]

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/nitx.nit

index dcf71d2..7c441ed 100644 (file)
@@ -401,31 +401,30 @@ class NitIndex
        end
 
        private fun seek_returns(entry: String): List[MProperty] do
-               # TODO how to match with generic types?
                var matches = new List[MProperty]
                for mprop in model.mproperties do
                        var intro = mprop.intro
                        if intro isa MMethodDef then
-                               if intro.msignature.return_mtype != null and intro.msignature.return_mtype.to_s == entry then matches.add(mprop)
+                               if intro.msignature.return_mtype != null and intro.msignature.return_mtype.to_console.has_prefix(entry) then matches.add(mprop)
                        else if intro isa MAttributeDef then
-                               if intro.static_mtype.to_s == entry then matches.add(mprop)
+                               if intro.static_mtype.to_console.has_prefix(entry) then matches.add(mprop)
                        end
                end
                return matches
        end
 
        private fun seek_params(entry: String): List[MProperty] do
-               # TODO how to match with generic types?
                var matches = new List[MProperty]
                for mprop in model.mproperties do
                        var intro = mprop.intro
                        if intro isa MMethodDef then
                                var mparameters = intro.msignature.mparameters
                                for mparameter in mparameters do
-                                       if mparameter.mtype.to_s == entry then matches.add(mprop)
+                                       print mparameter.mtype.to_console
+                                       if mparameter.mtype.to_console.has_prefix(entry) then matches.add(mprop)
                                end
                        else if intro isa MAttributeDef then
-                               if intro.static_mtype.to_s == entry then matches.add(mprop)
+                               if intro.static_mtype.to_console.has_prefix(entry) then matches.add(mprop)
                        end
                end
                return matches