Skip to content

Commit 7f8db2e

Browse files
committed
Clean up.
1 parent 6c6a374 commit 7f8db2e

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/wala/nCFAContextWithReceiversSelector.java

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,27 @@
1919

2020
public class nCFAContextWithReceiversSelector extends nCFAContextSelector {
2121

22-
/**
23-
* The N to use if the instance implements BaseStream.
24-
*/
25-
public static final int CONTEXT_LENGTH_FOR_STREAMS = 2;
26-
2722
protected class CallStringTriple {
2823

24+
CGNode node;
25+
26+
CallSiteReference site;
27+
IMethod target;
28+
2929
public CallStringTriple(CGNode node, CallSiteReference site, IMethod target) {
3030
this.node = node;
3131
this.site = site;
3232
this.target = target;
3333
}
3434

35-
CGNode node;
36-
CallSiteReference site;
37-
IMethod target;
35+
@Override
36+
public boolean equals(Object obj) {
37+
if (obj instanceof CallStringTriple) {
38+
CallStringTriple rhs = (CallStringTriple) obj;
39+
return this.node.equals(rhs.node) && this.site.equals(rhs.site) && this.target.equals(rhs.target);
40+
} else
41+
return false;
42+
}
3843

3944
@Override
4045
public int hashCode() {
@@ -46,17 +51,13 @@ public int hashCode() {
4651

4752
return builder.toString().hashCode();
4853
}
49-
50-
@Override
51-
public boolean equals(Object obj) {
52-
if (obj instanceof CallStringTriple) {
53-
CallStringTriple rhs = (CallStringTriple) obj;
54-
return this.node.equals(rhs.node) && this.site.equals(rhs.site) && this.target.equals(rhs.target);
55-
} else
56-
return false;
57-
}
5854
}
5955

56+
/**
57+
* The N to use if the instance implements BaseStream.
58+
*/
59+
public static final int CONTEXT_LENGTH_FOR_STREAMS = 2;
60+
6061
protected Map<CallStringTriple, CallStringWithReceivers> callStringWithReceiversMap = new HashMap<>();
6162

6263
public nCFAContextWithReceiversSelector(int n, ContextSelector base) {
@@ -66,15 +67,14 @@ public nCFAContextWithReceiversSelector(int n, ContextSelector base) {
6667
@Override
6768
public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee,
6869
InstanceKey[] actualParameters) {
69-
Context baseContext = base.getCalleeTarget(caller, site, callee, actualParameters);
70-
CallStringWithReceivers cs = getCallString(caller, site, callee, actualParameters);
71-
if (cs == null) {
70+
Context baseContext = this.base.getCalleeTarget(caller, site, callee, actualParameters);
71+
CallStringWithReceivers cs = this.getCallString(caller, site, callee, actualParameters);
72+
if (cs == null)
7273
return baseContext;
73-
} else if (baseContext == Everywhere.EVERYWHERE) {
74+
else if (baseContext == Everywhere.EVERYWHERE)
7475
return new CallStringContext(cs);
75-
} else {
76+
else
7677
return new CallStringContextPair(cs, baseContext);
77-
}
7878
}
7979

8080
protected CallStringWithReceivers getCallString(CGNode caller, CallSiteReference site, IMethod target,
@@ -94,17 +94,15 @@ protected CallStringWithReceivers getCallString(CGNode caller, CallSiteReference
9494
// not found. Compute it.
9595
CallStringWithReceivers ret = null;
9696

97-
int length = getLength(caller, site, target);
97+
int length = this.getLength(caller, site, target);
9898
if (length > 0) {
99-
if (caller.getContext().get(CALL_STRING) != null) {
99+
if (caller.getContext().get(CALL_STRING) != null)
100100
ret = new CallStringWithReceivers(site, caller.getMethod(), length,
101101
(CallString) caller.getContext().get(CALL_STRING));
102-
} else {
102+
else
103103
ret = new CallStringWithReceivers(site, caller.getMethod());
104-
}
105-
} else {
104+
} else
106105
ret = null;
107-
}
108106

109107
// if we have a receiver.
110108
if (ret != null && actualParameters != null && actualParameters.length > 0)
@@ -117,14 +115,14 @@ protected CallStringWithReceivers getCallString(CGNode caller, CallSiteReference
117115
}
118116

119117
protected Map<CallStringTriple, CallStringWithReceivers> getCallStringWithReceiversMap() {
120-
return callStringWithReceiversMap;
118+
return this.callStringWithReceiversMap;
121119
}
122120

123121
/**
124122
* {@inheritDoc}
125-
*
126-
* @return CONTEXT_LENGTH_FOR_STREAMS if the target's return type implements {@link BaseStream},
127-
* otherwise, return the original value.
123+
*
124+
* @return CONTEXT_LENGTH_FOR_STREAMS if the target's return type implements
125+
* {@link BaseStream}, otherwise, return the original value.
128126
*/
129127
@Override
130128
protected int getLength(CGNode caller, CallSiteReference site, IMethod target) {

0 commit comments

Comments
 (0)