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.
16 import model
::module_compound
18 var graph
= new ProjectGraph("foo")
19 var file
= new FileCompound(graph
)
20 var file_2
= new FileCompound(graph
)
21 var bar_class
= new ClassCompound(graph
)
22 var baz_class
= new ClassCompound(graph
)
23 var a_ns
= new Namespace(graph
)
24 var b_ns
= new Namespace(graph
)
25 var c_ns
= new Namespace(graph
)
26 var d_ns
= new Namespace(graph
)
27 var buffer
= new RopeBuffer
28 var root_ns
= graph
.by_id
[""].as(Namespace)
29 var location
: Location
31 file
.name
= "Bar.java"
32 file
.model_id
= "_Bar_8java"
33 location
= new Location
34 location
.path
= "a/b/Bar.java"
35 file
.location
= location
36 file
.declare_class
("classa_b_bar", "a::b::Bar", "package")
37 file
.declare_class
("classbaz", "Baz", "")
38 file
.declare_namespace
("", "a::b")
39 file
.doc
.brief_description
= "The first file."
42 file_2
.name
= "Bar.java"
43 file_2
.model_id
= "_Bar_8java_2"
44 location
= new Location
45 location
.path
= "Bar.java"
46 file_2
.location
= location
47 file_2
.declare_namespace
("namespacec", "c")
48 file_2
.declare_namespace
("", "d")
51 bar_class
.model_id
= "classa_b_bar"
52 bar_class
.name
= "Bar"
53 location
= new Location
54 location
.path
= "a/b/Bar.class"
55 location
.line_start
= 5
56 location
.column_start
= 1
57 location
.line_end
= 100
58 location
.column_end
= 10
59 bar_class
.location
= location
60 bar_class
.put_in_graph
62 baz_class
.model_id
= "classbaz"
63 baz_class
.name
= "Baz"
64 location
= new Location
65 location
.path
= "Baz.jar"
66 baz_class
.location
= location
67 baz_class
.put_in_graph
69 root_ns
.declare_namespace
("", "a")
70 root_ns
.declare_namespace
("namespacec", "c")
71 root_ns
.declare_namespace
("", "d")
75 a_ns
.declare_namespace
("", "a::b")
79 b_ns
.full_name
= "a::b"
80 b_ns
.declare_class
("classa_b_bar", "", "")
83 c_ns
.model_id
= "namespacec"
88 d_ns
.model_id
= "namespaced"
93 print
"---===WITHOUT GLOBALS===---"
98 print
"---===WITH GLOBALS===---"
100 graph
.add_global_modules