From: Jean Privat Date: Sat, 30 May 2015 12:15:42 +0000 (-0400) Subject: Merge: Kill `model_utils` X-Git-Tag: v0.7.5~1 X-Git-Url: http://nitlanguage.org Merge: Kill `model_utils` This PR removes the so hated module `model_utils`: * Useful services are kept in a new module `model::model_collect` that allows to collect and filter things from a `Model`. * Clients are migrated from `model_utils` to `model_collect` one by one. Misc functionalities used only by one client are moved in the client. Fixes #710 Pull-Request: #1376 Reviewed-by: Jean Privat Reviewed-by: Lucas Bajolet --- f38919d8532abb044a120fc8a84ac0a6661b2315 diff --cc src/doc/doc_phases/doc_intros_redefs.nit index ae341f9,83773f7..abc4f1d --- a/src/doc/doc_phases/doc_intros_redefs.nit +++ b/src/doc/doc_phases/doc_intros_redefs.nit @@@ -54,15 -55,14 +55,15 @@@ redef class DefinitionArticl # TODO this should move to MEntity? private fun build_mmodule_list(v: IntroRedefListPhase, doc: DocModel, mmodule: MModule) do - var section = new IntrosRedefsSection(mentity) - var group = new PanelGroup("List") + var section = new TabbedGroup("{mentity.nitdoc_id}.intros_redefs") + section.toc_title = "Intros / Redefs" + var group = new PanelGroup("list.group", "List") - var intros = mmodule.intro_mclassdefs(v.ctx.min_visibility).to_a + var intros = mmodule.collect_intro_mclassdefs(v.ctx.min_visibility).to_a doc.mainmodule.linearize_mclassdefs(intros) - group.add_child new IntrosRedefsListArticle(mentity, "Introduces", intros) + group.add_child new MEntitiesListArticle("{mentity.nitdoc_id}.intros", "Introduces", intros) - var redefs = mmodule.redef_mclassdefs(v.ctx.min_visibility).to_a + var redefs = mmodule.collect_redef_mclassdefs(v.ctx.min_visibility).to_a doc.mainmodule.linearize_mclassdefs(redefs) - group.add_child new IntrosRedefsListArticle(mentity, "Redefines", redefs) + group.add_child new MEntitiesListArticle("{mentity.nitdoc_id}.redefs", "Redefines", redefs) section.add_child group add_child(section) end diff --cc src/doc/doc_phases/doc_structure.nit index f9824d3,2e6a862..96bc219 --- a/src/doc/doc_phases/doc_structure.nit +++ b/src/doc/doc_phases/doc_structure.nit @@@ -394,8 -379,76 +394,80 @@@ class IndexArticl # List of mproperties to display. var mprops: Array[MProperty] + + redef fun is_hidden do + return mmodules.is_empty and mclasses.is_empty and mprops.is_empty + end end + + # Concerns ranking + + # Sort MConcerns based on the module importation hierarchy ranking + # see also: `MConcern::concern_rank` and `MConcern::booster_rank` + # + # Comparison is made with the formula: + # + # ~~~nitish + # a.concern_rank + a.booster_rank <=> b.concern_rank + b.booster_ran + # ~~~ + # + # If both `a` and `b` have the same ranking, + # ordering is based on lexicographic comparison of `a.name` and `b.name` + class MConcernRankSorter + super Comparator + redef type COMPARED: MConcern + + redef fun compare(a, b) do + if a.concern_rank == b.concern_rank then + return a.name <=> b.name + end + return a.concern_rank + a.booster_rank <=> b.concern_rank + b.booster_rank + end + end + + redef class MConcern + + # Boost a MConcern rank + # see: `MConcernRankSorter` + # Use a positive booster to push down a result in the list + # A negative booster can be used to push up the result + var booster_rank: Int = 0 is writable + + # Concern ranking used for ordering + # see: `MConcernRankSorter` + # Rank can be positive or negative + fun concern_rank: Int is abstract + end + + redef class MProject + redef var concern_rank is lazy do + var max = 0 + for mgroup in mgroups do + var mmax = mgroup.concern_rank + if mmax > max then max = mmax + end + return max + 1 + end + end + + redef class MGroup + redef var concern_rank is lazy do + var max = 0 + for mmodule in mmodules do + var mmax = mmodule.concern_rank + if mmax > max then max = mmax + end + return max + 1 + end + end + + redef class MModule + redef var concern_rank is lazy do + var max = 0 + for p in in_importation.direct_greaters do + var pmax = p.concern_rank + if pmax > max then max = pmax + end + return max + 1 + end + end