Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consolidate a consistent behavior for CtElement#getParent #3793

Merged
merged 10 commits into from
Feb 24, 2021
4 changes: 4 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,15 @@ <E extends CtElement> List<E> getAnnotatedChildren(

/**
* Gets the first parent that matches the given type.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you document this with an @return, in particular that it returns null if there's no match?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is based on the discussion we had previously about the poor documentation of null returns in Spoon :)

*
* @return null when a matching parent was not found or this element doesn't have a parent
sibwaf marked this conversation as resolved.
Show resolved Hide resolved
*/
<P extends CtElement> P getParent(Class<P> parentType);

/**
* Gets the first parent that matches the filter.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

*
* @return null when a matching parent was not found or this element doesn't have a parent
sibwaf marked this conversation as resolved.
Show resolved Hide resolved
*/
<E extends CtElement> E getParent(Filter<E> filter);

Expand Down