Skip to content

Commit 55f2f71

Browse files
#103 improve
1 parent fa7ddbb commit 55f2f71

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

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

+12-11
Original file line numberDiff line numberDiff line change
@@ -637,29 +637,30 @@ private void inferInitialOrdering()
637637
*/
638638
protected CGNode getEnclosingMethodNode() throws IOException, CoreException, NoEnclosingMethodNodeFoundException {
639639
MethodReference methodReference = this.getEnclosingMethodReference();
640-
return getEnclosingMethodNode(methodReference);
641-
}
642-
643-
protected CGNode getEnclosingMethodNode(MethodReference methodReference)
644-
throws IOException, CoreException, NoEnclosingMethodNodeFoundException {
645640
Set<CGNode> nodes = this.getAnalysisEngine().getCallGraph().getNodes(methodReference);
646641

647642
if (nodes.isEmpty())
648643
throw new NoEnclosingMethodNodeFoundException(methodReference);
649644
else
650645
return nodes.iterator().next(); // just return the first.
651646
}
652-
647+
648+
/**
649+
* add all CGNodes in call graph to a hash set
650+
* @return a hash set of CGNode
651+
* @throws IOException
652+
* @throws CoreException
653+
* @throws NoEnclosingMethodNodeFoundException
654+
*/
653655
protected HashSet<CGNode> getEnclosingMethodNodes()
654656
throws IOException, CoreException, NoEnclosingMethodNodeFoundException {
655657
HashSet<CGNode> cgNodes = new HashSet<>();
656-
com.ibm.wala.classLoader.IMethod[] methods = ((CallStringContext) (getEnclosingMethodNode().getContext()))
657-
.getCallString().getMethods();
658658

659-
for (int i = 0; i < methods.length - 1; ++i) {
660-
cgNodes.add(getEnclosingMethodNode(methods[i].getReference()));
659+
Iterator<CGNode> cgNodeIterator = this.getAnalysisEngine().getCallGraph().iterator();
660+
for (; cgNodeIterator.hasNext();) {
661+
cgNodes.add(cgNodeIterator.next());
661662
}
662-
cgNodes.add(this.getEnclosingMethodNode());
663+
663664
return cgNodes;
664665
}
665666

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

-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ public void start() throws IOException, CoreException, CallGraphBuilderCancelExc
280280
// the node of where the stream was declared: TODO: Can this be
281281
// somehow rewritten to get blocks corresponding to terminal
282282
// operations?
283-
// CGNode cgNode = this.getStream().getEnclosingMethodNode();
284283
for (CGNode cgNode : this.getStream().getEnclosingMethodNodes()) {
285284
for (Iterator<CallSiteReference> callSites = cgNode.iterateCallSites(); callSites.hasNext();) {
286285
CallSiteReference callSiteReference = callSites.next();

0 commit comments

Comments
 (0)