-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Switch to iterative algorithm to prevent stack overflows. #40211
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
|
Tagging @sharwell |
src/EditorFeatures/CSharp/Highlighting/KeywordHighlighters/AsyncAwaitHighlighter.cs
Outdated
Show resolved
Hide resolved
|
Note: i'd recommend reviewing this a commit at a time. |
f665d12 to
e55e787
Compare
CyrusNajmabadi
left a comment
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 preserved this logic (just in O(1) time instead of O(n)). But, overall, i think preserving this logic is pretty unnecessary. i don't see why we actually need it.
| spans[spans.Count - 1] = TextSpan.FromBounds(lastSpan.Start, mod.Span.End); | ||
| return true; | ||
| } | ||
| } |
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 preserved this logic (just in O(1) time instead of O(n)). But, overall, i think preserving this logic is pretty unnecessary. i don't see why we actually need it.
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.
It highlights the entire async code section rather than the highlighting the nested inside keywords Async and Await.
Personally i prefer the latter.
| return; | ||
| case LocalDeclarationStatementSyntax localDeclaration: | ||
| if (localDeclaration.AwaitKeyword.Kind() == SyntaxKind.AwaitKeyword && localDeclaration.UsingKeyword.Kind() == SyntaxKind.UsingKeyword) | ||
| if (localDeclaration.UsingKeyword.Kind() == SyntaxKind.UsingKeyword) |
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 preserved this logic. But i dont' actually think it's necessary. this basically ensures that we only highlight await in await using var whatever and not in await var whatever. However, the latter is broken code, so it would be fine IMO to highlight there.
| AnonymousFunctionExpressionSyntax anonymousFunction => TryAddAsyncOrAwaitKeyword(anonymousFunction.AsyncKeyword, spans), | ||
| UsingStatementSyntax usingStatement => TryAddAsyncOrAwaitKeyword(usingStatement.AwaitKeyword, spans), | ||
| LocalDeclarationStatementSyntax localDeclaration => | ||
| localDeclaration.UsingKeyword.Kind() == SyntaxKind.UsingKeyword && TryAddAsyncOrAwaitKeyword(localDeclaration.AwaitKeyword, spans), |
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 preserved this logic. But i dont' actually think it's necessary. this basically ensures that we only highlight await in await using var whatever and not in await var whatever. However, the latter is broken code, so it would be fine IMO to highlight there.
|
The would also need applying to the vb side as well. |
|
@AdamSpeight2008 my goal is not to harden the entirely of the IDE codebase to stack overflows. |
|
@sharwell LMK what you need here to proceed. |
|
@sharwell @jinujoseph LMK what you need here to proceed. |
src/EditorFeatures/CSharp/Highlighting/KeywordHighlighters/AsyncAwaitHighlighter.cs
Outdated
Show resolved
Hide resolved
|
@CyrusNajmabadi What is the observable impact of e55e787? There are disadvantages to both the before and after code and understanding the impact will help with the decision:
|
It was actually incorrect. i.e. it didn't highlight things properly. this was because it dove into nodes it shoudln't (i.e. an async lambda inside an async lambda).
Note: thsi was the same in both cases. calling |
src/EditorFeatures/CSharp/Highlighting/KeywordHighlighters/AsyncAwaitHighlighter.cs
Outdated
Show resolved
Hide resolved
The part I missed was the use of |
Absolutely! |
|
@sharwell good to merge this in? |
|
@sharwell everything has passed. merge when you can, thanks! |
|
Thanks! |
Fixes #40041