-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Don't run code in the async/await highlighter unless on one of those keywords. #73721
Conversation
@ToddGrun ptal. |
AddTouchingTokens(root, position, tokens, findInsideTrivia: false); | ||
AddTouchingTokens(root, position, ref tokens, findInsideTrivia: true); | ||
if (_findInsideTrivia) | ||
AddTouchingTokens(root, position, ref tokens, findInsideTrivia: false); |
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.
no point going into trivia for most highlighters. can update others as appropraite.
// We only look at a max of 4 tokens (two trivia, and two non-trivia), so a temp-array is ideal here | ||
using var touchingTokens = TemporaryArray<SyntaxToken>.Empty; | ||
AddTouchingTokens(root, position, ref touchingTokens.AsRef()); | ||
if (!ContainsHighlightableToken(ref touchingTokens.AsRef())) |
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.
the async/await highlighter si not well written. it does all sorts of unnecessary work even when not on an appropraite keyword. this allows us to early bail out here and not do any of that work.
internal class IfStatementHighlighter : AbstractKeywordHighlighter<IfStatementSyntax> | ||
[method: ImportingConstructor] | ||
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
internal sealed class IfStatementHighlighter() : AbstractKeywordHighlighter<IfStatementSyntax>(findInsideTrivia: false) |
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 picked the highlighters to update based on if i saw the in the traces.
dumb question: Could this method to also handle the _findInsideTrivia case and use the FindToken results so it wouldn't need to walk the as much of the tree for the _findInsideTrivia case, or is that more complexity than it's worth? ie, something like:
Refers to: src/Features/Core/Portable/Highlighting/Keywords/AbstractKeywordHighlighter.cs:94 in b7594de. [](commit_id = b7594de, deletion_comment = False) |
or SyntaxKind.WhileKeyword | ||
or SyntaxKind.BreakKeyword | ||
or SyntaxKind.ContinueKeyword | ||
or SyntaxKind.SemicolonToken); |
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.
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.
yes. that's correct. that's because the loop highlighter will highlight if you're next to things like break;
that's ok. this is still a tiny subset of all tokens.
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.
the main goal here is to stop runnin all these highlighters unnecessarily on tokens they will never report results for. that's just pointless.
It definitely could/should. But baby steps based on traces :) |
Fair enough, doesn't hurt to ask :) In reply to: 2132367763 |
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.
Addresses about half the cost of keyword highlighting.