提交 c6943d4a 编写于 作者: C CyrusNajmabadi

Add VB side.

上级 5d3a3c19
......@@ -10,7 +10,7 @@
namespace Microsoft.CodeAnalysis.CSharp.ConvertToInterpolatedString
{
[ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = PredefinedCodeRefactoringProviderNames.ConvertToInterpolatedString + "2"), Shared]
[ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = PredefinedCodeRefactoringProviderNames.ConvertToInterpolatedString), Shared]
internal class CSharpConvertConcatenationToInterpolatedStringRefactoringProvider :
AbstractConvertConcatenationToInterpolatedStringRefactoringProvider
{
......
......@@ -125,8 +125,9 @@ private bool SameLiteralKind(SyntaxNode literal1, SyntaxToken firstStringToken)
var method = semanticModel.GetSymbolInfo(expression, cancellationToken).Symbol as IMethodSymbol;
return method?.MethodKind == MethodKind.BuiltinOperator &&
method.MetadataName == WellKnownMemberNames.AdditionOperatorName &&
method.ContainingType.SpecialType == SpecialType.System_String;
method.ContainingType.SpecialType == SpecialType.System_String &&
(method.MetadataName == WellKnownMemberNames.AdditionOperatorName ||
method.MetadataName == WellKnownMemberNames.ConcatenateOperatorName);
}
private class MyCodeAction : CodeAction.DocumentChangeAction
......
......@@ -123,6 +123,7 @@
<Compile Include="CodeFixes\Spellcheck\VisualBasicSpellCheckCodeFixProvider.vb" />
<Compile Include="CodeFixes\Suppression\VisualBasicSuppressionCodeFixProvider.vb" />
<Compile Include="CodeLens\VisualBasicDisplayInfoService.vb" />
<Compile Include="ConvertToInterpolatedString\VisualBasicConvertConcatenationToInterpolatedStringRefactoringProvider.vb" />
<Compile Include="ConvertToInterpolatedString\VisualBasicConvertPlaceholderToInterpolatedStringRefactoringProvider.vb" />
<Compile Include="CodeRefactorings\EncapsulateField\EncapsulateFieldRefactoringProvider.vb" />
<Compile Include="CodeRefactorings\ExtractInterface\ExtractInterfaceCodeRefactoringProvider.vb" />
......
' 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.ConvertToInterpolatedString
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.ConvertToInterpolatedString
<ExportCodeRefactoringProvider(LanguageNames.VisualBasic, Name:=PredefinedCodeRefactoringProviderNames.ExtractMethod), [Shared]>
Friend Class VisualBasicConvertConcatenationToInterpolatedStringRefactoringProvider
Inherits AbstractConvertConcatenationToInterpolatedStringRefactoringProvider
Protected Overrides Function CreateInterpolatedString(firstStringToken As SyntaxToken,
pieces As List(Of SyntaxNode)) As SyntaxNode
Dim startToken = SyntaxFactory.Token(SyntaxKind.DollarSignDoubleQuoteToken).
WithLeadingTrivia(pieces.First().GetLeadingTrivia())
Dim endToken = SyntaxFactory.Token(SyntaxKind.DoubleQuoteToken).
WithTrailingTrivia(pieces.Last().GetTrailingTrivia())
Dim contents As New List(Of InterpolatedStringContentSyntax)
For Each piece In pieces
If piece.Kind() = SyntaxKind.StringLiteralExpression Then
Dim text = piece.GetFirstToken().Text
Dim textWithoutQuotes = text.Substring("'".Length, text.Length - "''".Length)
contents.Add(SyntaxFactory.InterpolatedStringText(
SyntaxFactory.InterpolatedStringTextToken(textWithoutQuotes, "")))
Else
contents.Add(SyntaxFactory.Interpolation(
DirectCast(piece, ExpressionSyntax).WithoutTrivia()))
End If
Next
Dim expression = SyntaxFactory.InterpolatedStringExpression(
startToken, SyntaxFactory.List(contents), endToken)
Return expression
End Function
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册