X-Git-Url: http://nitlanguage.org diff --git a/src/metrics/inheritance_metrics.nit b/src/metrics/inheritance_metrics.nit index 9e2c5d8..1287c0f 100644 --- a/src/metrics/inheritance_metrics.nit +++ b/src/metrics/inheritance_metrics.nit @@ -17,20 +17,18 @@ # Collect metrics about inheritance usage module inheritance_metrics -import model +import metrics_base import mmodules_metrics import mclasses_metrics -import phase -import frontend redef class ToolContext - var inheritance_metrics_phase = new InheritanceMetricsPhase(self, null) + var inheritance_metrics_phase: Phase = new InheritanceMetricsPhase(self, null) end # Extract metrics about inheritance from model. private class InheritanceMetricsPhase super Phase - redef fun process_mainmodule(mainmodule) + redef fun process_mainmodule(mainmodule, given_mmodules) do if not toolcontext.opt_inheritance.value and not toolcontext.opt_all.value then return var csv = toolcontext.opt_csv.value @@ -61,11 +59,11 @@ private class InheritanceMetricsPhase var model = toolcontext.modelbuilder.model var mmodules = new HashSet[MModule] var mclasses = new HashSet[MClass] - for mproject in model.mprojects do + for mpackage in model.mpackages do - print toolcontext.format_h2("\n ## project {mproject}") + print toolcontext.format_h2("\n ## package {mpackage}") - for mgroup in mproject.mgroups do + for mgroup in mpackage.mgroups do if mgroup.mmodules.is_empty then continue # Scalar metrics @@ -76,9 +74,11 @@ private class InheritanceMetricsPhase if mod_mclasses.is_empty then continue mmodules.add_all(mgroup.mmodules) mclasses.add_all(mod_mclasses) + cmetrics.clear cmetrics.collect(new HashSet[MClass].from(mod_mclasses)) cmetrics.to_console(1, not toolcontext.opt_nocolors.value) if csv then cmetrics.to_csv.save("{out}/{mgroup}_classes.csv") + hmetrics.clear hmetrics.collect(new HashSet[MModule].from(mgroup.mmodules)) hmetrics.to_console(1, not toolcontext.opt_nocolors.value) if csv then hmetrics.to_csv.save("{out}/{mgroup}_inheritance.csv")