12
12
import com .github .javaparser .ast .stmt .BlockStmt ;
13
13
import com .github .javaparser .ast .type .ReferenceType ;
14
14
import com .github .javaparser .ast .type .Type ;
15
- import com .github .javaparser .resolution .MethodAmbiguityException ;
16
- import com .github .javaparser .resolution .UnsolvedSymbolException ;
17
15
import com .github .javaparser .resolution .types .ResolvedType ;
18
16
import com .github .javaparser .symbolsolver .JavaSymbolSolver ;
19
17
import com .github .javaparser .symbolsolver .resolution .typesolvers .CombinedTypeSolver ;
@@ -454,6 +452,7 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
454
452
boolean isStaticCall = false ;
455
453
String declaringType = "" ;
456
454
String receiverName = "" ;
455
+ String returnType = "" ;
457
456
if (methodCallExpr .getScope ().isPresent ()) {
458
457
Expression scopeExpr = methodCallExpr .getScope ().get ();
459
458
receiverName = scopeExpr .toString ();
@@ -466,13 +465,14 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
466
465
if (declaringTypeName .equals (scopeExpr .toString ())) {
467
466
isStaticCall = true ;
468
467
}
468
+ returnType = resolveExpression (methodCallExpr );
469
469
}
470
470
// resolve arguments of the method call to types
471
471
List <String > arguments = methodCallExpr .getArguments ().stream ()
472
472
.map (arg -> resolveExpression (arg )).collect (Collectors .toList ());
473
473
// add a new call site object
474
474
callSites .add (createCallSite (methodCallExpr , methodCallExpr .getNameAsString (), receiverName , declaringType ,
475
- arguments , isStaticCall , false ));
475
+ arguments , returnType , isStaticCall , false ));
476
476
}
477
477
478
478
for (ObjectCreationExpr objectCreationExpr : callableBody .get ().findAll (ObjectCreationExpr .class )) {
@@ -486,7 +486,7 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
486
486
// add a new call site object
487
487
callSites .add (createCallSite (objectCreationExpr , "<init>" ,
488
488
objectCreationExpr .getScope ().isPresent () ? objectCreationExpr .getScope ().get ().toString () : "" ,
489
- instantiatedType , arguments , false , true ));
489
+ instantiatedType , arguments , instantiatedType , false , true ));
490
490
}
491
491
492
492
return callSites ;
@@ -506,13 +506,14 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
506
506
* @return
507
507
*/
508
508
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 ) {
511
511
CallSite callSite = new CallSite ();
512
512
callSite .setMethodName (calleeName );
513
513
callSite .setReceiverExpr (receiverExpr );
514
514
callSite .setReceiverType (receiverType );
515
515
callSite .setArgumentTypes (arguments );
516
+ callSite .setReturnType (returnType );
516
517
callSite .setStaticCall (isStaticCall );
517
518
callSite .setConstructorCall (isConstructorCall );
518
519
if (callExpr .getRange ().isPresent ()) {
0 commit comments