nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
testing: extract `fail` method to make a test case fail without running it
[nit.git]
/
src
/
metrics
/
static_types_metrics.nit
diff --git
a/src/metrics/static_types_metrics.nit
b/src/metrics/static_types_metrics.nit
index
0bc5268
..
b94ca13
100644
(file)
--- a/
src/metrics/static_types_metrics.nit
+++ b/
src/metrics/static_types_metrics.nit
@@
-17,18
+17,16
@@
# Metrics on the usage of explicit static types.
module static_types_metrics
# 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
redef class ToolContext
- var static_types_metrics_phase = new StaticTypesMetricsPhase(self, null)
+ var static_types_metrics_phase: Phase = new StaticTypesMetricsPhase(self, null)
end
private class StaticTypesMetricsPhase
super Phase
end
private class StaticTypesMetricsPhase
super Phase
- redef fun process_mainmodule(mainmodule)
+ redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_static_types.value and not toolcontext.opt_all.value then return
compute_static_types_metrics(toolcontext.modelbuilder)
do
if not toolcontext.opt_static_types.value and not toolcontext.opt_all.value then return
compute_static_types_metrics(toolcontext.modelbuilder)
@@
-43,7
+41,7
@@
private class ATypeCounterVisitor
var typecount: Counter[MType]
var typecount: Counter[MType]
- # Get a new visitor on a classef to add type count in `typecount'.
+ # 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
init(modelbuilder: ModelBuilder, nclassdef: AClassdef, typecount: Counter[MType])
do
self.modelbuilder = modelbuilder
@@
-53,8
+51,11
@@
private class ATypeCounterVisitor
redef fun visit(n)
do
redef fun visit(n)
do
+ if n isa AAnnotation then return
+
if n isa AType then
if n isa AType then
- var mtype = modelbuilder.resolve_mtype(self.nclassdef, n)
+ var mclassdef = self.nclassdef.mclassdef
+ var mtype = modelbuilder.resolve_mtype(mclassdef.mmodule, mclassdef, n)
if mtype != null then
self.typecount.inc(mtype)
end
if mtype != null then
self.typecount.inc(mtype)
end
@@
-79,8
+80,8
@@
do
# Display data
print "--- Metrics of the explitic static types ---"
# Display data
print "--- Metrics of the explitic static types ---"
- print "Total number of explicit static types: {typecount.total}"
- if typecount.total == 0 then return
+ print "Total number of explicit static types: {typecount.sum}"
+ if typecount.sum == 0 then return
print "Statistics of type usage:"
typecount.print_summary
print "Statistics of type usage:"
typecount.print_summary