提交 40a1968e 编写于 作者: C CyrusNajmabadi

Clean up code.

上级 470a4953
......@@ -139,7 +139,7 @@
<Compile Include="Classification\TotalClassifierTests.cs" />
<Compile Include="Classification\TotalClassifierTests_Dynamic.cs" />
<Compile Include="CodeActions\AbstractCSharpCodeActionTest.cs" />
<Compile Include="CodeActions\ConvertToInterpolatedString\ConvertToInterpolatedStringTests.cs" />
<Compile Include="CodeActions\ConvertToInterpolatedString\ConvertPlaceholderToInterpolatedStringTests.cs" />
<Compile Include="CodeActions\EncapsulateField\EncapsulateFieldTests.cs" />
<Compile Include="CodeActions\ExtractMethod\ExtractMethodTests.cs" />
<Compile Include="CodeActions\GenerateDefaultConstructors\GenerateDefaultConstructorsTests.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.CSharp.CodeRefactorings.ConvertToInterpolatedString;
......@@ -7,10 +9,10 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeActions.ConvertToInterpolatedString
{
public class ConvertToInterpolatedStringTests : AbstractCSharpCodeActionTest
public class ConvertPlaceholderToInterpolatedStringTests : AbstractCSharpCodeActionTest
{
protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspace workspace) =>
new ConvertToInterpolatedStringRefactoringProvider();
new CSharpConvertPlaceholderToInterpolatedStringRefactoringProvider();
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsConvertToInterpolatedString)]
public async Task TestSingleItemSubstitution()
......
......@@ -120,7 +120,7 @@
<Compile Include="Classification\SemanticClassifierTests.vb" />
<Compile Include="Classification\SyntacticClassifierTests.vb" />
<Compile Include="CodeActions\AbstractVisualBasicCodeActionTest.vb" />
<Compile Include="CodeActions\ConvertToInterpolatedString\ConvertToInterpolatedStringTests.vb" />
<Compile Include="CodeActions\ConvertToInterpolatedString\ConvertPlaceholderToInterpolatedStringTests.vb" />
<Compile Include="CodeActions\EncapsulateField\EncapsulateFieldTests.vb" />
<Compile Include="CodeActions\ExtractMethod\ExtractMethodTests.vb" />
<Compile Include="CodeActions\GenerateDefaultConstructors\GenerateDefaultConstructorsTests.vb" />
......
Imports Microsoft.CodeAnalysis
' 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
Imports Microsoft.CodeAnalysis.CodeRefactorings
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings
Public Class ConvertToInterpolatedStringTests
Public Class ConvertPlaceholderToInterpolatedStringTests
Inherits AbstractVisualBasicCodeActionTest
Protected Overrides Function CreateCodeRefactoringProvider(workspace As Workspace) As CodeRefactoringProvider
Return New ConvertToInterpolatedStringRefactoringProvider()
Return New VisualBasicConvertPlaceholderToInterpolatedStringRefactoringProvider()
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsConvertToInterpolatedString)>
......
......@@ -112,7 +112,7 @@
<Compile Include="CodeFixes\TypeStyle\UseExplicitTypeCodeFixProvider.cs" />
<Compile Include="CodeFixes\TypeStyle\UseImplicitTypeCodeFixProvider.cs" />
<Compile Include="CodeLens\CSharpCodeLensDisplayInfoService.cs" />
<Compile Include="CodeRefactorings\ConvertToInterpolatedString\ConvertToInterpolatedStringRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\ConvertToInterpolatedString\CSharpConvertPlaceholderToInterpolatedStringRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\EncapsulateField\EncapsulateFieldCodeRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\ExtractInterface\ExtractInterfaceCodeRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs" />
......
using System.Composition;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Composition;
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
namespace Microsoft.CodeAnalysis.CSharp.CodeRefactorings.ConvertToInterpolatedString
{
[ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = PredefinedCodeRefactoringProviderNames.ConvertToInterpolatedString), Shared]
internal partial class ConvertToInterpolatedStringRefactoringProvider :
AbstractConvertToInterpolatedStringRefactoringProvider <InvocationExpressionSyntax, ExpressionSyntax, ArgumentSyntax, LiteralExpressionSyntax>
internal partial class CSharpConvertPlaceholderToInterpolatedStringRefactoringProvider :
AbstractConvertPlaceholderToInterpolatedStringRefactoringProvider <InvocationExpressionSyntax, ExpressionSyntax, ArgumentSyntax, LiteralExpressionSyntax>
{
protected override SyntaxNode GetInterpolatedString(string text) =>
ParseExpression("$" + text) as InterpolatedStringExpressionSyntax;
protected override SyntaxNode GetInterpolatedString(string text)
=> SyntaxFactory.ParseExpression("$" + text) as InterpolatedStringExpressionSyntax;
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Immutable;
using System.Linq;
......@@ -13,7 +15,7 @@
namespace Microsoft.CodeAnalysis.CodeRefactorings
{
internal abstract class AbstractConvertToInterpolatedStringRefactoringProvider<TInvocationExpressionSyntax, TExpressionSyntax, TArgumentSyntax, TLiteralExpressionSyntax> : CodeRefactoringProvider
internal abstract class AbstractConvertPlaceholderToInterpolatedStringRefactoringProvider<TInvocationExpressionSyntax, TExpressionSyntax, TArgumentSyntax, TLiteralExpressionSyntax> : CodeRefactoringProvider
where TExpressionSyntax : SyntaxNode
where TInvocationExpressionSyntax : TExpressionSyntax
where TArgumentSyntax : SyntaxNode
......
......@@ -213,7 +213,7 @@
<Compile Include="CodeRefactorings\CodeRefactoringContextExtensions.cs" />
<Compile Include="CodeRefactorings\CodeRefactoring.cs" />
<Compile Include="CodeRefactorings\CodeRefactoringService.cs" />
<Compile Include="CodeRefactorings\ConvertToInterpolatedString\AbstractConvertToInterpolatedStringRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\ConvertToInterpolatedString\AbstractConvertPlaceholdToInterpolatedStringRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\ExtractMethod\AbstractExtractMethodCodeRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\GenerateDefaultConstructors\GenerateDefaultConstructorsCodeRefactoringProvider.cs" />
<Compile Include="CodeRefactorings\GenerateFromMembers\AddConstructorParameters\AddConstructorParametersCodeRefactoringProvider.cs" />
......
......@@ -123,7 +123,7 @@
<Compile Include="CodeFixes\Spellcheck\VisualBasicSpellCheckCodeFixProvider.vb" />
<Compile Include="CodeFixes\Suppression\VisualBasicSuppressionCodeFixProvider.vb" />
<Compile Include="CodeLens\VisualBasicDisplayInfoService.vb" />
<Compile Include="CodeRefactorings\ConvertToInterpolatedString\ConvertToInterpolatedStringRefactoringProvider.vb" />
<Compile Include="CodeRefactorings\ConvertToInterpolatedString\VisualBasicConvertPlaceholderToInterpolatedStringRefactoringProvider.vb" />
<Compile Include="CodeRefactorings\EncapsulateField\EncapsulateFieldRefactoringProvider.vb" />
<Compile Include="CodeRefactorings\ExtractInterface\ExtractInterfaceCodeRefactoringProvider.vb" />
<Compile Include="CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.ReferenceRewriter.vb" />
......
Imports System.Composition
' 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
Imports Microsoft.CodeAnalysis.CodeRefactorings
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory
<ExportCodeRefactoringProvider(LanguageNames.VisualBasic, Name:=PredefinedCodeRefactoringProviderNames.ExtractMethod), [Shared]>
Partial Friend Class ConvertToInterpolatedStringRefactoringProvider
Inherits AbstractConvertToInterpolatedStringRefactoringProvider(Of InvocationExpressionSyntax, ExpressionSyntax, ArgumentSyntax, LiteralExpressionSyntax)
Partial Friend Class VisualBasicConvertPlaceholderToInterpolatedStringRefactoringProvider
Inherits AbstractConvertPlaceholderToInterpolatedStringRefactoringProvider(Of InvocationExpressionSyntax, ExpressionSyntax, ArgumentSyntax, LiteralExpressionSyntax)
Protected Overrides Function GetInterpolatedString(text As String) As SyntaxNode
Return TryCast(ParseExpression("$" + text), InterpolatedStringExpressionSyntax)
Return TryCast(SyntaxFactory.ParseExpression("$" + text), InterpolatedStringExpressionSyntax)
End Function
End Class
End Class
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册