import modelbuilder
private import typing
private import metrics_base
+import frontend
+
+redef class ToolContext
+ var nullables_metrics_phase = new NullablesMetricsPhase(self, null)
+end
+
+private class NullablesMetricsPhase
+ super Phase
+ redef fun process_mainmodule(mainmodule)
+ do
+ if not toolcontext.opt_nullables.value and not toolcontext.opt_all.value then return
+ compute_nullables_metrics(toolcontext.modelbuilder)
+ end
+end
private class NullableSends
super Visitor
var nullable_sends: Int = 0
var buggy_sends: Int = 0
- # 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)
do
self.modelbuilder = modelbuilder
# Visit the AST and print metrics about the usage of send on nullable reciever.
fun compute_nullables_metrics(modelbuilder: ModelBuilder)
do
- print "--- Sends on Nullable Reciever ---"
+ print "--- Sends on Nullable Receiver ---"
var total_sends = 0
var nullable_sends = 0
var buggy_sends = 0