1212import com .github .javaparser .ast .stmt .BlockStmt ;
1313import com .github .javaparser .ast .type .ReferenceType ;
1414import com .github .javaparser .ast .type .Type ;
15- import com .github .javaparser .resolution .MethodAmbiguityException ;
16- import com .github .javaparser .resolution .UnsolvedSymbolException ;
1715import com .github .javaparser .resolution .types .ResolvedType ;
1816import com .github .javaparser .symbolsolver .JavaSymbolSolver ;
1917import com .github .javaparser .symbolsolver .resolution .typesolvers .CombinedTypeSolver ;
@@ -454,6 +452,7 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
454452 boolean isStaticCall = false ;
455453 String declaringType = "" ;
456454 String receiverName = "" ;
455+ String returnType = "" ;
457456 if (methodCallExpr .getScope ().isPresent ()) {
458457 Expression scopeExpr = methodCallExpr .getScope ().get ();
459458 receiverName = scopeExpr .toString ();
@@ -466,13 +465,14 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
466465 if (declaringTypeName .equals (scopeExpr .toString ())) {
467466 isStaticCall = true ;
468467 }
468+ returnType = resolveExpression (methodCallExpr );
469469 }
470470 // resolve arguments of the method call to types
471471 List <String > arguments = methodCallExpr .getArguments ().stream ()
472472 .map (arg -> resolveExpression (arg )).collect (Collectors .toList ());
473473 // add a new call site object
474474 callSites .add (createCallSite (methodCallExpr , methodCallExpr .getNameAsString (), receiverName , declaringType ,
475- arguments , isStaticCall , false ));
475+ arguments , returnType , isStaticCall , false ));
476476 }
477477
478478 for (ObjectCreationExpr objectCreationExpr : callableBody .get ().findAll (ObjectCreationExpr .class )) {
@@ -486,7 +486,7 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
486486 // add a new call site object
487487 callSites .add (createCallSite (objectCreationExpr , "<init>" ,
488488 objectCreationExpr .getScope ().isPresent () ? objectCreationExpr .getScope ().get ().toString () : "" ,
489- instantiatedType , arguments , false , true ));
489+ instantiatedType , arguments , instantiatedType , false , true ));
490490 }
491491
492492 return callSites ;
@@ -506,13 +506,14 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
506506 * @return
507507 */
508508 private static CallSite createCallSite (Expression callExpr , String calleeName , String receiverExpr ,
509- String receiverType , List <String > arguments , boolean isStaticCall ,
510- boolean isConstructorCall ) {
509+ String receiverType , List <String > arguments , String returnType ,
510+ boolean isStaticCall , boolean isConstructorCall ) {
511511 CallSite callSite = new CallSite ();
512512 callSite .setMethodName (calleeName );
513513 callSite .setReceiverExpr (receiverExpr );
514514 callSite .setReceiverType (receiverType );
515515 callSite .setArgumentTypes (arguments );
516+ callSite .setReturnType (returnType );
516517 callSite .setStaticCall (isStaticCall );
517518 callSite .setConstructorCall (isConstructorCall );
518519 if (callExpr .getRange ().isPresent ()) {
0 commit comments