-
-
Notifications
You must be signed in to change notification settings - Fork 355
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: print square brackets for manually created array references #4888
fix: print square brackets for manually created array references #4888
Conversation
@I-Al-Istannen can you please review this? |
|
||
|
||
// act | ||
((CtArrayTypeReferenceImpl<?>) arrayTypeReference).setDeclarationKind(CtArrayTypeReferenceImpl.DeclarationKind.IDENTIFIER); |
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.
These explicit casts look ugly. I can move the APIs used in the CtArrayTypeReference
interface. I do not know why I did not implement it that way in #4341 . If the reviewers think this is a good idea, I can submit a separate PR for 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.
I think "hiding" that functionality makes sense - we probably shouldn't encourage people to make use of it. Otherwise you'd also need to add support for it on return types, i.e. public int method()[] { return new int[10]; }
😉
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.
Additionally, I am not sure how much value this offers as attaching the brackets to the name (or after the method...) is not a really common style from what I have gathered.
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.
public int method()[] { return new int[10]; }
Wow. I did not know that is a valid syntax. Maybe we can add support for it if someone ever reports a bug. However, it is so unlikely people shall use this syntax which is good :)
Additionally, I am not sure how much value this offers as attaching the brackets to the name (or after the method...) is not a really common style from what I have gathered.
Right. It does not seem useful from a transformation perspective so we can keep it as is.
src/test/java/spoon/reflect/visitor/DefaultJavaPrettyPrinterTest.java
Outdated
Show resolved
Hide resolved
Thanks :) |
Fixes #4887
The changes modify the constructor of
CtArrayTypeReferenceImpl
to set the declaration style asTYPE
by default.