提交 0f2db452 编写于 作者: K Kevin Halverson

Merge pull request #3897 from KevinH-MS/ParamPropDataTips

Fix DataTips for parameterized property access...

(fixes #2602)
......@@ -11,6 +11,7 @@ Imports Roslyn.Test.Utilities
Imports Roslyn.Utilities
Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.UnitTests.Debugging
Public Class DataTipInfoGetterTests
Private Sub TestNoDataTip(input As XElement)
......@@ -97,7 +98,7 @@ end class</text>)
Test(<text>
class C
sub Foo()
[|System.Console.Wri$$teLine|](args)
[|System.Console.Wri$$teLine(args)|]
end sub
end class</text>)
End Sub
......@@ -107,7 +108,7 @@ end class</text>)
TestNoDataTip(<text>
class C
sub Foo()
[|System.Console.WriteLine|]$$(args)
System.Console.WriteLine$$(args)
end sub
end class</text>)
End Sub
......@@ -127,7 +128,7 @@ end class</text>)
TestNoDataTip(<text>
class C
sub Foo()
[|System.Console.WriteLine|](args$$)
System.Console.WriteLine(args$$)
end sub
end class</text>)
End Sub
......@@ -400,5 +401,40 @@ End Class
Test(<text><%= String.Format(sourceTemplate, "[|Me?!B?!$$C|]") %></text>)
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.DebuggingDataTips), WorkItem(2602)>
Public Sub TestParameterizedProperty()
Const sourceTemplate = "
Class Class1
Public row = New DataRow()
Function F()
Return {0}
End Function
Public ReadOnly Property Item(ByVal i As Integer) As String
Get
Return str
End Get
End Property
Class DataRow
Public ReadOnly Property Item(ByVal str As String) As String
Get
Return str
End Get
End Property
End Class
End Class
"
Test(<text><%= String.Format(sourceTemplate, "[|$$Item(42)|].Length") %></text>)
Test(<text><%= String.Format(sourceTemplate, "[|row.It$$em(""Test Row"")|].Length") %></text>)
Test(<text><%= String.Format(sourceTemplate, "[|row?.Ite$$m(""Test Row"")|].Length") %></text>)
Test(<text><%= String.Format(sourceTemplate, "[|Me?.row.$$Item(""Test Row"")|].Length") %></text>)
Test(<text><%= String.Format(sourceTemplate, "[|Me.row?.It$$em(""Test Row"")|].Length") %></text>)
Test(<text><%= String.Format(sourceTemplate, "[|Me?.row?.It$$em(""Test Row"")|].Length") %></text>)
End Sub
End Class
End Namespace
......@@ -38,33 +38,33 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Debugging
Return Nothing
End If
Dim conditionalAccess As ExpressionSyntax = Nothing
If expression.IsRightSideOfDotOrBang() Then
Dim parent = DirectCast(expression.Parent, ExpressionSyntax)
Dim curr = parent
expression = DirectCast(expression.Parent, ExpressionSyntax)
Dim curr = expression
While True
Dim conditionalAccess = curr.GetCorrespondingConditionalAccessExpression()
If conditionalAccess Is Nothing Then
curr = curr.GetCorrespondingConditionalAccessExpression()
If curr Is Nothing Then
Exit While
End If
curr = conditionalAccess
conditionalAccess = curr
End While
End If
If curr Is parent Then
' NB: parent.Span, not Span as below.
Return New DebugDataTipInfo(parent.Span, text:=Nothing)
End If
' NOTE: There may not be an ExpressionSyntax corresponding to the range we want.
' For example, for input a?.$$B?.C we want span [|a?.B|].C.
Return New DebugDataTipInfo(TextSpan.FromBounds(curr.SpanStart, expression.Span.End), text:=Nothing)
If expression.Parent.IsKind(SyntaxKind.InvocationExpression) Then
expression = DirectCast(expression.Parent, ExpressionSyntax)
End If
If expression.IsKind(SyntaxKind.InvocationExpression) Then
expression = DirectCast(expression, InvocationExpressionSyntax).Expression
Dim span = expression.Span
If conditionalAccess IsNot Nothing Then
' There may not be an ExpressionSyntax corresponding to the range we want.
' For example, for input a?.$$B?.C we want span [|a?.B|].C.
span = TextSpan.FromBounds(conditionalAccess.SpanStart, span.End)
End If
Return New DebugDataTipInfo(expression.Span, text:=Nothing)
Return New DebugDataTipInfo(span, text:=Nothing)
End Function
End Module
End Namespace
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册