VB Service Added - Inline Parameter Name Hints#45622
VB Service Added - Inline Parameter Name Hints#45622akhera99 merged 7 commits intodotnet:features/parameter-hintsfrom
Conversation
...ces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Extensions/ArgumentSyntaxExtensions.vb
Outdated
Show resolved
Hide resolved
src/Features/VisualBasic/Portable/InlineParameterNameHints/InlineParameterNameHintsService.vb
Outdated
Show resolved
Hide resolved
src/Features/VisualBasic/Portable/InlineParameterNameHints/InlineParameterNameHintsService.vb
Outdated
Show resolved
Hide resolved
src/Features/VisualBasic/Portable/InlineParameterNameHints/InlineParameterNameHintsService.vb
Outdated
Show resolved
Hide resolved
| Dim semanticModel = Await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(False) | ||
| Dim nodes = root.DescendantNodes() | ||
|
|
||
| For Each node In nodes |
There was a problem hiding this comment.
Something in this loop should be checking for cancellation.
| <Document> | ||
| Class Foo | ||
| Sub Main(args As String()) | ||
| TestMethod({|x:CInt(5.5)|}, {|y:2.2|}) |
There was a problem hiding this comment.
Also add tests for CType, TryCast and DirectCast.
There was a problem hiding this comment.
Added, they don't resolve to the same base type so I had to add checks for it in the service as well.
src/EditorFeatures/Test2/InlineParameterNameHints/AbstractInlineParameterNameHintsTests.vb
Outdated
Show resolved
Hide resolved
src/Features/VisualBasic/Portable/InlineParameterNameHints/InlineParameterNameHintsService.vb
Outdated
Show resolved
Hide resolved
| Implements IInlineParameterNameHintsService | ||
|
|
||
| <ImportingConstructor> | ||
| <Obsolete(MefConstruction.ImportingConstructorMessage, True)> |
There was a problem hiding this comment.
named parameter for true.
There was a problem hiding this comment.
It does not allow me to add one?
src/Features/VisualBasic/Portable/InlineParameterNameHints/InlineParameterNameHintsService.vb
Outdated
Show resolved
Hide resolved
src/Features/VisualBasic/Portable/InlineParameterNameHints/InlineParameterNameHintsService.vb
Show resolved
Hide resolved
src/Features/VisualBasic/Portable/InlineParameterNameHints/InlineParameterNameHintsService.vb
Outdated
Show resolved
Hide resolved
src/Features/VisualBasic/Portable/InlineParameterNameHints/InlineParameterNameHintsService.vb
Outdated
Show resolved
Hide resolved
src/Features/VisualBasic/Portable/InlineParameterNameHints/InlineParameterNameHintsService.vb
Outdated
Show resolved
Hide resolved
| public async Task<IEnumerable<InlineParameterHint>> GetInlineParameterNameHintsAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken) | ||
| { | ||
| var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); | ||
| var spans = new List<InlineParameterHint>(); |
There was a problem hiding this comment.
remove this and just do var spans = ... below.
| return spans; | ||
| } | ||
|
|
||
| protected abstract List<InlineParameterHint> AddAllParameterNameHintLocations( |
There was a problem hiding this comment.
don't really see why this is returning a List. Either have it be IEnuemrable, or ImmutableArray.
There was a problem hiding this comment.
oh wait. it's even weirder :) you both pass in teh value to add to, and you return it out as a return value. Pick one or the other :)
| /// </summary> | ||
| [ExportLanguageService(typeof(IInlineParameterNameHintsService), LanguageNames.CSharp), Shared] | ||
| internal class InlineParameterNameHintsService : IInlineParameterNameHintsService | ||
| internal class InlineParameterNameHintsService : AbstractInlineParameterNameHintsService |
There was a problem hiding this comment.
once we have a VB and C# version we rename thsee. so this should be CSharpInlineParameterNameHintsService. That way it's easy to find/nav-to them since we have distinct names, not three types with the same name.
|
|
||
| Namespace Microsoft.CodeAnalysis.VisualBasic.InlineParameterNameHints | ||
| <ExportLanguageService(GetType(IInlineParameterNameHintsService), LanguageNames.VisualBasic), [Shared]> | ||
| Friend Class InlineParameterNameHintsService |
| If param IsNot Nothing AndAlso param.Name.Length > 0 Then | ||
| spans.Add(New InlineParameterHint(param.Name, simpleArgument.Span.Start)) | ||
| End If |
There was a problem hiding this comment.
nit: you could share this code with c# by having a protected helper in teh base class. up to you.
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
lgtm as long as the renames happen. Up to you about the other nits :)
| If TypeOf arg Is TryCastExpressionSyntax Then | ||
| Dim cast = DirectCast(arg, TryCastExpressionSyntax) | ||
| ' Recurse until we find a literal | ||
| ' If so, then we should add the adornment | ||
| Return IsExpressionWithNoName(cast.Expression) | ||
| End If | ||
|
|
||
| If TypeOf arg Is CTypeExpressionSyntax Then | ||
| Dim cast = DirectCast(arg, CTypeExpressionSyntax) | ||
| ' Recurse until we find a literal | ||
| ' If so, then we should add the adornment | ||
| Return IsExpressionWithNoName(cast.Expression) | ||
| End If | ||
|
|
||
| If TypeOf arg Is DirectCastExpressionSyntax Then | ||
| Dim cast = DirectCast(arg, DirectCastExpressionSyntax) | ||
| ' Recurse until we find a literal | ||
| ' If so, then we should add the adornment | ||
| Return IsExpressionWithNoName(cast.Expression) | ||
| End If |
There was a problem hiding this comment.
There's a CastExpressionSyntax base type you can use to cover all of these if you wanted.
Hello,
This pull request is to be able to merge the added Visual Basic service to the current feature branch I have out.
View of the VB hints:

Modified/Created Files:
InlineParameterNameHintsService.vbmuch like the service for C#, I go through and located all the SimpleArgumentSyntax types and determine if the adornment should be added.VisualBasicInlineParameterNameHintsTests.vbessentially did all the tests I did for the C# tagger, but for VB.ArgumentSyntaxExtensions.vbpreviously the DetermineParameter function made a call to the GetSymbolInfo method which had the type ExpressionSyntax as a parameter. I just changed the call to use the GetSymbolInfo method which had the SyntaxNode type as a parameter so that I would be able to get the associated parameter for expressions as well as attributes.Please let me know if you have any questions or concerns!