-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathRefinedVariable.java
More file actions
100 lines (83 loc) · 2.8 KB
/
RefinedVariable.java
File metadata and controls
100 lines (83 loc) · 2.8 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package liquidjava.processor.context;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import liquidjava.rj_language.Predicate;
import liquidjava.utils.Utils;
import spoon.reflect.cu.SourcePosition;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.reference.CtTypeReference;
public abstract class RefinedVariable extends Refined {
private final List<CtTypeReference<?>> supertypes;
private PlacementInCode placementInCode;
private boolean isParameter;
private SourcePosition annPosition;
private Predicate failingRefinement;
public RefinedVariable(String name, CtTypeReference<?> type, Predicate c) {
super(name, type, c);
supertypes = new ArrayList<>();
isParameter = false;
}
public abstract Predicate getMainRefinement();
public void addSuperType(CtTypeReference<?> t) {
if (!supertypes.contains(t))
supertypes.add(t);
}
public List<CtTypeReference<?>> getSuperTypes() {
return supertypes;
}
public void addSuperTypes(CtTypeReference<?> ts, Set<CtTypeReference<?>> sts) {
if (ts != null && !supertypes.contains(ts))
supertypes.add(ts);
for (CtTypeReference<?> ct : sts)
if (ct != null && !supertypes.contains(ct))
supertypes.add(ct);
}
public void addPlacementInCode(CtElement element) {
placementInCode = PlacementInCode.createPlacement(element);
annPosition = Utils.getFirstLJAnnotationPosition(element);
}
public void addPlacementInCode(PlacementInCode placement) {
placementInCode = placement;
}
public PlacementInCode getPlacementInCode() {
return placementInCode;
}
public SourcePosition getAnnPosition() {
return annPosition;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((supertypes == null) ? 0 : supertypes.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
RefinedVariable other = (RefinedVariable) obj;
if (supertypes == null) {
return other.supertypes == null;
} else {
return supertypes.equals(other.supertypes);
}
}
public void setIsParameter(boolean b) {
isParameter = b;
}
public boolean isParameter() {
return isParameter;
}
public void setFailingRefinement(Predicate failingRefinement) {
this.failingRefinement = failingRefinement;
}
public Predicate getFailingRefinement() {
return failingRefinement;
}
}