-
Notifications
You must be signed in to change notification settings - Fork 439
Improved Diagnostic for C-style for loop #1540
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
@swift-ci please test |
I have to think about the right approach, I think |
Syntax(node.unexpectedBetweenWhereClauseAndBody), | ||
Syntax(unexpectedCondition), | ||
] as [Syntax?]).compactMap({ $0 }), | ||
highlights: (getTokens(between: firstToken, and: lastToken).map { Optional(Syntax($0)) }).compactMap({ $0 }), |
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.
Why do you need to explicitly spell out Optional
here?
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 was thinking about replicating as [Syntax?]
,
However, the test failing is testColoringWithHighlights()
. The problem seems to be that with getTokens
we are creating an array of tokens, which is not what was happening previously. Do you think I should find a way to walk through node
's children?
What about this solution? Obviously, it's very primitive, if you think that's the right approach I'll refine it |
If we need to write a new function for this, I don’t think it’s worth it. The C-style for loop diagnostic is a bit of a weirdo anyway and unless a new use case for |
@ahoppen seems reasonable, what about this last attempt? Otherwise, I'll just close the PR |
This makes implicit assumptions about the number of children of a for loop that we are not interested in, which might change if we changed the structure of for loops. I’d just close the PR, sorry. |
Improved Diagnostic for C-style for loop using
getTokens
introduced by #1464