nitc $ MendelMetricsPhase :: SELF
Type of this instance, automatically specialized in every classnitc $ MendelMetricsPhase :: process_mainmodule
Specific action to execute on the whole program.nitc :: Phase :: _in_hierarchy
The dependence relation of the phase with the other phasesnitc :: Phase :: _toolcontext
The toolcontext instance attached to the phasecore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: Phase :: defaultinit
core :: Object :: defaultinit
nitc :: Phase :: in_hierarchy
The dependence relation of the phase with the other phasesnitc :: Phase :: in_hierarchy=
The dependence relation of the phase with the other phasescore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: Phase :: process_annotated_node
Specific actions to execute on annotated nodesnitc :: Phase :: process_mainmodule
Specific action to execute on the whole program.nitc :: Phase :: process_nclassdef
Specific actions to execute on the tree of a class definitionnitc :: Phase :: process_nmodule
Specific actions to execute on the whole tree of a modulenitc :: Phase :: process_nmodule_after
Specific actions to execute on the whole tree of a modulenitc :: Phase :: process_npropdef
Specific actions to execute on the tree of a propertynitc :: Phase :: toolcontext
The toolcontext instance attached to the phasenitc :: Phase :: toolcontext=
The toolcontext instance attached to the phase
private class MendelMetricsPhase
super Phase
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_mendel.value and not toolcontext.opt_all.value then return
var csv = toolcontext.opt_csv.value
var out = "{toolcontext.opt_dir.value or else "metrics"}/mendel"
out.mkdir
print toolcontext.format_h1("\n# Mendel metrics")
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(min_visibility = protected_visibility)
var mclasses = new HashSet[MClass]
for mclass in model.collect_mclasses(filter) do
if mclass.is_interface then continue
mclasses.add(mclass)
end
var cnblp = new CNBLP(model, mainmodule, filter)
var cnvi = new CNVI(model, mainmodule, filter)
var cnvs = new CNVS(model, mainmodule, filter)
var metrics = new MetricSet
metrics.register(cnblp, cnvi, cnvs)
metrics.collect(mclasses)
if csv then metrics.to_csv.write_to_file("{out}/mendel.csv")
var threshold = cnblp.threshold
print toolcontext.format_h4("\tlarge mclasses (threshold: {threshold})")
for mclass in cnblp.sort do
var val = cnblp.values[mclass]
if val.to_f < threshold then break
print toolcontext.format_p("\t {mclass.name}: {val}")
end
threshold = cnvi.threshold
print toolcontext.format_h4("\tbudding mclasses (threshold: {threshold})")
for mclass in cnvi.sort do
var val = cnvi.values[mclass]
if val.to_f < threshold then break
print toolcontext.format_p("\t {mclass.name}: {val}")
end
threshold = cnvs.threshold
print toolcontext.format_h4("\tblooming mclasses (threshold: {threshold})")
for mclass in cnvs.sort do
var val = cnvs.values[mclass]
if val.to_f < threshold then break
print toolcontext.format_p("\t {mclass.name}: {val}")
end
if csv then
var csvh = new CsvDocument
csvh.separator = ';'
csvh.header = ["povr", "ovr", "pext", "ext", "pspe", "spe", "prep", "rep", "eq"]
for mclass in mclasses do
var povr = mclass.is_pure_overrider(filter).object_id
var ovr = mclass.is_overrider(filter).object_id
var pext = mclass.is_pure_extender(filter).object_id
var ext = mclass.is_extender(filter).object_id
var pspe = mclass.is_pure_specializer(filter).object_id
var spe = mclass.is_pure_specializer(filter).object_id
var prep = mclass.is_pure_replacer(filter).object_id
var rep = mclass.is_replacer(filter).object_id
var eq = mclass.is_equal(filter).object_id
csvh.add_record(povr, ovr, pext, ext, pspe, spe, prep, rep, eq)
end
csvh.write_to_file("{out}/inheritance_behaviour.csv")
end
end
end
src/metrics/mendel_metrics.nit:58,1--130,3