Skip to content

Commit 6522584

Browse files
committed
Extract method.
1 parent ae910e7 commit 6522584

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
@@ -669,4 +669,23 @@ private static boolean wouldOrderingBeConsistent(final Collection<TypeAbstractio
669669

670670
private Util() {
671671
}
672+
673+
/**
674+
* If it's a ctor, return the declaring class, otherwise, return the return
675+
* type.
676+
*
677+
* @param method
678+
* The {@link IMethod} in question.
679+
* @return The declaring class of target if target is a ctor and the return type
680+
* otherwise.
681+
*/
682+
public static TypeReference getEvaluationType(IMethod method) {
683+
// if it's a ctor.
684+
if (method.isInit())
685+
// then, use the declaring type.
686+
return method.getDeclaringClass().getReference();
687+
else // otherwise.
688+
// use the return type.
689+
return method.getReturnType();
690+
}
672691
}

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)