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 .declarations .ResolvedConstructorDeclaration ;
16
- import com .github .javaparser .resolution .declarations .ResolvedMethodDeclaration ;
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 ;
@@ -491,14 +489,21 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
491
489
} else {
492
490
returnType = resolveExpression (methodCallExpr );
493
491
}
494
- ResolvedMethodDeclaration resolvedMethodDeclaration = methodCallExpr .resolve ();
492
+
493
+ // resolve callee and get signature
494
+ String calleeSignature = "" ;
495
+ try {
496
+ calleeSignature = methodCallExpr .resolve ().getSignature ();
497
+ } catch (RuntimeException exception ) {
498
+ Log .debug ("Could not resolve method call: " + methodCallExpr + ": " + exception .getMessage ());
499
+ }
495
500
496
501
// resolve arguments of the method call to types
497
502
List <String > arguments = methodCallExpr .getArguments ().stream ()
498
503
.map (SymbolTable ::resolveExpression ).collect (Collectors .toList ());
499
504
// add a new call site object
500
505
callSites .add (createCallSite (methodCallExpr , methodCallExpr .getNameAsString (), receiverName , declaringType ,
501
- arguments , returnType , resolvedMethodDeclaration . getSignature () , isStaticCall , false ));
506
+ arguments , returnType , calleeSignature , isStaticCall , false ));
502
507
}
503
508
504
509
for (ObjectCreationExpr objectCreationExpr : callableBody .get ().findAll (ObjectCreationExpr .class )) {
@@ -509,13 +514,18 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
509
514
List <String > arguments = objectCreationExpr .getArguments ().stream ()
510
515
.map (SymbolTable ::resolveExpression ).collect (Collectors .toList ());
511
516
512
- ResolvedConstructorDeclaration resolvedConstructorDeclaration = objectCreationExpr .resolve ();
517
+ // resolve callee and get signature
518
+ String calleeSignature = "" ;
519
+ try {
520
+ calleeSignature = objectCreationExpr .resolve ().getSignature ();
521
+ } catch (RuntimeException exception ) {
522
+ Log .debug ("Could not resolve constructor call: " + objectCreationExpr + ": " + exception .getMessage ());
523
+ }
513
524
514
525
// add a new call site object
515
526
callSites .add (createCallSite (objectCreationExpr , "<init>" ,
516
527
objectCreationExpr .getScope ().isPresent () ? objectCreationExpr .getScope ().get ().toString () : "" ,
517
- instantiatedType , arguments , instantiatedType , resolvedConstructorDeclaration .getSignature (),
518
- false , true ));
528
+ instantiatedType , arguments , instantiatedType , calleeSignature ,false , true ));
519
529
}
520
530
521
531
return callSites ;
0 commit comments