|
1 |
| package koala.dynamicjava.tree; |
|
2 |
| |
|
3 |
| import java.util.List; |
|
4 |
| |
|
5 |
| import koala.dynamicjava.tree.visitor.Visitor; |
|
6 |
| |
|
7 |
| public class CompilationUnit extends Node { |
|
8 |
| |
|
9 |
| private PackageDeclaration package_; |
|
10 |
| private List<ImportDeclaration> imports; |
|
11 |
| private List<Node> declarations; |
|
12 |
| |
|
13 |
0
| public CompilationUnit(PackageDeclaration pkg, List<ImportDeclaration> imp, List<Node> decls) {
|
|
14 |
0
| this(pkg, imp, decls, SourceInfo.NONE);
|
|
15 |
| } |
|
16 |
| |
|
17 |
0
| public CompilationUnit(PackageDeclaration pkg, List<ImportDeclaration> imp, List<Node> decls, SourceInfo si) {
|
|
18 |
0
| super(si);
|
|
19 |
| |
|
20 |
0
| if (imp == null) throw new IllegalArgumentException("imp == null");
|
|
21 |
0
| if (decls == null) throw new IllegalArgumentException("decls == null");
|
|
22 |
| |
|
23 |
0
| package_ = pkg;
|
|
24 |
0
| imports = imp;
|
|
25 |
0
| declarations = decls;
|
|
26 |
| } |
|
27 |
| |
|
28 |
0
| public PackageDeclaration getPackage() {
|
|
29 |
0
| return package_;
|
|
30 |
| } |
|
31 |
| |
|
32 |
0
| public List<ImportDeclaration> getImports() {
|
|
33 |
0
| return imports;
|
|
34 |
| } |
|
35 |
| |
|
36 |
0
| public List<Node> getDeclarations() {
|
|
37 |
0
| return declarations;
|
|
38 |
| } |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
0
| public <T> T acceptVisitor(Visitor<T> visitor) {
|
|
45 |
0
| return visitor.visit(this);
|
|
46 |
| } |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
0
| public String toString() {
|
|
52 |
0
| return "("+getClass().getName()+": "+getPackage()+", " + getImports() + ", " + getDeclarations() + ")";
|
|
53 |
| } |
|
54 |
| } |