1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Concerns computation.
19 import model
::model_collect
21 # ConcernsPhase computes the ConcernsTree used for each page layout.
25 # Populates the given DocModel.
27 for page
in doc
.pages
.values
do page
.build_concerns
(self)
33 # Build the `concerns` tree for this page.
35 # Since only `MEntityPage`, this method is a no-op for everything else.
36 private fun build_concerns
(v
: ConcernsPhase) do end
39 redef class MEntityPage
41 # Concerns to display in this page.
42 var concerns
: nullable ConcernsTree = null
45 # TODO ConcernsTrees are a PITA, following redef should not be needed here...
46 # The bad, so baaaadddd, ConcernsTree interface induces a lot of useless code
49 redef class MGroupPage
51 # Introduced classes in `mentity` that should appear in this page.
52 var intros
= new HashSet[MClass]
54 # Refined classes in `mentity` that should appear in this page.
55 var redefs
= new HashSet[MClass]
57 redef fun build_concerns
(v
) do
59 var mmodules
= new HashSet[MModule]
60 for mmodule
in mentity
.mmodules
do
61 if doc
.filter
.accept_mentity
(mmodule
) then mmodules
.add mmodule
63 for mclass
in mmodule
.intro_mclasses
do
64 if doc
.filter
.accept_mentity
(mclass
) then intros
.add mclass
66 for mclass
in mmodule
.collect_redef_mclasses
(doc
.filter
) do
67 if doc
.filter
.accept_mentity
(mclass
) then redefs
.add mclass
70 concerns
= doc
.model
.concerns_tree
(mmodules
)
74 redef class MModulePage
76 # MClasses defined in `mentity` to display in this page.
77 var mclasses
= new HashSet[MClass]
79 # MClassDefs located in `mentity` to display in this page.
80 var mclassdefs
= new HashSet[MClassDef]
82 redef fun build_concerns
(v
) do
84 # extract mclassdefs in mmodule
85 for mclassdef
in mentity
.mclassdefs
do
86 if doc
.filter
.accept_mentity
(mclassdef
) then mclassdefs
.add mclassdef
88 # extract mclasses in mmodule
89 for mclassdef
in mclassdefs
do
90 var mclass
= mclassdef
.mclass
91 if doc
.filter
.accept_mentity
(mclass
) then mclasses
.add mclass
94 var mods
= new HashSet[MModule]
95 for mclass
in mclasses
do
96 var mod
= mclass
.intro_mmodule
97 if doc
.filter
.accept_mentity
(mod
) then mods
.add mod
99 concerns
= doc
.model
.concerns_tree
(mods
)
103 redef class MClassPage
105 # MClassDefs to display in this page.
106 var mclassdefs
= new HashSet[MClassDef]
108 # MPropdefs to display in this page.
109 var mpropdefs
= new HashSet[MPropDef]
111 redef fun build_concerns
(v
) do
114 for mclassdef
in mentity
.mclassdefs
do
115 if doc
.filter
.accept_mentity
(mclassdef
) then mclassdefs
.add mclassdef
118 for mclassdef
in mclassdefs
do
119 for mpropdef
in mclassdef
.mpropdefs
do
120 if doc
.filter
.accept_mentity
(mpropdef
) then mpropdefs
.add mpropdef
124 var mods
= new HashSet[MModule]
125 for mpropdef
in mpropdefs
do
126 var mod
= mpropdef
.mclassdef
.mmodule
127 if doc
.filter
.accept_mentity
(mod
) then mods
.add mod
129 concerns
= doc
.model
.concerns_tree
(mods
)
133 redef class MPropertyPage
135 # MPropdefs to display in this page.
136 var mpropdefs
= new HashSet[MPropDef]
138 redef fun build_concerns
(v
) do
141 for mpropdef
in mentity
.mpropdefs
do
143 if mpropdef
.is_intro
then continue
144 if doc
.filter
.accept_mentity
(mpropdef
) then mpropdefs
.add mpropdef
147 var mods
= new HashSet[MModule]
148 for mpropdef
in mpropdefs
do
149 var mod
= mpropdef
.mclassdef
.mmodule
150 if doc
.filter
.accept_mentity
(mod
) then mods
.add mod
152 concerns
= doc
.model
.concerns_tree
(mods
)