@@ -76,6 +76,7 @@ private static JSONExporter<Pair<String, Callable>, AbstractGraphEdge> getGraphE
76
76
return gson .toJson (vertex );
77
77
}
78
78
);
79
+ // exporter.setVertexAttributeProvider(v -> v.getRight().getAttributes());
79
80
exporter .setEdgeAttributeProvider (AbstractGraphEdge ::getAttributes );
80
81
return exporter ;
81
82
}
@@ -151,6 +152,41 @@ private static org.jgrapht.Graph<Pair<String, Callable>, AbstractGraphEdge> buil
151
152
}
152
153
}
153
154
}));
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
+
154
190
return graph ;
155
191
}
156
192
0 commit comments