contrib/jwrapper: compute the methods introduced by each classes
authorAlexis Laferrière <alexis.laf@xymus.net>
Sat, 1 Aug 2015 13:32:32 +0000 (09:32 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 5 Aug 2015 01:41:50 +0000 (21:41 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/jwrapper/src/model.nit

index d288658..e47b76f 100644 (file)
@@ -172,6 +172,9 @@ class JavaClass
        # Methods of this class organized by their name
        var methods = new MultiHashMap[String, JavaMethod]
 
+       # Methods signatures introduced by this class
+       var local_intro_methods = new MultiHashMap[String, JavaMethod]
+
        # Constructors of this class
        var constructors = new Array[JavaConstructor]
 
@@ -367,6 +370,34 @@ class JavaModel
                                class_hierarchy.add_edge(java_class, super_class)
                        end
                end
+
+               # Flatten classes from the top one (Object like)
+               var linearized = class_hierarchy.linearize(class_hierarchy)
+
+               # Methods intro
+               for java_class in linearized do
+                       var in_hierarchy = class_hierarchy[java_class]
+                       var greaters = in_hierarchy.greaters
+
+                       for mid, signatures in java_class.methods do
+                               for signature in signatures do
+                                       if signature.is_static then continue
+
+                                       # Check if this signature exists in a parent
+                                       for parent in greaters do
+                                               if parent == java_class then continue
+
+                                               if not parent.methods.keys.has(mid) then continue
+
+                                               if parent.methods[mid].has(signature) then continue label
+                                       end
+
+                                       # This is an introduction! register it
+                                       java_class.local_intro_methods[mid].add signature
+
+                               end label
+                       end
+               end
        end
 end