You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started to implement a refactoring method, which removes unused method parameters, which needs a list of all implementations and declarations of refactored method, which needs correct implementation of CtExecutableReference#isOverriding method, which actually fails on #1160, whose correct implementation needs some new methods around CtTypeParameter and it's reference.
I would like to implement fix for #1160, but I am not sure, how to design appropriate new Spoon API, which is needed to implement it in elegant way.
I actually touched these problems:
CtTypeParameterReference is by default created with parent==null. And therefore next call of CtTypeParameterReference#getDeclaration() returns null, because it is not able to detect scope where to search for type parameter declaration. So I think the parent field should be always initialized too - by default it might point directly to CtTypeParameter instance. Do you agree with that change?
In the example below, there are two classes O and P. The typed parameter A of class O (O$A) and typed parameter D of class P (P$D) are synonyms in scope of class P.
CtTypeReferencectType_P_D = ...//reference to P$DCtTypeReferencectType_O_A = ...//reference to O$A//both assertions should passassertTrue(ctType_O_A.isSubtypeOf(ctType_P_D));
assertTrue(ctType_P_D.isSubtypeOf(ctType_O_A));
//may be we need a new API method `isSame`, which would pass in that case too.assertTrue(ctType_P_D.isSame(ctType_O_A));
Do you agree to implement a method like CtTypeParameter#isSame? How it should be exactly named?
What is the actual type of typed parameter in child class.
If the class hierarchy X,O,P from example above is extended like this:
I get ctType_O_foo_B, which is CtTypeParameterReference with simple name B, which is declared in scope of method foo in class O. But I need to be able to detect that in scope of class R the reference points to something what extends InputStream.
So I would need a new spoon API method for that. But how that API should look like?
A) CtTypeParameterReference#getReferenceInScope(CtType)
B) CtTypeParameterReference#declaringType defines scope of type parameter and #parent defines view point.
Actually CtTypeParameterReference#parent is used to found a context/scope where CtTypeParameterReference#simpleName is defined. May be the there should be used CtTypeParameterReference#declaringType for that. Then CtTypeParameterReference#parent might be used (same like in case of CtTypeReference) to define place which is pointing at CtTypeParameter. Then the code would be like this:
I started to implement a refactoring method, which removes unused method parameters, which needs a list of all implementations and declarations of refactored method, which needs correct implementation of
CtExecutableReference#isOverriding
method, which actually fails on #1160, whose correct implementation needs some new methods around CtTypeParameter and it's reference.I would like to implement fix for #1160, but I am not sure, how to design appropriate new Spoon API, which is needed to implement it in elegant way.
I actually touched these problems:
CtTypeParameterReference
is by default created withparent==null
. And therefore next call ofCtTypeParameterReference#getDeclaration()
returns null, because it is not able to detect scope where to search for type parameter declaration. So I think theparent
field should be always initialized too - by default it might point directly to CtTypeParameter instance. Do you agree with that change?O
andP
. The typed parameterA
of classO
(O$A) and typed parameterD
of classP
(P$D) are synonyms in scope of classP
.In different words:
Do you agree to implement a method like
CtTypeParameter#isSame
? How it should be exactly named?If the class hierarchy X,O,P from example above is extended like this:
and then I write spoon code like:
I get
ctType_O_foo_B
, which is CtTypeParameterReference with simple nameB
, which is declared in scope of methodfoo
in classO
. But I need to be able to detect that in scope of classR
the reference points to something what extendsInputStream
.So I would need a new spoon API method for that. But how that API should look like?
A)
CtTypeParameterReference#getReferenceInScope(CtType)
B)
CtTypeParameterReference#declaringType
defines scope of type parameter and#parent
defines view point.Actually
CtTypeParameterReference#parent
is used to found a context/scope whereCtTypeParameterReference#simpleName
is defined. May be the there should be usedCtTypeParameterReference#declaringType
for that. ThenCtTypeParameterReference#parent
might be used (same like in case ofCtTypeReference
) to define place which is pointing atCtTypeParameter
. Then the code would be like this:Are there already some spoon methods, which supports that problem?
Do you have an concept how that API should look like?
The text was updated successfully, but these errors were encountered: