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 ;
15
17
import com .github .javaparser .resolution .types .ResolvedType ;
16
18
import com .github .javaparser .symbolsolver .JavaSymbolSolver ;
17
19
import com .github .javaparser .symbolsolver .resolution .typesolvers .CombinedTypeSolver ;
27
29
import org .apache .commons .lang3 .tuple .Pair ;
28
30
29
31
import java .io .IOException ;
30
- import java .nio .file .Path ;
31
- import java .nio .file .Paths ;
32
+ import java .nio .file .*;
32
33
import java .util .*;
33
34
import java .util .stream .Collectors ;
34
35
import java .util .stream .IntStream ;
@@ -490,13 +491,14 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
490
491
} else {
491
492
returnType = resolveExpression (methodCallExpr );
492
493
}
494
+ ResolvedMethodDeclaration resolvedMethodDeclaration = methodCallExpr .resolve ();
493
495
494
496
// resolve arguments of the method call to types
495
497
List <String > arguments = methodCallExpr .getArguments ().stream ()
496
- .map (arg -> resolveExpression ( arg ) ).collect (Collectors .toList ());
498
+ .map (SymbolTable :: resolveExpression ).collect (Collectors .toList ());
497
499
// add a new call site object
498
500
callSites .add (createCallSite (methodCallExpr , methodCallExpr .getNameAsString (), receiverName , declaringType ,
499
- arguments , returnType , isStaticCall , false ));
501
+ arguments , returnType , resolvedMethodDeclaration . getSignature (), isStaticCall , false ));
500
502
}
501
503
502
504
for (ObjectCreationExpr objectCreationExpr : callableBody .get ().findAll (ObjectCreationExpr .class )) {
@@ -505,12 +507,15 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
505
507
506
508
// resolve arguments of the constructor call to types
507
509
List <String > arguments = objectCreationExpr .getArguments ().stream ()
508
- .map (arg -> resolveExpression (arg )).collect (Collectors .toList ());
510
+ .map (SymbolTable ::resolveExpression ).collect (Collectors .toList ());
511
+
512
+ ResolvedConstructorDeclaration resolvedConstructorDeclaration = objectCreationExpr .resolve ();
509
513
510
514
// add a new call site object
511
515
callSites .add (createCallSite (objectCreationExpr , "<init>" ,
512
516
objectCreationExpr .getScope ().isPresent () ? objectCreationExpr .getScope ().get ().toString () : "" ,
513
- instantiatedType , arguments , instantiatedType , false , true ));
517
+ instantiatedType , arguments , instantiatedType , resolvedConstructorDeclaration .getSignature (),
518
+ false , true ));
514
519
}
515
520
516
521
return callSites ;
@@ -531,13 +536,14 @@ private static List<CallSite> getCallSites(Optional<BlockStmt> callableBody) {
531
536
*/
532
537
private static CallSite createCallSite (Expression callExpr , String calleeName , String receiverExpr ,
533
538
String receiverType , List <String > arguments , String returnType ,
534
- boolean isStaticCall , boolean isConstructorCall ) {
539
+ String calleeSignature , boolean isStaticCall , boolean isConstructorCall ) {
535
540
CallSite callSite = new CallSite ();
536
541
callSite .setMethodName (calleeName );
537
542
callSite .setReceiverExpr (receiverExpr );
538
543
callSite .setReceiverType (receiverType );
539
544
callSite .setArgumentTypes (arguments );
540
545
callSite .setReturnType (returnType );
546
+ callSite .setCalleeSignature (calleeSignature );
541
547
callSite .setStaticCall (isStaticCall );
542
548
callSite .setConstructorCall (isConstructorCall );
543
549
if (callExpr .getRange ().isPresent ()) {
0 commit comments