From: Alexis Laferrière Date: Sat, 1 Aug 2015 13:32:32 +0000 (-0400) Subject: contrib/jwrapper: compute the methods introduced by each classes X-Git-Tag: v0.7.8~112^2~14 X-Git-Url: http://nitlanguage.org contrib/jwrapper: compute the methods introduced by each classes Signed-off-by: Alexis Laferrière --- diff --git a/contrib/jwrapper/src/model.nit b/contrib/jwrapper/src/model.nit index d288658..e47b76f 100644 --- a/contrib/jwrapper/src/model.nit +++ b/contrib/jwrapper/src/model.nit @@ -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