From: Stefan Lage Date: Fri, 28 Jun 2013 18:20:24 +0000 (-0400) Subject: model_utils: All modules concerned in a class X-Git-Tag: v0.6.1~73^2~5^2~72^2~33 X-Git-Url: http://nitlanguage.org model_utils: All modules concerned in a class Creating a function to all modules an submodules concerned in a class Signed-off-by: Stefan Lage --- diff --git a/src/model_utils.nit b/src/model_utils.nit index 7963eda..4d8d615 100644 --- a/src/model_utils.nit +++ b/src/model_utils.nit @@ -186,6 +186,25 @@ redef class MClass return mdls end + # Get the list of MModule concern in 'self' + fun concerns: HashMap[MModule, nullable List[MModule]] do + var hm = new HashMap[MModule, nullable List[MModule]] + for mmodule in mmodules do + var owner = mmodule.public_owner + if owner == null then + hm[mmodule] = null + else + if hm.has_key(owner) then + hm[owner].add(mmodule) + else + hm[owner] = new List[MModule] + hm[owner].add(mmodule) + end + end + end + return hm + end + fun is_class: Bool do return self.kind == concrete_kind or self.kind == abstract_kind end