提交 ef581a4b 编写于 作者: B Brett Forsgren

enable quick-info for interpolated strings

上级 94c4887e
......@@ -1267,6 +1267,34 @@ public void TestStringLiteral()
MainDescription("class System.String"));
}
[WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public void TestVerbatimStringLiteral()
{
TestInMethod(@"string f = @""cat""$$",
MainDescription("class System.String"));
}
[WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public void TestInterpolatedStringLiteral()
{
TestInMethod(@"string f = $""cat""$$", MainDescription("class System.String"));
TestInMethod(@"string f = $""c$$at""", MainDescription("class System.String"));
TestInMethod(@"string f = $""$$cat""", MainDescription("class System.String"));
TestInMethod(@"string f = $""cat {1$$ + 2} dog""", MainDescription("struct System.Int32"));
}
[WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")]
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public void TestVerbatimInterpolatedStringLiteral()
{
TestInMethod(@"string f = $@""cat""$$", MainDescription("class System.String"));
TestInMethod(@"string f = $@""c$$at""", MainDescription("class System.String"));
TestInMethod(@"string f = $@""$$cat""", MainDescription("class System.String"));
TestInMethod(@"string f = $@""cat {1$$ + 2} dog""", MainDescription("struct System.Int32"));
}
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public void TestCharLiteral()
{
......
......@@ -149,6 +149,22 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.QuickInfo
MainDescription("Class System.String"))
End Sub
<WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")>
<Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)>
Public Sub TestStringLiteral()
TestInClass("Dim i = ""cat""$$",
MainDescription("Class System.String"))
End Sub
<WorkItem(1280, "https://github.com/dotnet/roslyn/issues/1280")>
<Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)>
Public Sub TestInterpolatedStringLiteral()
TestInClass("Dim i = $""cat""$$", MainDescription("Class System.String"))
TestInClass("Dim i = $""c$$at""", MainDescription("Class System.String"))
TestInClass("Dim i = $""$$cat""", MainDescription("Class System.String"))
TestInClass("Dim i = $""cat {1$$ + 2} dog""", MainDescription("Structure System.Int32"))
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)>
Public Sub TestListOfString()
TestInClass("Dim l As $$List(Of String)",
......
......@@ -450,6 +450,10 @@ public bool IsLiteral(SyntaxToken token)
case SyntaxKind.NullKeyword:
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
case SyntaxKind.InterpolatedStringStartToken:
case SyntaxKind.InterpolatedStringEndToken:
case SyntaxKind.InterpolatedVerbatimStringStartToken:
case SyntaxKind.InterpolatedStringTextToken:
return true;
}
......@@ -1272,6 +1276,14 @@ public SyntaxNode GetBindableParent(SyntaxToken token)
}
}
// The inside of an interpolated string is treated as its own token so we
// need to force navigation to the parent expression syntax.
if (node is InterpolatedStringTextSyntax && parent is InterpolatedStringExpressionSyntax)
{
node = parent;
break;
}
// If this node is not parented by a name, we're done.
var name = parent as NameSyntax;
if (name == null)
......
......@@ -386,7 +386,24 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Function
Public Function IsLiteral(token As SyntaxToken) As Boolean Implements ISyntaxFactsService.IsLiteral
Return SyntaxFacts.IsLiteralExpressionToken(CType(token.Kind, SyntaxKind))
Select Case token.Kind()
Case _
SyntaxKind.IntegerLiteralToken,
SyntaxKind.CharacterLiteralToken,
SyntaxKind.DecimalLiteralToken,
SyntaxKind.FloatingLiteralToken,
SyntaxKind.DateLiteralToken,
SyntaxKind.StringLiteralToken,
SyntaxKind.DollarSignDoubleQuoteToken,
SyntaxKind.DoubleQuoteToken,
SyntaxKind.InterpolatedStringTextToken,
SyntaxKind.TrueKeyword,
SyntaxKind.FalseKeyword,
SyntaxKind.NothingKeyword
Return True
End Select
Return False
End Function
Public Function IsStringLiteral(token As SyntaxToken) As Boolean Implements ISyntaxFactsService.IsStringLiteral
......@@ -1028,6 +1045,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End If
End If
' The inside of an interpolated string is treated as its own token so we
' need to force navigation to the parent expression syntax.
If TypeOf node Is InterpolatedStringTextSyntax AndAlso TypeOf parent Is InterpolatedStringExpressionSyntax Then
node = parent
Exit While
End If
' If this node is not parented by a name, we're done.
Dim name = TryCast(parent, NameSyntax)
If name Is Nothing Then
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册