-
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
SignatureHelp: guess best overload for incomplete invocations #31843
Conversation
src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/SignatureHelp/AbstractSignatureHelpProvider.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSemanticFactsService.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSemanticFactsService.cs
Outdated
Show resolved
Hide resolved
|
||
Public Function CanConvert(semanticModel As SemanticModel, node As SyntaxNode, type As ITypeSymbol) As Boolean Implements ISemanticFactsService.CanConvert | ||
Dim conversion = semanticModel.ClassifyConversion(DirectCast(node, ExpressionSyntax), type) | ||
Return conversion.Exists |
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 not .isWidening for VB to match .IsImplicit for C#? #Resolved
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.
That was meant to be minimal. I'll fix when I do the VB implementation/testing. #Resolved
Seems reasonable. Though i'm curious about the costs of arg name checking. Humorously enough doesn't sig-help already use provided arg-names to filter down the list? Or, at least, to figure out which param you're on to show the appropriate sig help docs for that param? #Resolved |
Yes, sig-help filters out the list based on named arguments. But that logic is simple (it doesn't need to understand non-trailing named arguments). PS: This reminds me, I should probably handle |
Added handling for named arguments, empty arguments and params. #Closed |
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 only able to partially complete this review so far. Will go through it again.
src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs
Outdated
Show resolved
Hide resolved
...tures/CSharp/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider_MethodGroup.cs
Outdated
Show resolved
Hide resolved
/// </summary> | ||
protected static bool IsInacceptable(SeparatedSyntaxList<ArgumentSyntax> arguments, IMethodSymbol method) | ||
protected static bool IsUnacceptable(SeparatedSyntaxList<ArgumentSyntax> arguments, IMethodSymbol method) |
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.
instead of having IsUnacceptable
which tehn has to eb used like => !IsUnacceptable
, consider just having => IsAcceptable
. #Resolved
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.
this cmment still applies, unless you strongly like the negative form here.
src/Features/CSharp/Portable/SignatureHelp/AttributeSignatureHelpProvider.cs
Show resolved
Hide resolved
src/Features/CSharp/Portable/SignatureHelp/ConstructorInitializerSignatureHelpProvider.cs
Show resolved
Hide resolved
src/Features/CSharp/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.cs
Outdated
Show resolved
Hide resolved
CancellationToken cancellationToken) | ||
{ | ||
return Task.FromResult( | ||
(accessibleMethods.SelectAsArray(m => ConvertMethodGroupMethod(document, m, invocationExpression.SpanStart, semanticModel)), | ||
TryGetSelectedIndex(accessibleMethods, currentSymbol.Symbol))); | ||
TryGetSelectedIndex(accessibleMethods, currentSymbol))); |
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 prior spacing was intentional fwiw :) #Pending
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.
specifically, teh tuple element values were aligned.
if (selectedItem == -1) | ||
{ | ||
selectedItem = 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.
was this something you encountered? #Pending
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.
Probably did at some point, but seems this can now be removed. Thanks
{ | ||
result.ArgumentIndex = parameterIndex; | ||
} | ||
return result; |
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 extract a helper in the base type that these guys can all share? #Resolved
I'm anticipating being able to rest the fingers that hit the up-down keys to search through overloads 🎉 |
Yay! Thanks @CyrusNajmabadi, @sharwell. It feels good to get this 2018 PR finally merged :-) That'll teach me not to let PRs go so stale... |
The current behavior is that a provider will recommend a selection only if the compiler definitely identified the symbol. But when overload resolution failed, the compiler doesn't say which overload was the best match.
I implemented a simple heuristic (poor man's overload resolution), which just checks if the arguments are compatible with the parameters.
Fixes #6713
Tagging @CyrusNajmabadi @dpoeschl @sharwell