Merge: Kill `model_utils`
authorJean Privat <jean@pryen.org>
Sat, 30 May 2015 12:15:42 +0000 (08:15 -0400)
committerJean Privat <jean@pryen.org>
Sat, 30 May 2015 12:15:42 +0000 (08:15 -0400)
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 <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

1  2 
src/doc/doc_base.nit
src/doc/doc_phases/doc_html.nit
src/doc/doc_phases/doc_intros_redefs.nit
src/doc/doc_phases/doc_poset.nit
src/doc/doc_phases/doc_structure.nit
src/doc/html_templates/html_model.nit
src/metrics/nullables_metrics.nit
src/model/model.nit
src/nitserial.nit
tests/sav/nituml_args3.res
tests/sav/nituml_args4.res

Simple merge
Simple merge
@@@ -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
Simple merge
@@@ -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
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge