-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
WiP: feature: CtSuperTypeHierarchy #1243
Conversation
865d627
to
62a15dd
Compare
The core responsibility of this new class is |
yes. The core is "to be able to compute details about super inheritence hierarchy", which is needed to deliver these features:
|
OK. We'll have to discuss on how to integrate this kind of feature in the repo, but first, I want to well understand what you mean by Could you elaborate on the example given in the Javadoc? |
62a15dd
to
bbe9000
Compare
The target of all these small PRs is to be able to correctly detect whether one method overrides another method. So please have a look at this test. There is a complex class hierarchy of generic classes and generic inner classes. There are 3 implementations of method |
here is the big picture: I want to implement a refactoring, which will remove method parameters. That needs an algorithm which founds all declarations and implementations of methods with same signature on the same type hierarchy. Therefore I need to correctly detect whether two methods have same signature (method A overrides B). And following java lang specification, one of the steps in the method signature comparation is adapting of type parameters. class Parent<T,K> {
void someMethod(T p1, K p2);
}
class Child1 extends Parent<Integer,Double> {
void someMethod(Integer p1, Double p2);
} Now I want to detect whether
class Parent {
void someMethod(Integer p1, Double p2);
}
class Child1 extends Parent {
void someMethod(Integer p1, Double p2);
} In this model it is easily possible to compare method signatures, because type parameters are adapted to scope of Child1. The class Now little bit more complicated example to explain why I started with PR #1238. class Parent<T,K> {
void someMethod(T p1, K p2);
}
class Child2<M> extends Parent<Double,M> {
void someMethod(Double p1, M p2);
} In this case the super type hierarchy model of Child2, where each parameter is adapted looks like this: class Parent {
void someMethod(Double p1, M p2);
}
class Child2<M> extends Parent {
void someMethod(Double p1, M p2);
} Note the usage of |
0ae4ad2
to
388a35e
Compare
we're getting closer to merge.
|
yes, I am open to better name. But let's wait some more days with merge and name decision until I finish the "method overrides" detection code - it is the main client of CtSuperTypeHierarchy for now and I would prefer to have free hands with further refactoring of CtSuperTypeHierarchy , when something might be done better. Note: CtSuperTypeHierarchy is able to adapt generic types declared in scope of CtType. I have nearly finished another similar helper class, which will adapt generic types declared in scope of CtMethod. I call it actually
At the beginning I though that CtSuperTypeHierarchy is a mapping function, but now I see it is not. So it should be may be moved to different package and does not belong to Query. I guess some method(s) might be added to CtType(Parameter)(Reference). Explanation: Mapping function has one responsibility, but CtSuperTypeHierarchy has more. There are:
|
a3ec565
to
46d436a
Compare
46d436a
to
8e16227
Compare
I guess this one can be closed. |
Yes, it's content was already merged by PR #1218 |
CtSuperTypeHierarchy
is a new helper class, which provides access to actual type arguments of any super type of type X adapted to type X