-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassSymbol.java
More file actions
67 lines (53 loc) · 1.63 KB
/
Copy pathClassSymbol.java
File metadata and controls
67 lines (53 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
public class ClassSymbol extends ClassDeclSymbol {
String className;
public ClassSymbol(String id, String className) {
super(id);
this.className = className;
}
public ClassSymbol(String id, String className, ClassDeclSymbol type) {
super(id);
this.className = className;
this.parentClass = type.parentClass;
this.fields = type.fields;
this.methods = type.methods;
}
public ClassSymbol(String id, ClassDeclSymbol type) {
super(id);
this.className = type.id;
this.parentClass = type.parentClass;
this.fields = type.fields;
this.methods = type.methods;
}
@Override
public boolean isInstanceOf(ClassDeclSymbol parent) {
if (this.className.equals(parent.id)) {
return true;
} else {
return super.isInstanceOf(parent);
}
}
private boolean isParentOfHelper(ClassSymbol parent, ClassDeclSymbol child) {
if (child == null) {
return false;
} else if (parent.className.equals(child.id)) {
return true;
} else {
return isParentOfHelper(parent, child.parentClass);
}
}
@Override
public boolean isParentOf(ClassDeclSymbol child) {
// TODO Auto-generated method stub
if (this.className.equals(child.id)) {
return true;
} else {
return isParentOfHelper(this, child.parentClass);
}
}
@Override
public String toString() {
// TODO Auto-generated method stub
String ret = className + " " + id;
return ret;
}
}