annotation: move collect_annotations_on_modules from android_annotations to annotation
authorJean Privat <jean@pryen.org>
Thu, 31 Jul 2014 03:27:51 +0000 (23:27 -0400)
committerJean Privat <jean@pryen.org>
Thu, 31 Jul 2014 12:50:11 +0000 (08:50 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/android_annotations.nit
src/annotation.nit

index 799a548..3e7e604 100644 (file)
@@ -100,21 +100,6 @@ redef class ModelBuilder
                return project
        end
 
-       # Recursively collect all annotations by name in `mmodule` and its importations (direct and indirect)
-       private fun collect_annotations_on_modules(name: String, mmodule: MModule): Array[AAnnotation]
-       do
-               var annotations = new Array[AAnnotation]
-               for mmod in mmodule.in_importation.greaters do
-                       if not mmodule2nmodule.keys.has(mmod) then continue
-                       var amod = mmodule2nmodule[mmod]
-                       var module_decl = amod.n_moduledecl
-                       if module_decl == null then continue
-                       var aas = module_decl.get_annotations(name)
-                       annotations.add_all aas
-               end
-               return annotations
-       end
-
        # Get an annotation by name from `mmodule` and its super modules. Will recursively search
        # in imported module to find the "latest" declaration and detects priority conflicts.
        private fun priority_annotation_on_modules(name: String, mmodule: MModule): nullable AAnnotation
index a0d397e..36fef4c 100644 (file)
@@ -133,3 +133,21 @@ redef class AAtArg
                return nexpr.n_id.text
        end
 end
+
+redef class ModelBuilder
+       # Collect all annotations by `name` assocated to `mmodule` and its imported modules.
+       # Note that visibility is not considered.
+       fun collect_annotations_on_modules(name: String, mmodule: MModule): Array[AAnnotation]
+       do
+               var annotations = new Array[AAnnotation]
+               for mmod in mmodule.in_importation.greaters do
+                       if not mmodule2nmodule.keys.has(mmod) then continue
+                       var amod = mmodule2nmodule[mmod]
+                       var module_decl = amod.n_moduledecl
+                       if module_decl == null then continue
+                       var aas = module_decl.get_annotations(name)
+                       annotations.add_all aas
+               end
+               return annotations
+       end
+end