@@ -637,29 +637,30 @@ private void inferInitialOrdering()
637
637
*/
638
638
protected CGNode getEnclosingMethodNode () throws IOException , CoreException , NoEnclosingMethodNodeFoundException {
639
639
MethodReference methodReference = this .getEnclosingMethodReference ();
640
- return getEnclosingMethodNode (methodReference );
641
- }
642
-
643
- protected CGNode getEnclosingMethodNode (MethodReference methodReference )
644
- throws IOException , CoreException , NoEnclosingMethodNodeFoundException {
645
640
Set <CGNode > nodes = this .getAnalysisEngine ().getCallGraph ().getNodes (methodReference );
646
641
647
642
if (nodes .isEmpty ())
648
643
throw new NoEnclosingMethodNodeFoundException (methodReference );
649
644
else
650
645
return nodes .iterator ().next (); // just return the first.
651
646
}
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
+ */
653
655
protected HashSet <CGNode > getEnclosingMethodNodes ()
654
656
throws IOException , CoreException , NoEnclosingMethodNodeFoundException {
655
657
HashSet <CGNode > cgNodes = new HashSet <>();
656
- com .ibm .wala .classLoader .IMethod [] methods = ((CallStringContext ) (getEnclosingMethodNode ().getContext ()))
657
- .getCallString ().getMethods ();
658
658
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 ());
661
662
}
662
- cgNodes . add ( this . getEnclosingMethodNode ());
663
+
663
664
return cgNodes ;
664
665
}
665
666
0 commit comments