-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
F1 help for #if
and #else
refers to preprocessor symbols, not if_CSharpKeyword
and else_CSharpkeyword
#69192
Conversation
The F1 service should produce `#if` instead of `if_CSharpKeyword` when the cursor is on the `#if` symbol. Add other tasks for the other preprocessor symbols related to conditional compilation. The `#if` and `#else` fail, because the model finds child nodes for `if` and `else`, respectively. The tests for `#elif` and `#endif` pass, because the model does not find child nodes for those tokens.
Because the `#if` and `#else` preprocessor tokens contain the text for keywords (`if` and `else`), the `TryGetTextForKeyword` would lock to those keywords before the `TryGetTextForPreProcessor` looked for the preprocessor token. By switching the order of those two tests, the longer preprocessor tokens are found first.
The "if" and "else" nodes may appear as "if" / "else" or "#if" / "#else". If the parent isn't the if statement or else clause, don't treat them as keywords. Then, the later processing will find them as preprocessor tokens and correctly route the request.
ping @CyrusNajmabadi |
Commit notes for reviewers:
|
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.
looking. |
Let me take a stab at this. |
TryGetTextForPreProcessor(token, out text) || | ||
TryGetTextForKeyword(token, out text) || |
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.
have pp checks come first so we defer to the pp interepretation if inside a directive.
|
||
if (token.IsKind(SyntaxKind.EndOfDirectiveToken) && token.GetAncestor<RegionDirectiveTriviaSyntax>() != null) |
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.
unified the behavior here so it works for any directive, not just regions.
{ | ||
text = Keyword("defaultline"); | ||
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.
moved from the keyword handling case to the directive handling case.
The F1 service should produce
#if
instead ofif_CSharpKeyword
when the cursor is on the#if
symbol.Fixes dotnet/docs#35715
Add tests for the F1 service on
#if
and related tokens. Then, when checking for keywords, make sure thatif
andelse
have the proper statement token as the parent token. Otherwise, that text is part of the preprocessor token.