redef class ToolContext
+ # --static-types
+ var opt_static_types = new OptionBool("Compute explicit static types metrics", "--static-types")
# --tables
var opt_tables = new OptionBool("Compute tables metrics", "--tables")
# --rta
redef init
do
super
+ self.option_context.add_option(opt_static_types)
self.option_context.add_option(opt_tables)
self.option_context.add_option(opt_rta)
self.option_context.add_option(opt_generate_hyperdoc)
# See the License for the specific language governing permissions and
# limitations under the License.
-# Statistics on the usage of explicit static types.
-module count_ntypes
+# Metrics on the usage of explicit static types.
+module static_types_metrics
private import metrics_base
import modelbuilder
end
end
-# Visit the AST and print statistics on the usage of explicit static types.
-fun count_ntypes(modelbuilder: ModelBuilder)
+# Visit the AST and print metrics on the usage of explicit static types.
+fun compute_static_types_metrics(modelbuilder: ModelBuilder)
do
# Count each occurence of a specific static type
var typecount = new Counter[MType]
end
# Display data
- print "--- Statistics of the explitic static types ---"
+ print "--- Metrics of the explitic static types ---"
print "Total number of explicit static types: {typecount.total}"
if typecount.total == 0 then return
print ""
visit_nullable_sends(modelbuilder)
-print ""
-count_ntypes(modelbuilder)
+# Static types metrics
+if toolcontext.opt_static_types.value then
+ print ""
+ compute_static_types_metrics(modelbuilder)
+end
# Tables metrics
if toolcontext.opt_tables.value then