@@ -76,6 +76,7 @@ private static JSONExporter<Pair<String, Callable>, AbstractGraphEdge> getGraphE
7676 return gson .toJson (vertex );
7777 }
7878 );
79+ // exporter.setVertexAttributeProvider(v -> v.getRight().getAttributes());
7980 exporter .setEdgeAttributeProvider (AbstractGraphEdge ::getAttributes );
8081 return exporter ;
8182 }
@@ -151,6 +152,41 @@ private static org.jgrapht.Graph<Pair<String, Callable>, AbstractGraphEdge> buil
151152 }
152153 }
153154 }));
155+
156+ callGraph .getEntrypointNodes ()
157+ .forEach (p -> {
158+ // Get call statements that may execute in a given method
159+ Iterator <CallSiteReference > outGoingCalls = p .iterateCallSites ();
160+ outGoingCalls .forEachRemaining (n -> {
161+ callGraph .getPossibleTargets (p , n ).stream ()
162+ .filter (o -> AnalysisUtils .isApplicationClass (o .getMethod ().getDeclaringClass ()))
163+ .forEach (o -> {
164+
165+ // Add the source nodes to the graph as vertices
166+ Pair <String , Callable > source = Optional .ofNullable (getCallableFromSymbolTable (p .getMethod ())).orElseGet (() -> createAndPutNewCallableInSymbolTable (p .getMethod ()));
167+ graph .addVertex (source );
168+
169+ // Add the target nodes to the graph as vertices
170+ Pair <String , Callable > target = Optional .ofNullable (getCallableFromSymbolTable (o .getMethod ())).orElseGet (() -> createAndPutNewCallableInSymbolTable (o .getMethod ()));
171+ graph .addVertex (target );
172+
173+ if (!source .equals (target ) && source .getRight () != null && target .getRight () != null ) {
174+
175+ // Get the edge between the source and the target
176+ AbstractGraphEdge cgEdge = graph .getEdge (source , target );
177+
178+ if (cgEdge == null ) {
179+ graph .addEdge (source , target , new CallEdge ());
180+ }
181+ // If edge exists, then increment the weight
182+ else {
183+ cgEdge .incrementWeight ();
184+ }
185+ }
186+ });
187+ });
188+ });
189+
154190 return graph ;
155191 }
156192
0 commit comments