-
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
Add AwaitCompletionProvider that makes container Async in VB #54908
Conversation
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 This is ready for initial review (modulo integration tests)
54ce85d
to
4265c04
Compare
displayTextSuffix: "", | ||
rules: CompletionItemRules.Default, | ||
Glyph.Keyword, | ||
description: RecommendedKeyword.CreateDisplayParts(text, string.Empty), |
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.
yeah, let's move to core and have same description.
private protected override bool ShouldMakeContainerAsync(SyntaxToken token) | ||
{ | ||
var declaration = GetAsyncSupportingDeclaration(token); | ||
return declaration is not null && !declaration.GetModifiers().Any(SyntaxKind.AsyncKeyword); |
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 wonder if this line coudl be pulled up to the base, using SYntaxGenerator.GetModifiers to unify the code.
|
||
var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); | ||
var newText = text.WithChanges(builder); | ||
return CompletionChange.Create(Utilities.Collapse(newText, builder.ToImmutableArray())); |
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 presume this logic moved up effectively unchanged?
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.
|
||
Public Overrides ReadOnly Property TriggerCharacters As ImmutableHashSet(Of Char) = CommonTriggerChars | ||
|
||
Private Protected Overrides ReadOnly Property AsyncKeywordTextWithSpace As String = "Async " |
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 don't know why, but this bugs me. can jyst you get hte asynckeyword, and hten add the space in the base class? :)
SyntaxKind.MultiLineSubLambdaExpression, | ||
SyntaxKind.SingleLineFunctionLambdaExpression, | ||
SyntaxKind.SingleLineSubLambdaExpression | ||
Return DirectCast(declaration, LambdaExpressionSyntax).SubOrFunctionHeader.SubOrFunctionKeyword.SpanStart |
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.
are tehre teests for all these cases?
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 Yes. See VisualBasicCompletionCommandHandlerTests_AwaitCompletion:
AwaitCompletionAddsAsync_FunctionDeclaration
AwaitCompletionAddsAsync_SubDeclaration
AwaitCompletionAddsAsync_MultiLineFunctionLambdaExpression
AwaitCompletionAddsAsync_MultiLineSubLambdaExpression
AwaitCompletionAddsAsync_SingleLineFunctionLambdaExpression
AwaitCompletionAddsAsync_SingleLineSubLambdaExpression
End Function | ||
|
||
Private Protected Overrides Function GetAsyncSupportingDeclaration(token As SyntaxToken) As SyntaxNode | ||
Return token.GetAncestor(Function(node) node.IsAsyncSupportedFunctionSyntax()) |
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.
coudl ahve the abstract base calss expose IsAsyncSupportedFunctionSyntax. then more logic can be pushed up.
For Each node In TargetToken.GetAncestors(Of SyntaxNode)() | ||
If node.IsKind(SyntaxKind.SingleLineSubLambdaExpression, SyntaxKind.SingleLineFunctionLambdaExpression, | ||
SyntaxKind.MultiLineSubLambdaExpression, SyntaxKind.MultiLineFunctionLambdaExpression) Then | ||
|
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.
lgtm. some small requests for more unification.
@@ -24,7 +24,7 @@ public class C | |||
]]> | |||
</Document>) | |||
state.SendTypeChars("aw") | |||
Await state.AssertSelectedCompletionItem(displayText:="await", isHardSelected:=True, inlineDescription:=CSharpFeaturesResources.Make_container_async) | |||
Await state.AssertSelectedCompletionItem(displayText:="await", isHardSelected:=True, inlineDescription:=FeaturesResources.Make_containing_scope_async) |
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 found this existing resource string and went for it (it doesn't seem to be used anywhere else)
@@ -54,6 +54,7 @@ | |||
<InternalsVisibleTo Include="Roslyn.VisualStudio.Setup" /> | |||
<InternalsVisibleTo Include="VBCSCompiler" /> | |||
<InternalsVisibleTo Include="AnalyzerRunner" /> | |||
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" /> |
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.
Without this, tests don't have access to FeaturesResources
.
src/Features/Core/Portable/Completion/Providers/AbstractAwaitCompletionProvider.cs
Show resolved
Hide resolved
@Youssef1313 test failures seem real. |
Followup to #48352
Unblocks #52289