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 # Add support for namespace’s members.
16 module model
::namespace_members
22 # The class that contains the namespace’s direct members.
24 # Left `null` for the root namespace and for any namespace with no direct
25 # member. Automatically put in the graph with the namespace.
27 # Note: In the graph, the `self_class` not linked directly to the namespace.
28 # This is the role of the modules implicitly created by `FileCompound`s to
29 # link a namespace to its `self_class`.
31 # SEE: `declare_member`
32 var self_class
: nullable SelfClass = null
34 # Add the specified member as a direct children of the namespace.
35 redef fun declare_member
(member
) do
36 if self_class
== null then self_class
= new SelfClass(graph
, self)
37 self_class
.as(not null).declare_member
(member
)
40 redef fun put_in_graph
do
42 var self_class
= self.self_class
43 if self_class
isa SelfClass then self_class
.put_in_graph
47 redef class RootNamespace
48 redef fun declare_member
(member
) do
50 # TODO Check how Doxygen modelize member of the root namespace.
51 # Note: Doxygen does not modelize the root namespace.
52 sys
.stderr
.write
"The addition of a member to the root namespace is not supported yet."
57 # A class that contains a namespace’s direct members.
61 # The namespace of the members
62 var namespace
: Namespace