src: Update init
[nit.git] / src / metrics / static_types_metrics.nit
index 888c8e2..4dd38d0 100644 (file)
 # Metrics on the usage of explicit static types.
 module static_types_metrics
 
-private import metrics_base
-import modelbuilder
-import modelize_class
-import frontend
+import metrics_base
+import modelize
 
 redef class ToolContext
        var static_types_metrics_phase: Phase = new StaticTypesMetricsPhase(self, null)
@@ -43,19 +41,14 @@ private class ATypeCounterVisitor
 
        var typecount: Counter[MType]
 
-       # Get a new visitor on a classef to add type count in `typecount`.
-       init(modelbuilder: ModelBuilder, nclassdef: AClassdef, typecount: Counter[MType])
-       do
-               self.modelbuilder = modelbuilder
-               self.nclassdef = nclassdef
-               self.typecount = typecount
-       end
-
        redef fun visit(n)
        do
-               if n isa AType then
+               if n isa AAnnotation then return
+
+               if n isa AType then do
                        var mclassdef = self.nclassdef.mclassdef
-                       var mtype = modelbuilder.resolve_mtype(mclassdef.mmodule, mclassdef, n)
+                       if mclassdef == null then break
+                       var mtype = modelbuilder.resolve_mtype(mclassdef, n)
                        if mtype != null then
                                self.typecount.inc(mtype)
                        end