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
Comments can be added to CtFieldReferenceImpl, but they are not considered for cloning and equals methods. Given that comments are disallowed for references in general then why can we add them to CtFieldReferenceImpl and they get stored?
Maybe it is just a misunderstanding of mine, but there seems to be an inconsistency in how this is handled compared to other Ct elements, as for example there are other Ct references that discard the comments when they are added.
Source code you are trying to analyze/transform
No response
Source code for your Spoon processing
@TestpublicvoidspoonTest() {
spoon.support.DefaultCoreFactorydfc = newDefaultCoreFactory();
spoon.compiler.Environmente = newspoon.support.StandardEnvironment();
spoon.reflect.factory.Factoryf = newspoon.reflect.factory.FactoryImpl(dfc, e);
CtCommentcmt = f.createComment();
cmt.setContent("This is a comment");
CtFieldReference<String> cfr = f.createFieldReference();
cfr.setSimpleName("field1");
//NOTE: References do not allow comments to be set... but we can add one... //that it is not cloned, but preferably it should not be added either...cfr.addComment(cmt);
cmt.setParent(cmt);
assertEquals("FieldReference should have one comment", 1, cfr.getComments().size());
CtFieldReference<String> clonedCfr = cfr.clone();
assertEquals("Cloned and original objects should be equal", cfr, clonedCfr);
assertEquals("Cloned object should have one comment", clonedCfr.getComments().size());
}
Describe the bug
Comments can be added to CtFieldReferenceImpl, but they are not considered for cloning and equals methods. Given that comments are disallowed for references in general then why can we add them to CtFieldReferenceImpl and they get stored?
Maybe it is just a misunderstanding of mine, but there seems to be an inconsistency in how this is handled compared to other Ct elements, as for example there are other Ct references that discard the comments when they are added.
Source code you are trying to analyze/transform
No response
Source code for your Spoon processing
Actual output
Expected output
Spoon Version
11.1.0
JVM Version
Java 17
What operating system are you using?
NixOS 24.11 (Vicuna)
The text was updated successfully, but these errors were encountered: