Skip to content

Commit c6ce476

Browse files
committed
Extract method.
1 parent 4dd2a96 commit c6ce476

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/Util.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,4 +687,23 @@ private static boolean wouldOrderingBeConsistent(final Collection<TypeAbstractio
687687

688688
private Util() {
689689
}
690+
691+
/**
692+
* If it's a ctor, return the declaring class, otherwise, return the return
693+
* type.
694+
*
695+
* @param method
696+
* The {@link IMethod} in question.
697+
* @return The declaring class of target if target is a ctor and the return type
698+
* otherwise.
699+
*/
700+
public static TypeReference getEvaluationType(IMethod method) {
701+
// if it's a ctor.
702+
if (method.isInit())
703+
// then, use the declaring type.
704+
return method.getDeclaringClass().getReference();
705+
else // otherwise.
706+
// use the return type.
707+
return method.getReturnType();
708+
}
690709
}

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,7 @@ protected Map<CallStringTriple, CallStringWithReceivers> getCallStringWithReceiv
127127
*/
128128
@Override
129129
protected int getLength(CGNode caller, CallSiteReference site, IMethod target) {
130-
TypeReference typeToCheck;
131-
132-
// if it's a ctor.
133-
if (target.isInit())
134-
// then, use the declaring type.
135-
typeToCheck = target.getDeclaringClass().getReference();
136-
else // otherwise.
137-
// use the return type.
138-
typeToCheck = target.getReturnType();
139-
130+
TypeReference typeToCheck = Util.getEvaluationType(target);
140131
boolean implementsBaseStream = Util.implementsBaseStream(typeToCheck, target.getClassHierarchy());
141132

142133
if (implementsBaseStream)

0 commit comments

Comments
 (0)