提交 d3936957 编写于 作者: C CyrusNajmabadi

Add VB implementation and tests.

上级 373915ad
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.CodeRefactorings
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings
Imports Microsoft.CodeAnalysis.VisualBasic.ReplaceDocCommentTextWithTag
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ReplaceDocCommentTextWithTag
Public Class ReplaceDocCommentTextWithTagTests
Inherits AbstractVisualBasicCodeActionTest
Protected Overrides Function CreateCodeRefactoringProvider(Workspace As Workspace, parameters As TestParameters) As CodeRefactoringProvider
Return New VisualBasicReplaceDocCommentTextWithTagCodeRefactoringProvider()
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestStartOfKeyword() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the System.IDisposable [||]interface.
class C(Of TKey)
end class",
"
''' TKey must implement the System.IDisposable <see langword=""interface""/>.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestStartOfKeywordCapitalized() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the System.IDisposable [||]Interface.
class C(Of TKey)
end class",
"
''' TKey must implement the System.IDisposable <see langword=""Interface""/>.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestEndOfKeyword() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the System.IDisposable interface[||].
class C(Of TKey)
end class",
"
''' TKey must implement the System.IDisposable <see langword=""interface""/>.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestEndOfKeyword_NewLineFollowing() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the System.IDisposable interface[||]
class C(Of TKey)
end class",
"
''' TKey must implement the System.IDisposable <see langword=""interface""/>
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestSelectedKeyword() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the System.IDisposable [|interface|].
class C(Of TKey)
end class",
"
''' TKey must implement the System.IDisposable <see langword=""interface""/>.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestInsideKeyword() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the System.IDisposable int[||]erface.
class C(Of TKey)
end class",
"
''' TKey must implement the System.IDisposable <see langword=""interface""/>.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestNotInsideKeywordIfNonEmptySpan() As Task
Await TestMissingAsync(
"
''' TKey must implement the System.IDisposable int[|erf|]ace
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestStartOfFullyQualifiedTypeName_Start() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the [||]System.IDisposable interface.
class C(Of TKey)
end class",
"
''' TKey must implement the <see cref=""System.IDisposable""/> interface.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestStartOfFullyQualifiedTypeName_Mid1() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the System[||].IDisposable interface.
class C(Of TKey)
end class",
"
''' TKey must implement the <see cref=""System.IDisposable""/> interface.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestStartOfFullyQualifiedTypeName_Mid2() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the System.[||]IDisposable interface.
class C(Of TKey)
end class",
"
''' TKey must implement the <see cref=""System.IDisposable""/> interface.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestStartOfFullyQualifiedTypeName_End() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the System.IDisposable[||] interface.
class C(Of TKey)
end class",
"
''' TKey must implement the <see cref=""System.IDisposable""/> interface.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestStartOfFullyQualifiedTypeName_CaseInsensitive() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the [||]system.idisposable interface.
class C(Of TKey)
end class",
"
''' TKey must implement the <see cref=""system.idisposable""/> interface.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestStartOfFullyQualifiedTypeName_Selected() As Task
Await TestInRegularAndScriptAsync(
"
''' TKey must implement the [|System.IDisposable|] interface.
class C(Of TKey)
end class",
"
''' TKey must implement the <see cref=""System.IDisposable""/> interface.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestTypeParameterReference() As Task
Await TestInRegularAndScriptAsync(
"
''' [||]TKey must implement the System.IDisposable interface.
class C(Of TKey)
end class",
"
''' <typeparamref name=""TKey""/> must implement the System.IDisposable interface.
class C(Of TKey)
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestCanSeeInnerMethod() As Task
Await TestInRegularAndScriptAsync(
"
''' Use WriteLine[||] as a Console.WriteLine replacement
class C
sub WriteLine(Of TKey)(value as TKey)
end sub
end class",
"
''' Use <see cref=""WriteLine""/> as a Console.WriteLine replacement
class C
sub WriteLine(Of TKey)(value as TKey)
end sub
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestNotOnMispelledName() As Task
Await TestMissingAsync(
"
''' Use WriteLine1[||] as a Console.WriteLine replacement
class C
sub WriteLine(Of TKey)(value as TKey)
end sub
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestMethodTypeParameterSymbol() As Task
Await TestInRegularAndScriptAsync(
"
class C
''' value has type TKey[||] so we don't box primitives.
sub WriteLine(Of TKey)(value as TKey)
end sub
end class",
"
class C
''' value has type <typeparamref name=""TKey""/> so we don't box primitives.
sub WriteLine(Of TKey)(value as TKey)
end sub
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestMethodTypeParameterSymbol_CaseInsensitive() As Task
Await TestInRegularAndScriptAsync(
"
class C
''' value has type TKey[||] so we don't box primitives.
sub WriteLine(Of tkey)(value as TKey)
end sub
end class",
"
class C
''' value has type <typeparamref name=""TKey""/> so we don't box primitives.
sub WriteLine(Of tkey)(value as TKey)
end sub
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestMethodTypeParameterSymbol_EmptyBody() As Task
Await TestInRegularAndScriptAsync(
"
interface I
''' value has type TKey[||] so we don't box primitives.
sub WriteLine(Of TKey)(value as TKey)
end interface",
"
interface I
''' value has type <typeparamref name=""TKey""/> so we don't box primitives.
sub WriteLine(Of TKey)(value as TKey)
end interface")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestMethodParameterSymbol() As Task
Await TestInRegularAndScriptAsync(
"
class C
''' value[||] has type TKey so we don't box primitives.
sub WriteLine(Of TKey)(value as TKey)
end sub
end class",
"
class C
''' <paramref name=""value""/> has type TKey so we don't box primitives.
sub WriteLine(Of TKey)(value as TKey)
end sub
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestMethodParameterSymbol_CaseInsensitive() As Task
Await TestInRegularAndScriptAsync(
"
class C
''' value[||] has type TKey so we don't box primitives.
sub WriteLine(Of TKey)(Value as TKey)
end sub
end class",
"
class C
''' <paramref name=""value""/> has type TKey so we don't box primitives.
sub WriteLine(Of TKey)(Value as TKey)
end sub
end class")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceDocCommentTextWithTag)>
Public Async Function TestMethodParameterSymbol_EmptyBody() As Task
Await TestInRegularAndScriptAsync(
"
interface I
''' value[||] has type TKey so we don't box primitives.
sub WriteLine(Of TKey)(value as TKey)
end interface",
"
interface I
''' <paramref name=""value""/> has type TKey so we don't box primitives.
sub WriteLine(Of TKey)(value as TKey)
end interface")
End Function
End Class
End Namespace
......@@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.CSharp.ReplaceDocCommentTextWithTag
{
[ExportCodeRefactoringProvider(LanguageNames.CSharp), Shared]
internal class CSharpReplaceDocCommentTextWithTagCodeRefactoringProvider :
AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider<MemberDeclarationSyntax>
AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider
{
protected override bool IsXmlTextToken(SyntaxToken token)
=> token.Kind() == SyntaxKind.XmlTextLiteralToken ||
......
......@@ -13,9 +13,7 @@
namespace Microsoft.CodeAnalysis.ReplaceDocCommentTextWithTag
{
internal abstract class AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider<TMemberDeclarationSyntax>
: CodeRefactoringProvider
where TMemberDeclarationSyntax : SyntaxNode
internal abstract class AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider : CodeRefactoringProvider
{
protected abstract bool IsAnyKeyword(string text);
protected abstract bool IsXmlTextToken(SyntaxToken token);
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Composition
Imports Microsoft.CodeAnalysis.CodeRefactorings
Imports Microsoft.CodeAnalysis.ReplaceDocCommentTextWithTag
Namespace Microsoft.CodeAnalysis.VisualBasic.ReplaceDocCommentTextWithTag
<ExportCodeRefactoringProvider(LanguageNames.VisualBasic), [Shared]>
Friend Class VisualBasicReplaceDocCommentTextWithTagCodeRefactoringProvider
Inherits AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider
Protected Overrides Function IsXmlTextToken(token As SyntaxToken) As Boolean
Return token.Kind() = SyntaxKind.XmlTextLiteralToken OrElse
token.Kind() = SyntaxKind.DocumentationCommentLineBreakToken
End Function
Protected Overrides Function IsAnyKeyword(text As String) As Boolean
Return SyntaxFacts.GetKeywordKind(text) <> SyntaxKind.None OrElse
SyntaxFacts.GetContextualKeywordKind(text) <> SyntaxKind.None
End Function
Protected Overrides Function ParseExpression(text As String) As SyntaxNode
Return SyntaxFactory.ParseExpression(text)
End Function
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册