-
Notifications
You must be signed in to change notification settings - Fork 440
add fix-its for a bare regex literal with leading and/or trailing spaces #2744
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
add fix-its for a bare regex literal with leading and/or trailing spaces #2744
Conversation
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.
You should be able to remove the TODO
in RegexLiteralLexer.swift:259 as well.
I've found two other |
aeca20b
to
148533e
Compare
Good catch. You can remove them as well. |
Looks good to me, I’d just like to see the following two addressed: |
148533e
to
9dbaab0
Compare
// TODO: We ought to have a fix-it that suggests #/.../#. We could
// suggest escaping, but that would be wrong if the user has written (?x).
// TODO: Should we suggest #/.../# for space-as-first character too? I don't quite understand what "that would be wrong if the user has written (?x)." means, I am hesitating to remove these two |
07ea8b4
to
47b2113
Compare
47b2113
to
f73f4d0
Compare
We support an "extended syntax mode" in regex literals, which can be enabled with |
Thanks for your detailed explanation! Considering that the parser of now will never emit diagnostics for the trailing space case alone, I guess we can safely discard the two |
IIRC it can be emitted for things like this: let x = /, / (Oh huh I never added a test for that, my bad) |
I got it, I will revert back to my earlier design that the presence of a trailing space will mandate only "convert to extended regex literal with '#'" as the only Fix-it. |
8e94551
to
8ee1211
Compare
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.
Could you also address this comment?
8ee1211
to
f7119d9
Compare
Done, please check. |
@swift-ci Please test |
@swift-ci Please test Windows |
added "convert to extended regex literal" and/or "insert '\'" to `SwiftSyntax.TokenDiagnostic.fixIts` introduced a more general `assertParse` that can test for different combinations of fix-its against fixed sources modified related test cases
Head branch was pushed to by a user without write access
f7119d9
to
bba7b15
Compare
@swift-ci Please test |
The check statuses have stayed unchanged for 5 days, could there be any problem with the CI? |
@swift-ci please test |
fix #1479