nitc :: Phase :: process_mainmodule
Called by the ToolContext::run_global_phases
.
mainmodule
is the main module of the program.
It could be an implicit module (called like the first given_mmodules).
given_modules
is the list of explicitely requested modules.
from the command-line for instance.
REQUIRE: not given_modules.is_empty
REQUIRE: (given_modules.length == 1) == (mainmodule == given_modules.first)
@toimplement
# Specific action to execute on the whole program.
# Called by the `ToolContext::run_global_phases`.
#
# `mainmodule` is the main module of the program.
# It could be an implicit module (called like the first given_mmodules).
#
# `given_modules` is the list of explicitely requested modules.
# from the command-line for instance.
#
# REQUIRE: `not given_modules.is_empty`
# REQUIRE: `(given_modules.length == 1) == (mainmodule == given_modules.first)`
#
# @toimplement
fun process_mainmodule(mainmodule: MModule, given_mmodules: SequenceRead[MModule]) do end
src/modelbuilder.nit:74,2--87,90
redef fun process_mainmodule(mainmodule, given_mmodules) do
if not toolcontext.opt_erasure.value then return
var modelbuilder = toolcontext.modelbuilder
var analysis = null
if toolcontext.opt_rta.value then
analysis = modelbuilder.do_rapid_type_analysis(mainmodule)
end
modelbuilder.run_separate_erasure_compiler(mainmodule, analysis)
end
src/compiler/separate_erasure_compiler.nit:54,2--63,4
redef fun process_mainmodule(mainmodule, given_mmodules) do
if not toolcontext.opt_separate.value then return
var modelbuilder = toolcontext.modelbuilder
var analysis = modelbuilder.do_rapid_type_analysis(mainmodule)
modelbuilder.run_separate_compiler(mainmodule, analysis)
end
src/compiler/separate_compiler.nit:105,2--111,4
redef fun process_mainmodule(mainmodule, given_mmodules) do
if not toolcontext.opt_global.value then return
var modelbuilder = toolcontext.modelbuilder
var analysis = modelbuilder.do_rapid_type_analysis(mainmodule)
modelbuilder.run_global_compiler(mainmodule, analysis)
end
src/compiler/global_compiler.nit:43,2--49,4
redef fun process_mainmodule(mainmodule, mmodules)
do
var modelbuilder = toolcontext.modelbuilder
var model = modelbuilder.model
var min_visibility = private_visibility
if not toolcontext.opt_private.value then min_visibility = protected_visibility
var accept_attribute = true
if toolcontext.opt_no_attributes.value then accept_attribute = false
var catalog = new Catalog(toolcontext.modelbuilder)
catalog.build_catalog(mainmodule.model.mpackages)
var filter = new ModelFilter(
min_visibility,
accept_attribute = accept_attribute,
accept_fictive = true,
accept_generated = true,
accept_test = false,
accept_redef = true,
accept_extern = true,
accept_empty_doc = true,
accept_example = true,
accept_broken = false)
var doc = new DocModel(model, mainmodule, modelbuilder, catalog, filter)
model.nitdoc_md_processor = doc.md_processor
doc.no_dot = toolcontext.opt_nodot.value
doc.no_code = toolcontext.opt_nocode.value
doc.code_url = toolcontext.opt_source.value
doc.share_url = toolcontext.opt_shareurl.value
doc.custom_brand = toolcontext.opt_custom_brand.value
doc.custom_title = toolcontext.opt_custom_title.value
doc.custom_footer = toolcontext.opt_custom_footer.value
doc.custom_intro = toolcontext.opt_custom_intro.value
doc.tracker_url = toolcontext.opt_piwik_tracker.value
doc.piwik_site_id = toolcontext.opt_piwik_site_id.value
# Prepare output dir
var test_mode = toolcontext.opt_test.value
var no_render = toolcontext.opt_norender.value
var output_dir = toolcontext.opt_dir.value or else "doc"
if not no_render then
output_dir.mkdir
# Copy assets
var share_dir = toolcontext.opt_share_dir.value or else "{toolcontext.share_dir}/nitdoc"
sys.system("cp -r -- {share_dir.escape_to_sh}/* {output_dir.escape_to_sh}/")
end
# Collect model to document
var mpackages = model.collect_mpackages(filter)
var mgroups = model.collect_mgroups(filter)
var nmodules = model.collect_mmodules(filter)
var mclasses = model.collect_mclasses(filter)
var mprops = model.collect_mproperties(filter)
var mentities = new Array[MEntity]
mentities.add_all mpackages
mentities.add_all mgroups
mentities.add_all nmodules
mentities.add_all mclasses
mentities.add_all mprops
var persons = doc.catalog.persons
var tags = doc.catalog.tag2proj.keys
# Prepare progress bar
var count = 0
var pages = 1 # count homepage
pages += mentities.length
pages += persons.length
pages += tags.length
print "Generating documentation pages..."
var progress = new TermProgress(pages, 0)
if not test_mode then progress.display
# Make pages
count += 1
if not test_mode then progress.update(count, "homepage")
if not no_render then doc.gen_page(new PageHome("Overview"), output_dir)
for mentity in mentities do
count += 1
if not test_mode then progress.update(count, "page {count}/{pages}")
if not no_render then doc.gen_page(new PageMEntity(mentity), output_dir)
end
for name, person in persons do
count += 1
if not test_mode then progress.update(count, "page {count}/{pages}")
if not no_render then doc.gen_page(new PagePerson(person), output_dir)
end
for tag in tags do
count += 1
if not test_mode then progress.update(count, "page {count}/{pages}")
if not no_render then doc.gen_page(new PageTag(tag), output_dir)
end
if not test_mode then print "" # finalise progress
if not no_render then
doc.create_index_file("{output_dir}/quicksearch-list.js")
print "Documentation produced in `{output_dir}`"
end
if test_mode then
print "Generated {count}/{pages} pages"
print " PageHome: 1"
print " PageMPackage: {mpackages.length}"
print " PageMGroup: {mgroups.length}"
print " PageMModule: {nmodules.length}"
print " PageMClass: {mclasses.length}"
print " PageMProperty: {mprops.length}"
print " PagePerson: {persons.length}"
print " PageTag: {tags.length}"
end
end
src/nitdoc.nit:106,2--224,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_mmodules.value and not toolcontext.opt_all.value then return
var csv = toolcontext.opt_csv.value
var out = "{toolcontext.opt_dir.value or else "metrics"}/mmodules"
out.mkdir
var model = toolcontext.modelbuilder.model
print toolcontext.format_h1("\n# MModules metrics")
var metrics = new MetricSet
metrics.register(new MNOA(model, mainmodule))
metrics.register(new MNOP(model, mainmodule))
metrics.register(new MNOC(model, mainmodule))
metrics.register(new MNOD(model, mainmodule))
metrics.register(new MDIT(model, mainmodule))
metrics.register(new MNBI(model, mainmodule))
metrics.register(new MNBR(model, mainmodule))
metrics.register(new MNBCC(model, mainmodule))
metrics.register(new MNBAC(model, mainmodule))
metrics.register(new MNBIC(model, mainmodule))
var mmodules = new HashSet[MModule]
for mpackage in model.mpackages do
print toolcontext.format_h2("\n ## package {mpackage}")
for mgroup in mpackage.mgroups do
if mgroup.mmodules.is_empty then continue
# Scalar metrics
print toolcontext.format_h3(" `- group {mgroup.full_name}")
mmodules.add_all(mgroup.mmodules)
metrics.clear
metrics.collect(new HashSet[MModule].from(mgroup.mmodules))
metrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then metrics.to_csv.write_to_file("{out}/{mgroup}.csv")
end
end
if not mmodules.is_empty then
# Global metrics
print toolcontext.format_h2("\n ## global metrics")
metrics.clear
metrics.collect(mmodules)
metrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then metrics.to_csv.write_to_file("{out}/summary.csv")
end
end
src/metrics/mmodules_metrics.nit:32,2--79,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_mclasses.value and not toolcontext.opt_all.value then return
var csv = toolcontext.opt_csv.value
var out = "{toolcontext.opt_dir.value or else "metrics"}/mclasses"
out.mkdir
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(private_visibility)
print toolcontext.format_h1("\n# MClasses metrics")
var metrics = new MetricSet
metrics.register(new CNOA(model, mainmodule, filter))
metrics.register(new CNOP(model, mainmodule, filter))
metrics.register(new CNOC(model, mainmodule, filter))
metrics.register(new CNOD(model, mainmodule, filter))
metrics.register(new CDIT(model, mainmodule, filter))
metrics.register(new CNBP(model, mainmodule, filter))
metrics.register(new CNBA(model, mainmodule, filter))
metrics.register(new CNBI(model, mainmodule, filter))
metrics.register(new CNBM(model, mainmodule, filter))
metrics.register(new CNBV(model, mainmodule, filter))
metrics.register(new CNBIP(model, mainmodule, filter))
metrics.register(new CNBRP(model, mainmodule, filter))
metrics.register(new CNBHP(model, mainmodule, filter))
var mclasses = new HashSet[MClass]
for mpackage in model.mpackages do
print toolcontext.format_h2("\n ## package {mpackage}")
for mgroup in mpackage.mgroups do
if mgroup.mmodules.is_empty then continue
metrics.clear
# Scalar metrics
print toolcontext.format_h3(" `- group {mgroup.full_name}")
var mod_mclasses = new HashSet[MClass]
for mmodule in mgroup.mmodules do mod_mclasses.add_all(mmodule.intro_mclasses)
if mod_mclasses.is_empty then continue
mclasses.add_all(mod_mclasses)
metrics.collect(new HashSet[MClass].from(mod_mclasses))
metrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then metrics.to_csv.write_to_file("{out}/{mgroup}.csv")
end
end
if not mclasses.is_empty then
metrics.clear
# Global metrics
print toolcontext.format_h2("\n ## global metrics")
metrics.collect(mclasses)
metrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then metrics.to_csv.write_to_file("{out}/summary.csv")
end
end
src/metrics/mclasses_metrics.nit:32,2--87,4
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
src/metrics/mendel_metrics.nit:60,2--129,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_inheritance.value and not toolcontext.opt_all.value then return
var csv = toolcontext.opt_csv.value
var out = "{toolcontext.opt_dir.value or else "metrics"}/inheritance"
out.mkdir
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(min_visibility = private_visibility)
print toolcontext.format_h1("\n# Inheritance metrics")
var hmetrics = new MetricSet
hmetrics.register(new MDUI(model, mainmodule))
hmetrics.register(new MDUIC(model, mainmodule))
hmetrics.register(new MDUII(model, mainmodule))
hmetrics.register(new MIF(model, mainmodule))
hmetrics.register(new MIFC(model, mainmodule))
hmetrics.register(new MIFI(model, mainmodule))
var cmetrics = new MetricSet
cmetrics.register(new CNOAC(model, mainmodule, filter))
cmetrics.register(new CNOPC(model, mainmodule, filter))
cmetrics.register(new CNOCC(model, mainmodule, filter))
cmetrics.register(new CNODC(model, mainmodule, filter))
cmetrics.register(new CNOPI(model, mainmodule, filter))
cmetrics.register(new CNOCI(model, mainmodule, filter))
cmetrics.register(new CNODI(model, mainmodule, filter))
cmetrics.register(new CDITC(model, mainmodule, filter))
cmetrics.register(new CDITI(model, mainmodule, filter))
var mmodules = new HashSet[MModule]
var mclasses = new HashSet[MClass]
for mpackage in model.mpackages do
print toolcontext.format_h2("\n ## package {mpackage}")
for mgroup in mpackage.mgroups do
if mgroup.mmodules.is_empty then continue
# Scalar metrics
print toolcontext.format_h3(" `- group {mgroup.full_name}")
var mod_mclasses = new HashSet[MClass]
for mmodule in mgroup.mmodules do mod_mclasses.add_all(mmodule.intro_mclasses)
if mod_mclasses.is_empty then continue
mmodules.add_all(mgroup.mmodules)
mclasses.add_all(mod_mclasses)
cmetrics.clear
cmetrics.collect(new HashSet[MClass].from(mod_mclasses))
cmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then cmetrics.to_csv.write_to_file("{out}/{mgroup}_classes.csv")
hmetrics.clear
hmetrics.collect(new HashSet[MModule].from(mgroup.mmodules))
hmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then hmetrics.to_csv.write_to_file("{out}/{mgroup}_inheritance.csv")
end
end
if not mclasses.is_empty then
# Global metrics
print toolcontext.format_h2("\n ## global metrics")
cmetrics.clear
cmetrics.collect(mclasses)
cmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then cmetrics.to_csv.write_to_file("{out}/summary_classes.csv")
hmetrics.clear
hmetrics.collect(mmodules)
hmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then hmetrics.to_csv.write_to_file("{out}/summary_inheritance.csv")
end
end
src/metrics/inheritance_metrics.nit:33,2--103,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_refinement.value and not toolcontext.opt_all.value then return
compute_refinement_metrics(toolcontext.modelbuilder.model)
end
src/metrics/refinement_metrics.nit:29,2--33,4
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)
end
src/metrics/static_types_metrics.nit:29,2--33,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_nullables.value and not toolcontext.opt_all.value then return
var csv = toolcontext.opt_csv.value
var out = "{toolcontext.opt_dir.value or else "metrics"}/nullables"
out.mkdir
print toolcontext.format_h1("\n# Nullable metrics")
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(private_visibility)
var metrics = new MetricSet
metrics.register(new CNBA(model, mainmodule, filter))
metrics.register(new CNBNA(model, mainmodule, filter))
var mclasses = new HashSet[MClass]
for mpackage in model.mpackages do
print toolcontext.format_h2("\n ## package {mpackage}")
for mgroup in mpackage.mgroups do
if mgroup.mmodules.is_empty then continue
metrics.clear
# Scalar metrics
print toolcontext.format_h3(" `- group {mgroup.full_name}")
var mod_mclasses = new HashSet[MClass]
for mmodule in mgroup.mmodules do mod_mclasses.add_all(mmodule.intro_mclasses)
if mod_mclasses.is_empty then continue
mclasses.add_all(mod_mclasses)
metrics.collect(new HashSet[MClass].from(mod_mclasses))
metrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then metrics.to_csv.write_to_file("{out}/{mgroup}.csv")
end
end
if not mclasses.is_empty then
metrics.clear
# Global metrics
print toolcontext.format_h2("\n ## global metrics")
metrics.collect(mclasses)
metrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then metrics.to_csv.write_to_file("{out}/summary.csv")
end
compute_nullables_metrics(toolcontext.modelbuilder)
end
src/metrics/nullables_metrics.nit:32,2--79,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_self.value and not toolcontext.opt_all.value then return
compute_self_metrics(toolcontext.modelbuilder)
end
src/metrics/self_metrics.nit:28,2--32,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_generate_hyperdoc.value and not toolcontext.opt_all.value then return
var model = toolcontext.modelbuilder.model
generate_module_hierarchy(toolcontext, given_mmodules)
generate_classdef_hierarchy(toolcontext, model)
generate_class_hierarchy(toolcontext, mainmodule)
end
src/metrics/generate_hierarchies.nit:31,2--38,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_rta.value and not toolcontext.opt_all.value then return
var csv = toolcontext.opt_csv.value
var out = "{toolcontext.opt_dir.value or else "metrics"}/rta"
out.mkdir
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(min_visibility = protected_visibility)
print toolcontext.format_h1("\n# RTA metrics")
print toolcontext.format_h2("\n ## Live instances by mainmodules")
var mmetrics = new MetricSet
mmetrics.register(new MNLC(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNLT(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNCT(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNLI(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNLM(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNLMD(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNLDD(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.collect(new HashSet[MModule].from([mainmodule]))
mmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then mmetrics.to_csv.write_to_file("{out}/{mainmodule}.csv")
var mtypes = new HashSet[MType]
var analysis = new MetricsRapidTypeAnalysis(toolcontext.modelbuilder, mainmodule)
analysis.run_analysis
mtypes.add_all(analysis.live_types)
mtypes.add_all(analysis.live_cast_types)
print toolcontext.format_h2("\n ## Total live instances by mclasses")
var cmetrics = new MetricSet
cmetrics.register(analysis.cnli)
cmetrics.register(analysis.cnlc)
cmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then cmetrics.to_csv.write_to_file("{out}/mclasses.csv")
print toolcontext.format_h2("\n ## Total live instances by mtypes")
var tmetrics = new MetricSet
tmetrics.register(analysis.tnli)
tmetrics.register(analysis.tnlc)
tmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then tmetrics.to_csv.write_to_file("{out}/mtypes.csv")
print toolcontext.format_h2("\n ## MType complexity")
var gmetrics = new MetricSet
gmetrics.register(new TAGS)
gmetrics.register(new TDGS)
gmetrics.collect(mtypes)
gmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then gmetrics.to_csv.write_to_file("{out}/complexity.csv")
callsite_info(analysis)
# dump type and method infos
if csv then
analysis.live_types_to_csv.write_to_file("{out}/rta_types.csv")
analysis.live_methods_to_tree.write_to_file("{out}/rta_methods.dat")
end
end
src/metrics/rta_metrics.nit:33,2--93,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_generate_hyperdoc.value and not toolcontext.opt_all.value then return
generate_model_hyperdoc(toolcontext, toolcontext.modelbuilder.model)
end
src/metrics/model_hyperdoc.nit:28,2--32,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_tables.value and not toolcontext.opt_all.value then return
compute_tables_metrics(mainmodule)
end
src/metrics/tables_metrics.nit:28,2--32,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_poset.value and not toolcontext.opt_all.value then return
var model = mainmodule.model
print "--- Poset metrics ---"
print "## Module importation hierarchy"
model.mmodule_importation_hierarchy.print_metrics
print "## Classdef hierarchy"
model.mclassdef_hierarchy.print_metrics
print "## Class hierarchy"
mainmodule.flatten_mclass_hierarchy.print_metrics
end
src/metrics/poset_metrics.nit:27,2--39,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_ast.value and not toolcontext.opt_all.value then return
print "--- AST Metrics ---"
# Visit all the source code to collect data
var visitor = new AstMetricsVisitor(self)
for nmodule in toolcontext.modelbuilder.nmodules do
visitor.enter_visit(nmodule)
end
print "## All nodes of the AST"
node_counter.print_summary
node_counter.print_elements(10)
print "## All identifiers of the AST"
id_counter.print_summary
id_counter.print_elements(10)
end
src/metrics/ast_metrics.nit:30,2--45,4
redef fun process_mainmodule(mainmodule, given_mmodules) do
if not toolcontext.opt_readme.value and not toolcontext.opt_all.value then return
print toolcontext.format_h1("\n# ReadMe metrics")
var model = toolcontext.modelbuilder.model
var metrics = new ReadmeMetrics
metrics.collect_metrics(model.mpackages)
metrics.to_console(toolcontext)
var csv = toolcontext.opt_csv.value
if csv then metrics.to_csv.write_to_file("{toolcontext.opt_dir.value or else "metrics"}/readme.csv")
end
src/metrics/readme_metrics.nit:34,2--46,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_detect_variance_constraints.value and not toolcontext.opt_all.value then return
print "--- Detection of variance constraints on formal parameter types ---"
var k = new DetectVarianceConstraints
k.collect(mainmodule)
print "-- Generic classes --"
k.cpt_class.print_elements(10)
print " total classes: {k.cpt_class.sum}"
print " total formal parameters: {k.pts.length}"
k.propagate
print "-- Including `private` properties --"
k.print_stats
k = new DetectVarianceConstraints
k.exclude_private = true
k.collect(mainmodule)
k.propagate
print "-- Excluding `private` properties --"
k.print_stats
end
src/metrics/detect_variance_constraints.nit:49,2--76,4
# Display collected statistics
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if is_disabled then return
print "--- Detection of the usage of covariance static type conformance ---"
print "-- Total --"
print "- Kinds of the subtype -"
cpt_subtype_kinds.print_elements(10)
print " total: {cpt_subtype_kinds.sum}"
print "- Variance -"
cpt_total_variance.print_elements(10)
print " total: {cpt_total_variance.sum}"
print "- Classes of the subtype -"
cpt_total_classes.print_elements(10)
print " total: {cpt_total_classes.sum}"
print "-- On covariance only --"
print "- Specific covariance case explanations -"
cpt_explanations.print_elements(10)
print " total: {cpt_explanations.sum}"
print "- Classes of the subtype, when covariance -"
cpt_classes.print_elements(10)
print " total: {cpt_classes.sum}"
print "- Patterns of the covariant cases -"
cpt_pattern.print_elements(10)
print " total: {cpt_pattern.sum}"
print "- Nodes of the covariance cases -"
cpt_nodes.print_elements(10)
print " total: {cpt_nodes.sum}"
print "- Modules of the covariance cases -"
cpt_modules.print_elements(10)
print " total: {cpt_modules.sum}"
print "- Kind of the expression node (when it make sense) -"
cpt_expression.print_elements(10)
print " total: {cpt_expression.sum}"
print "-- Casts --"
print "- Kind of cast target -"
cpt_cast_kind.print_elements(10)
print " total: {cpt_cast_kind.sum}"
print "- Classes of the cast -"
cpt_cast_classes.print_elements(10)
print " total: {cpt_cast_classes.sum}"
print "- Cast pattern -"
cpt_cast_pattern.print_elements(10)
print " total: {cpt_cast_pattern.sum}"
print "- Autocasts -"
cpt_autocast.print_elements(10)
print " total: {cpt_autocast.sum}"
end
src/metrics/detect_covariance.nit:64,2--127,4
redef fun process_mainmodule(mainmodule, mmodules) do
var mpackages = extract_mpackages(mmodules)
for mpackage in mpackages do
# Fictive and buggy packages are ignored
if not mpackage.has_source then
toolcontext.warning(mpackage.location, "no-source",
"Warning: `{mpackage}` has no source file")
continue
end
# Check package INI files
if toolcontext.opt_check_ini.value then
mpackage.check_ini(toolcontext)
continue
end
# Check package Makefiles
if toolcontext.opt_check_makefile.value then
mpackage.check_makefile(toolcontext, mainmodule)
continue
end
# Check manpages
if toolcontext.opt_check_man.value then
mpackage.check_man(toolcontext, mainmodule)
continue
end
# Check README.md
if toolcontext.opt_check_readme.value then
mpackage.check_readme(toolcontext)
continue
end
# Expand packages
if toolcontext.opt_expand.value and not mpackage.is_expanded then
var path = mpackage.expand
toolcontext.info("{mpackage} moved to {path}", 0)
end
if not mpackage.is_expanded then
toolcontext.warning(mpackage.location, "no-dir",
"Warning: `{mpackage}` has no package directory")
continue
end
# Create INI file
if toolcontext.opt_gen_ini.value then
if not mpackage.has_ini or toolcontext.opt_force.value then
var path = mpackage.gen_ini
toolcontext.info("generated INI file `{path}`", 0)
end
end
# Create Makefile
if toolcontext.opt_gen_makefile.value then
if not mpackage.has_makefile or toolcontext.opt_force.value then
var path = mpackage.gen_makefile(toolcontext.modelbuilder.model, mainmodule)
if path != null then
toolcontext.info("generated Makefile `{path}`", 0)
end
end
end
# Create manpages
if toolcontext.opt_gen_man.value then
mpackage.gen_man(toolcontext, mainmodule)
end
end
end
src/nitpackage.nit:66,2--135,4
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_vim_autocomplete.value then return
var compile_dir = "NIT_VIM_DIR".environ
if compile_dir.is_empty then compile_dir = "HOME".environ / ".vim/nit"
compile_dir.mkdir
var modules_stream = new FileWriter.open(compile_dir / "modules.txt")
var classes_stream = new FileWriter.open(compile_dir / "classes.txt")
var constructors_stream = new FileWriter.open(compile_dir / "constructors.txt")
var types_stream = new FileWriter.open(compile_dir / "types.txt")
var properties_stream = new FileWriter.open(compile_dir / "properties.txt")
# Got all known modules
var model = mainmodule.model
for mmodule in model.mmodules do
mmodule.write_doc(model, mainmodule, modules_stream)
end
# TODO list other modules from the Nit lib
# Get all known classes
for mclass in model.mclasses do
if not mainmodule.is_visible(mclass.intro_mmodule, public_visibility) then continue
var mclass_intro = mclass.intro
# Can it be instantiated?
if mclass.kind != interface_kind and mclass.kind != abstract_kind then
for prop in mclass.collect_accessible_mproperties(mainmodule) do
if prop isa MMethod and prop.is_init then
mclass_intro.target_constructor = prop.intro
mclass_intro.write_doc(model, mainmodule, constructors_stream)
end
end
mclass_intro.target_constructor = null
end
# Always add to types and classes
mclass.mclass_type.write_doc(model, mainmodule, classes_stream)
mclass.mclass_type.write_doc(model, mainmodule, types_stream)
end
# Get all known properties
for mproperty in model.mproperties do
var intro_mmodule = mproperty.intro_mclassdef.mmodule
if not mainmodule.is_visible(intro_mmodule, public_visibility) then continue
# Is it a virtual type?
if mproperty isa MVirtualTypeProp then
mproperty.intro.write_doc(model, mainmodule, types_stream)
continue
end
# Skip properties beginning with @ or _
var first_letter = mproperty.name.chars.first
if first_letter == '@' or first_letter == '_' then continue
mproperty.intro.write_doc(model, mainmodule, properties_stream)
end
# Close streams
for stream in [modules_stream, classes_stream, properties_stream,
types_stream, constructors_stream] do
stream.close
var error = stream.last_error
if error != null then
toolcontext.error(null, "Error: failed to write Vim autocomplete file: {error}.")
end
end
end
src/doc/vim_autocomplete.nit:258,2--330,4
redef fun process_mainmodule(mainmodule, given_mmodules) do
do_work(mainmodule, given_mmodules, toolcontext.modelbuilder)
end
src/test_phase.nit:32,2--34,4
redef fun process_mainmodule(mainmodule, given_mmodules) do
print toolcontext.format_h1("--- Code Smells Metrics ---")
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(private_visibility)
self.set_all_average_metrics(model)
var mclass_codesmell = new BadConceptonController(model, filter)
var collect = new Counter[MClassDef]
var mclassdefs = new Array[MClassDef]
for mclass in mainmodule.flatten_mclass_hierarchy do
mclass_codesmell.collect(mclass.mclassdefs,self)
end
if toolcontext.opt_get_all.value then
mclass_codesmell.print_all
else
mclass_codesmell.print_top(10)
end
end
src/metrics/codesmells_metrics.nit:34,2--52,4
redef fun process_mainmodule(mainmodule, mmodules)
do
var filters = new ModelFilter
if not toolcontext.opt_privacy.value then
filters.min_visibility = protected_visibility
end
var d = new UMLModel(toolcontext.modelbuilder.model, mainmodule, filters)
if toolcontext.opt_gen.value == 0 then
print d.generate_class_uml.write_to_string
else if toolcontext.opt_gen.value == 1 then
print d.generate_package_uml.write_to_string
end
end
src/nituml.nit:42,2--55,4
redef fun process_mainmodule(mainmodule, mmodules)
do
var config = build_config(toolcontext, mainmodule)
config.model.index # pre load model index
config.model.nitdoc_md_processor = config.md_processor
var app = new App
app.use_before("/*", new SessionInit)
app.use_before("/*", new RequestClock)
app.use("/api", new APIRouter(config))
app.use("/login", new GithubLogin(config.github_client_id))
app.use("/oauth", new GithubOAuthCallBack(config.github_client_id, config.github_client_secret))
app.use("/logout", new GithubLogout)
app.use("/*", new StaticHandler(toolcontext.share_dir / "nitweb", "index.html"))
app.use_after("/*", new PopLogger(info_level))
app.listen(config.app_host, config.app_port)
end
src/nitweb.nit:87,2--105,4