model_utils: extract modifiers from mpropdef
authorAlexandre Terrasa <alexandre@moz-code.org>
Sat, 3 May 2014 05:56:55 +0000 (01:56 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 7 May 2014 06:03:10 +0000 (02:03 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/model_utils.nit

index 03ce173..a8be901 100644 (file)
@@ -304,6 +304,35 @@ redef class MClassDef
        end
 end
 
+redef class MPropDef
+       # modifiers are keywords like redef, private etc.
+       fun modifiers: Array[String] do
+               var res = new Array[String]
+               if not is_intro then
+                       res.add "redef"
+               else
+                       res.add mproperty.visibility.to_s
+               end
+               var mprop = self
+               if mprop isa MVirtualTypeDef then
+                       res.add "type"
+               else if mprop isa MMethodDef then
+                       if mprop.is_abstract then
+                               res.add "abstract"
+                       else if mprop.is_intern then
+                               res.add "intern"
+                       end
+                       if mprop.mproperty.is_init then
+                               res.add "init"
+                       else
+                               res.add "fun"
+                       end
+               end
+               return res
+       end
+end
+
+
 # Sorters
 
 # Sort mmodules by their name