use of com.github.sevntu.checkstyle.domain.RefCall in project methods-distance by sevntu-checkstyle.
the class MethodCallDependencyCheckstyleModule method tryResolveRefCall.
private static Optional<ResolvedCall> tryResolveRefCall(ClassDefinition classDefinition, DetailAST refCallNode) {
final RefCall call = new RefCall(classDefinition, refCallNode);
return Optional.of(call).filter(RefCall::isRefToMethodOfEnclosingClass).map(refCall -> {
return refCall.isRefToStaticMethodOfEnclosingClass() ? classDefinition.getStaticMethodsByName(refCall.getMethodName()) : classDefinition.getInstanceMethodsByName(refCall.getMethodName());
}).filter(list -> !list.isEmpty()).map(possibleMethods -> {
final MethodDefinition callee = possibleMethods.get(0);
final MethodDefinition caller = classDefinition.getMethodByAstNode(call.getEnclosingMethod());
return new ResolvedCall(refCallNode, caller, callee);
});
}
Aggregations