-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ExpressionLanguage] Add comment support to expression language #54978
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
Conversation
Hey! Thanks for your PR. You are targeting branch "7.1" but it seems your PR description refers to branch "7.2". Cheers! Carsonbot |
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.
This feature is useful when used with user input where it is not otherwise possible to add comments in the code.
I think you could add tests on expressions like /* /* comment */
and /* comment */ */
to ensure the regex catch the right comment separators.
d5ce011
to
c762141
Compare
Added some extra tests + changelog (too late for 7.1 as I understand) |
c762141
to
d50ca10
Compare
1fa8629
to
0f8dee7
Compare
Thank you @valtzu. |
When expression language expressions are provided by the user, it would be really helpful if we could include comments in the expression. Many times the user will write something like
which in my opinion, would be much better with a comment
so that the next person reading the expression knows what the magical 123 is.
The implementation is quite simple, given it's ok to strip the comments from AST & the compiled version.
Why
/*
&*/
This seems to be the most common way among different programming languages, including JS, C#, Go, C, PHP, Java, Rust – also in business scenarios you often times want multi-line comments, for which this syntax usually stands for. Also, this makes it possible to use comments in the middle of single-line expressions.
At the moment, unlike multi-line comments in PHP, we always require closing
*/
.