Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Dec 23, 2023
1 parent fb2c457 commit 320e642
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public NullnessHint onDataflowVisitMethodInvocation(
return NullnessHint.UNKNOWN;
}

/**
* Returns the AccessPath for the argument of an assertThat() call, if present as a valid nested
* receiver expression of a method invocation
*
* @param node the method invocation node
* @param state the visitor state
* @param apContext the access path context
* @return the AccessPath for the argument of the assertThat() call, if present, otherwise {@code
* null}
*/
private @Nullable AccessPath getAccessPathForNotNullExpr(
MethodInvocationNode node, VisitorState state, AccessPath.AccessPathContext apContext) {
Node receiver = node.getTarget().getReceiver();
Expand All @@ -97,7 +107,8 @@ public NullnessHint onDataflowVisitMethodInvocation(
if (methodNameUtil.isMethodAssertThat(receiver_symbol)) {
Node arg = receiver_method.getArgument(0);
return AccessPath.getAccessPathForNode(arg, state, apContext);
} else if (methodNameUtil.isMethodDescribedAs(receiver_symbol)) {
} else if (methodNameUtil.isMethodAssertJDescribedAs(receiver_symbol)) {
// For calls to as() or describedAs(), we recursively search for the assertThat() call
return getAccessPathForNotNullExpr(receiver_method, state, apContext);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ boolean isMethodAssertThat(Symbol.MethodSymbol methodSymbol) {
|| matchesMethod(methodSymbol, assertThat, assertThatOwnerAssertJ);
}

public boolean isMethodDescribedAs(Symbol.MethodSymbol methodSymbol) {
public boolean isMethodAssertJDescribedAs(Symbol.MethodSymbol methodSymbol) {
// describedAs() and as() are equivalent. Also, we do not check the owner, as there are many
// possible implementations. This method should only be used in a caller content where it is
// clear that the operation is related to use of AssertJ.
return methodSymbol.name.equals(as) || methodSymbol.name.equals(describedAs);
}

Expand Down

0 comments on commit 320e642

Please sign in to comment.