model_utils: add attributes count (local + inherited) in MClass
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 25 Mar 2014 21:25:05 +0000 (17:25 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 25 Apr 2014 01:56:59 +0000 (21:56 -0400)
src/model_utils.nit

index 5347128..f893b8d 100644 (file)
@@ -175,6 +175,14 @@ redef class MClass
                return set
        end
 
+       # the set of all accessible mattributes for this class
+       fun all_mattributes(mainmodule: MModule, min_visibility: MVisibility): Set[MAttribute] do
+               var set = new HashSet[MAttribute]
+               for mprop in all_mproperties(mainmodule, min_visibility) do
+                       if mprop isa MAttribute then set.add(mprop)
+               end
+               return set
+       end
 
        # Get the list of locally refined methods in 'self'.
        fun redef_methods: Set[MMethod] do
@@ -247,6 +255,7 @@ redef class MClass
        end
 end
 
+
 # Sorters
 
 # Sort mmodules by their name