metrics: replace is_user_defined() by is_standard()
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 25 Feb 2014 05:05:38 +0000 (00:05 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 28 Feb 2014 18:35:16 +0000 (13:35 -0500)
also fix the @FIXME

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/metrics/metrics_base.nit
src/metrics/rta_metrics.nit

index 1de86e4..aa428f2 100644 (file)
@@ -123,14 +123,16 @@ redef class Model
 end
 
 redef class MClass
-       fun is_user_defined: Bool do
-               return self.intro_mmodule.is_user_defined
+       # is the class imported from standard lib?
+       fun is_standard: Bool do
+               return self.intro_mmodule.mgroup.mproject.name == "standard"
        end
 end
 
 redef class MModule
-       fun is_user_defined: Bool do
-               return not self.model.std_modules.has(self.name)
+       # is the module imported from standard lib?
+       fun is_standard: Bool do
+               return self.mgroup.mproject.name == "standard"
        end
 end
 
index 4752396..5cac158 100644 (file)
@@ -40,10 +40,10 @@ redef class MType
        private var nlvt: Int = 0
        private var nlct: Int = 0
 
-       private fun is_user_defined: Bool do
+       private fun is_standard: Bool do
                var mtype = self
                if mtype isa MNullableType then mtype = mtype.mtype
-               return self.as(MClassType).mclass.is_user_defined
+               return self.as(MClassType).mclass.is_standard
        end
 
        private fun get_depth: Int do
@@ -93,7 +93,7 @@ do
                mtype.mclass.nlvt += 1
                mtype.mclass.live_types.add(mtype)
                if mtype isa MGenericType then nlvtg += 1
-               if mtype.is_user_defined then
+               if not mtype.is_standard then
                        nlvtudud += 1
                        if mtype isa MGenericType then nlvtgudud += 1
                else
@@ -108,7 +108,7 @@ do
                mtype.mclass.nlct += 1
                mtype.mclass.cast_types.add(mtype)
                if mtype isa MGenericType then nlctg += 1
-               if mtype.is_user_defined then
+               if not mtype.is_standard then
                        nlctudud += 1
                        if mtype isa MGenericType then nlctgudud += 1
                else
@@ -134,7 +134,7 @@ do
                for mtype in mtypes do
                        var arity = 0
                        if mtype isa MGenericType then arity = mtype.arguments.length
-                       if mtype.is_user_defined then
+                       if not mtype.is_standard then
                                udscalarCSV.add_line(mtype, arity, mtype.get_depth, mtype.nlvt, mtype.nlct)
                        end
                        scalarCSV.add_line(mtype, arity, mtype.get_depth, mtype.nlvt, mtype.nlct)
@@ -149,7 +149,7 @@ do
 
                for mclass in modelbuilder.model.mclasses do
                        if not mclass.is_class or mclass.is_abstract then continue
-                       if mclass.is_user_defined then
+                       if not mclass.is_standard then
                                udscalarCSV.add_line(mclass.mclass_type, mclass.arity, mclass.live_types.length, mclass.nlvt)
                        end
                        scalarCSV.add_line(mclass.mclass_type, mclass.arity, mclass.live_types.length, mclass.nlvt)