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.
20 # ConcernsPhase computes the ConcernsTree used for each page layout.
24 # Populates the given DocModel.
26 for page
in doc
.pages
do page
.build_concerns
(doc
)
32 # Build the `concerns` tree for this page.
34 # Since only `MEntityPage`, this method is a no-op for everything else.
35 private fun build_concerns
(doc
: DocModel) do end
38 redef class MEntityPage
40 # Concerns to display in this page.
41 var concerns
: nullable ConcernsTree = null
44 # TODO ConcernsTrees are a PITA, following redef should not be needed here...
45 # The bad, so baaaadddd, ConcernsTree interface induces a lot of useless code
48 redef class MGroupPage
50 # Introduced classes in `mentity` that should appear in this page.
51 var intros
= new HashSet[MClass]
53 # Refined classes in `mentity` that should appear in this page.
54 var redefs
= new HashSet[MClass]
56 redef fun build_concerns
(doc
) do
57 var mmodules
= new HashSet[MModule]
58 for mmodule
in mentity
.collect_mmodules
do
59 if doc
.mmodules
.has
(mmodule
) then mmodules
.add mmodule
61 for mclass
in mmodule
.intro_mclasses
do
62 if doc
.mclasses
.has
(mclass
) then intros
.add mclass
64 for mclass
in mmodule
.redef_mclasses
do
65 if doc
.mclasses
.has
(mclass
) then redefs
.add mclass
68 concerns
= doc
.model
.concerns_tree
(mmodules
)
72 redef class MModulePage
74 # MClasses defined in `mentity` to display in this page.
75 var mclasses
= new HashSet[MClass]
77 # MClassDefs located in `mentity` to display in this page.
78 var mclassdefs
= new HashSet[MClassDef]
80 redef fun build_concerns
(doc
) do
81 # extract mclassdefs in mmodule
82 for mclassdef
in mentity
.mclassdefs
do
83 if doc
.mclassdefs
.has
(mclassdef
) then mclassdefs
.add mclassdef
85 # extract mclasses in mmodule
86 for mclassdef
in mclassdefs
do
87 var mclass
= mclassdef
.mclass
88 if doc
.mclasses
.has
(mclass
) then mclasses
.add mclass
91 var mods
= new HashSet[MModule]
92 for mclass
in mclasses
do
93 var mod
= mclass
.intro_mmodule
94 if doc
.mmodules
.has
(mod
) then mods
.add mod
96 concerns
= doc
.model
.concerns_tree
(mods
)
100 redef class MClassPage
102 # MClassDefs to display in this page.
103 var mclassdefs
= new HashSet[MClassDef]
105 # MPropdefs to display in this page.
106 var mpropdefs
= new HashSet[MPropDef]
108 redef fun build_concerns
(doc
) do
110 for mclassdef
in mentity
.mclassdefs
do
111 if doc
.mclassdefs
.has
(mclassdef
) then mclassdefs
.add mclassdef
114 for mclassdef
in mclassdefs
do
115 for mpropdef
in mclassdef
.mpropdefs
do
116 if doc
.mpropdefs
.has
(mpropdef
) then mpropdefs
.add mpropdef
120 var mods
= new HashSet[MModule]
121 for mpropdef
in mpropdefs
do
122 var mod
= mpropdef
.mclassdef
.mmodule
123 if doc
.mmodules
.has
(mod
) then mods
.add mod
125 concerns
= doc
.model
.concerns_tree
(mods
)
129 redef class MPropertyPage
131 # MPropdefs to display in this page.
132 var mpropdefs
= new HashSet[MPropDef]
134 redef fun build_concerns
(doc
) do
136 for mpropdef
in mentity
.mpropdefs
do
138 if mpropdef
.is_intro
then continue
139 if doc
.mpropdefs
.has
(mpropdef
) then mpropdefs
.add mpropdef
142 var mods
= new HashSet[MModule]
143 for mpropdef
in mpropdefs
do
144 var mod
= mpropdef
.mclassdef
.mmodule
145 if doc
.mmodules
.has
(mod
) then mods
.add mod
147 concerns
= doc
.model
.concerns_tree
(mods
)