-
-
Notifications
You must be signed in to change notification settings - Fork 352
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
add CtTypeMember.getTopLevelType() #1004
Conversation
@@ -30,6 +30,11 @@ | |||
* @return declaring class | |||
*/ | |||
@DerivedProperty | |||
CtType<?> getDeclaringType(); | |||
<T> CtType<T> getDeclaringType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not backward-compatible. do you really need to add generics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed that to solve another compilation problem in CtConstructorImpl ... but I will try different solution
|
||
/** | ||
* Returns top level declaring type of this. If this is already a TopLevelType, then it returns this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns the top level type declaring this type if an inner type. If this is already a top-level type, then returns itself.
* Returns top level declaring type of this. If this is already a TopLevelType, then it returns this | ||
*/ | ||
@DerivedProperty | ||
<T> CtType<T> getTopLevelType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes a lot of sense. it is OK to me.
I'm looking for exactly the same feature. |
excellent. Could you add tests? |
Is it possible to add a similar method that returns the parent type instead of the top level type? |
there is |
or |
Please merge it if it pass. I need this method in #1007 |
I have added new method
I need it for next PR, which brings some new Refactoring methods for changing of the name of the CtVariable based elements.
Please give me feedback, if such method is acceptable. If yes, then I will add test case too.
Note: I also moved some getDeclaringType to more common place in the hierarchy of CtExecutableImpl, so I did not had to copy the implementation of getTopLevelType 3 times.