nitmetrics: refactor refinement usage metrics computation
authorAlexandre Terrasa <alexadre@moz-code.org>
Sun, 4 Nov 2012 20:38:57 +0000 (15:38 -0500)
committerJean Privat <jean@pryen.org>
Mon, 5 Nov 2012 19:17:53 +0000 (14:17 -0500)
Signed-off-by: Alexandre Terrasa <alexadre@moz-code.org>

src/metrics/metrics.nit
src/metrics/metrics_base.nit
src/metrics/refinement_metrics.nit [moved from src/metrics/model_stats.nit with 92% similarity]
src/nitmetrics.nit

index fef9566..30b6eeb 100644 (file)
 module metrics
 
 import metrics_base
+import refinement_metrics
 import static_types_metrics
 import nullables_metrics
 import self_metrics
-import model_stats
 import generate_hierarchies
 import rta_metrics
 import model_hyperdoc
index 56641ec..e6926af 100644 (file)
@@ -21,6 +21,8 @@ import modelbuilder
 
 redef class ToolContext
 
+       # --refinement
+       var opt_refinement = new OptionBool("Compute metrics about refinement usage", "--refinement")
        # --self
        var opt_self = new OptionBool("Compute metrics about the usage of explicit and implicit self", "--self")
        # --nullables
@@ -40,6 +42,7 @@ redef class ToolContext
        redef init
        do
                super
+               self.option_context.add_option(opt_refinement)
                self.option_context.add_option(opt_self)
                self.option_context.add_option(opt_nullables)
                self.option_context.add_option(opt_static_types)
similarity index 92%
rename from src/metrics/model_stats.nit
rename to src/metrics/refinement_metrics.nit
index 3ee2323..549f661 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# General statistics on a model
-module model_stats
+# Collect metrics about refinement usage
+module refinement_metrics
 
 import model
 private import metrics_base
 
-# Print general statistics on a model
-fun compute_statistics(model: Model)
+# Print refinement usage metrics
+fun compute_refinement_metrics(model: Model)
 do
-       print "--- Statistics of the model ---"
+       print "--- Metrics of refinement usage ---"
        var nbmod = model.mmodules.length
        print "Number of modules: {nbmod}"
 
index 5d93ceb..6c5306e 100644 (file)
@@ -56,8 +56,11 @@ end
 # Now, we just have to play with the model!
 print "*** STATS ***"
 
-print ""
-compute_statistics(model)
+# Refinement usage metrics
+if toolcontext.opt_refinement.value then
+       print ""
+       compute_refinement_metrics(model)
+end
 
 # Self usage metrics
 if toolcontext.opt_self.value then