-
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
Handle more cases in F1 help service #60156
Conversation
@@ -239,6 +232,12 @@ private static bool TryGetTextForOperator(SyntaxToken token, Document document, | |||
return true; | |||
} | |||
|
|||
if (token.IsKind(SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken) && token.Parent.IsKind(SyntaxKind.TypeParameterList, SyntaxKind.TypeArgumentList)) | |||
{ | |||
text = Keyword("generics"); |
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'm using the Keyword
call for consistency, but let me know if I shouldn't use it in this case.
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.
@RikkiGibson FYI we will need to handle !!
. But it's waiting on dotnet/docs#28443. Do you want a tracking issue for this?
@@ -239,6 +287,12 @@ private static bool TryGetTextForOperator(SyntaxToken token, Document document, | |||
return true; | |||
} | |||
|
|||
if (token.IsKind(SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken) && token.Parent.IsKind(SyntaxKind.TypeParameterList, SyntaxKind.TypeArgumentList)) |
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.
Note to self:
TODO:
<
and >
in:
- FunctionPointerParameterListSyntax
- RelationalPatternSyntax
- XML doc comments (OperatorMemberCrefSyntax, XmlElementStartTagSyntax, XmlEmptyElementSyntax)
@davidwengier @CyrusNajmabadi Is it worth handling <
and >
in XML doc comments?
@@ -50,14 +51,15 @@ public override async Task<string> GetHelpTermAsync(Document document, TextSpan | |||
var semanticModel = await document.ReuseExistingSpeculativeModelAsync(span, cancellationToken).ConfigureAwait(false); | |||
|
|||
var result = TryGetText(token, semanticModel, document, cancellationToken); | |||
if (string.IsNullOrEmpty(result)) | |||
if (result is 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.
why this cahnge?
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.
@CyrusNajmabadi I changed the path that returns string.Empty
to return null
instead. Just simplifies the check and allows me to use ??
below. We're also now more consistent. Previously we were returning null
in some cases, and string.Empty
in other cases. Both had the same meaning of "we don't have an F1 keyword".
{ | ||
var previousToken = token.GetPreviousToken(); | ||
if (previousToken.Span.IntersectsWith(span)) | ||
result = TryGetText(previousToken, semanticModel, document, cancellationToken); | ||
} | ||
|
||
return result; | ||
// This redirects to https://docs.microsoft.com/visualstudio/ide/not-in-toc/default, indicating nothing is found. | ||
return result ?? "vs.texteditor"; |
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.
can you make a constant for this at the top of the file and doc that?
// PROTOTYPE: Figure out where to redirect. | ||
|
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.
@BillWagner @333fred Is there a documentation page we can redirect to 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.
Not yet. I'll ping you and @RikkiGibson on the docs issue referenced below when I open that PR.
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.
@BillWagner Sorry for not clarifying. This was about function pointers
roslyn/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs
Lines 291 to 295 in 64c5fd1
if (token.IsKind(SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken)) | |
{ | |
if (token.Parent.IsKind(SyntaxKind.FunctionPointerParameterList)) | |
{ | |
// PROTOTYPE: Figure out where to redirect. |
I found now that https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/unsafe-code is the most suitable page.
Opened dotnet/docs#28669.
No thanks, I'll just subscribe to the docs issue. |
Fixes #60154
Fixes #51878
Handles different meanings of EqualsToken (part of Improve F1 help for tokens with multiple uses #48392).
Handles
yield return
andyield break
(F1 keyword help forprivate protected
should not send you to help forprivate
orprotected
#23881 (comment))docs PR: dotnet/docs#28653 dotnet/docs#28660
@davidwengier @CyrusNajmabadi Can you take a look? Thanks!