未验证 提交 88a5b506 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #22791 from sharwell/see-langword

Avoid showing language keywords after typing < in a doc comment
......@@ -653,6 +653,70 @@ static void Goo()
}", "cref", "langword");
}
[WorkItem(22789, "https://github.com/dotnet/roslyn/issues/22789")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task LangwordCompletionInPlainText()
{
await VerifyItemsExistAsync(@"
class C
{
/// <summary>
/// Some text $$
/// </summary>
static void Goo()
{
}
}", "null", "sealed", "true", "false", "await");
}
[WorkItem(22789, "https://github.com/dotnet/roslyn/issues/22789")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task LangwordCompletionAfterAngleBracket1()
{
await VerifyItemsAbsentAsync(@"
class C
{
/// <summary>
/// Some text <$$
/// </summary>
static void Goo()
{
}
}", "null", "sealed", "true", "false", "await");
}
[WorkItem(22789, "https://github.com/dotnet/roslyn/issues/22789")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task LangwordCompletionAfterAngleBracket2()
{
await VerifyItemsAbsentAsync(@"
class C
{
/// <summary>
/// Some text <s$$
/// </summary>
static void Goo()
{
}
}", "null", "sealed", "true", "false", "await");
}
[WorkItem(22789, "https://github.com/dotnet/roslyn/issues/22789")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task LangwordCompletionAfterAngleBracket3()
{
await VerifyItemsExistAsync(@"
class C
{
/// <summary>
/// Some text < $$
/// </summary>
static void Goo()
{
}
}", "null", "sealed", "true", "false", "await");
}
[WorkItem(11490, "https://github.com/dotnet/roslyn/issues/11490")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task SeeLangwordAttributeValue()
......
......@@ -577,6 +577,31 @@ class c
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
<WorkItem(22789, "https://github.com/dotnet/roslyn/issues/22789")>
Public Async Function InvokeWithOpenAngleCommitSeeOnTab() As Task
Using state = TestState.CreateCSharpTestState(
<Document><![CDATA[
class c
{
/// $$
void goo() { }
}
]]></Document>)
state.SendTypeChars("<")
Await state.AssertCompletionSession()
state.SendTypeChars("se")
Await state.AssertSelectedCompletionItem(displayText:="see")
state.SendTab()
Await state.AssertNoCompletionSession()
' /// <see cref="$$"/>
Await state.AssertLineTextAroundCaret(" /// <see cref=""", """/>")
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function InvokeWithOpenAngleCommitSeeOnSpace() As Task
......
......@@ -774,6 +774,66 @@ End Class
Await VerifyItemsExistAsync(text, "cref", "langword")
End Function
<WorkItem(22789, "https://github.com/dotnet/roslyn/issues/22789")>
<Fact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function TestLangwordCompletionInPlainText() As Task
Dim text = "
Class C
''' <summary>
''' Some text $$
''' </summary>
Sub Goo()
End Sub
End Class
"
Await VerifyItemsExistAsync(text, "Nothing", "Shared", "True", "False", "Await")
End Function
<WorkItem(22789, "https://github.com/dotnet/roslyn/issues/22789")>
<Fact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function LangwordCompletionAfterAngleBracket1() As Task
Dim text = "
Class C
''' <summary>
''' Some text <$$
''' </summary>
Sub Goo()
End Sub
End Class
"
Await VerifyItemsAbsentAsync(text, "Nothing", "Shared", "True", "False", "Await")
End Function
<WorkItem(22789, "https://github.com/dotnet/roslyn/issues/22789")>
<Fact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function LangwordCompletionAfterAngleBracket2() As Task
Dim text = "
Class C
''' <summary>
''' Some text <s$$
''' </summary>
Sub Goo()
End Sub
End Class
"
Await VerifyItemsAbsentAsync(text, "Nothing", "Shared", "True", "False", "Await")
End Function
<WorkItem(22789, "https://github.com/dotnet/roslyn/issues/22789")>
<Fact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function LangwordCompletionAfterAngleBracket3() As Task
Dim text = "
Class C
''' <summary>
''' Some text < $$
''' </summary>
Sub Goo()
End Sub
End Class
"
Await VerifyItemsAbsentAsync(text, "Nothing", "Shared", "True", "False", "Await")
End Function
<WorkItem(11490, "https://github.com/dotnet/roslyn/issues/11490")>
<Fact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function TestSeeLangwordAttributeValue() As Task
......
......@@ -101,7 +101,15 @@ internal override bool IsInsertionTrigger(SourceText text, int characterPosition
if (token.Parent.Parent.Kind() == SyntaxKind.XmlElement ||
token.Parent.Parent.IsParentKind(SyntaxKind.XmlElement))
{
items.AddRange(GetNestedItems(declaredSymbol));
// Avoid including language keywords when following < or <text, since these cases should only be
// attempting to complete the XML name (which for language keywords is 'see'). While the parser
// treats the 'name' in '< name' as an XML name, we don't treat it like that here so the completion
// experience is consistent for '< ' and '< n'.
var xmlNameOnly = token.IsKind(SyntaxKind.LessThanToken)
|| (token.Parent.IsKind(SyntaxKind.XmlName) && !token.HasLeadingTrivia);
var includeKeywords = !xmlNameOnly;
items.AddRange(GetNestedItems(declaredSymbol, includeKeywords));
}
if (token.Parent.Parent.Kind() == SyntaxKind.XmlElement && ((XmlElementSyntax)token.Parent.Parent).StartTag.Name.LocalName.ValueText == ListElementName)
......
......@@ -125,7 +125,7 @@ private CompletionItem GetCDataItem()
return CreateCompletionItem(prefix, "<" + prefix, suffix);
}
protected IEnumerable<CompletionItem> GetNestedItems(ISymbol symbol)
protected IEnumerable<CompletionItem> GetNestedItems(ISymbol symbol, bool includeKeywords)
{
var items = s_nestedTagNames.Select(GetItem);
......@@ -135,7 +135,10 @@ protected IEnumerable<CompletionItem> GetNestedItems(ISymbol symbol)
.Concat(GetTypeParamRefItems(symbol));
}
items = items.Concat(GetKeywordNames().Select(CreateLangwordCompletionItem));
if (includeKeywords)
{
items = items.Concat(GetKeywordNames().Select(CreateLangwordCompletionItem));
}
return items;
}
......
......@@ -110,7 +110,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.Providers
Dim grandParent = parentElement?.Parent
If grandParent.IsKind(SyntaxKind.XmlElement) Then
items.AddRange(GetNestedItems(symbol))
' Avoid including language keywords when following < Or <text, since these cases should only be
' attempting to complete the XML name (which for language keywords Is 'see'). The VB parser treats
' spaces after a < character as trailing whitespace, even if an identifier follows it on the same line.
' Therefore, the consistent VB experience says we never show keywords for < followed by spaces.
Dim xmlNameOnly = token.IsKind(SyntaxKind.LessThanToken) OrElse token.Parent.IsKind(SyntaxKind.XmlName)
Dim includeKeywords = Not xmlNameOnly
items.AddRange(GetNestedItems(symbol, includeKeywords))
If GetStartTagName(grandParent) = ListElementName Then
items.AddRange(GetListItems())
......@@ -125,7 +132,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.Providers
' ''' $$
items.AddRange(GetTopLevelItems(symbol, parent))
ElseIf token.Parent.IsParentKind(SyntaxKind.XmlElement) Then
items.AddRange(GetNestedItems(symbol))
items.AddRange(GetNestedItems(symbol, includeKeywords:=True))
If GetStartTagName(token.Parent.Parent) = ListElementName Then
items.AddRange(GetListItems())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册