-
-
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 necessary parentheses when accessing a new array directly #4239
Conversation
CtModel model = SpoonTestHelpers.createModelFromString(code, 8); | ||
CtType<?> first = model.getAllTypes().iterator().next(); | ||
assertThat(first.toString(), containsString(line)); | ||
CtCodeSnippetStatement statement = launcher.getFactory().createCodeSnippetStatement(line); |
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.
if you pretty-print a CtCodeSnippetStatement, it's the input line, so the assert is useless. you have to call compile first to transform the CtCodeSnippetStatement into an AST
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.
Oh yeah, that wasn't meant to end up there. Thanks for catching it.
LGTM, needs to fix conflicts |
b3adc93
to
83a66e5
Compare
Rebased (and removed unused code I added before) |
Cool, nice Friday contribution :) |
Previously, a statement like
int a = (new int[10])[1];
was printed likeint a = new int[10][1];
. This won't compile anymore as the types aren't compatible.While I hope I'll never come across such code anywhere, I thought it would be worth to fix it.