From 9b46ad32c897b31040bc98bdcb5722df3ba53687 Mon Sep 17 00:00:00 2001 From: Stefan Lage Date: Fri, 28 Jun 2013 14:20:24 -0400 Subject: [PATCH] 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 --- src/model_utils.nit | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 -- 1.7.9.5