-
Notifications
You must be signed in to change notification settings - Fork 4k
/
CodeRefactoringProvider.cs
50 lines (45 loc) · 2.11 KB
/
CodeRefactoringProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CodeRefactorings
{
/// <summary>
/// Inherit this type to provide source code refactorings.
/// Remember to use <see cref="ExportCodeRefactoringProviderAttribute"/> so the host environment can offer your refactorings in a UI.
/// </summary>
public abstract class CodeRefactoringProvider
{
/// <summary>
/// Computes one or more refactorings for the specified <see cref="CodeRefactoringContext"/>.
/// </summary>
public abstract Task ComputeRefactoringsAsync(CodeRefactoringContext context);
/// <summary>
/// Gets an optional <see cref="FixAllProvider"/> that can apply multiple occurrences of code refactoring(s)
/// registered by this code refactoring provider across the supported <see cref="CodeFixes.FixAllScope"/>s.
/// Return null if the provider doesn't support fix all operation.
/// </summary>
/// <remarks>
/// TODO: Make public, tracked with https://github.com/dotnet/roslyn/issues/60703
/// </remarks>
internal virtual FixAllProvider? GetFixAllProvider()
=> null;
/// <summary>
/// What priority this provider should run at.
/// </summary>
internal CodeActionRequestPriority RequestPriority
{
get
{
var priority = ComputeRequestPriority();
// Note: CodeActionRequestPriority.Lowest is reserved for IConfigurationFixProvider.
Contract.ThrowIfFalse(priority is CodeActionRequestPriority.Low or CodeActionRequestPriority.Normal or CodeActionRequestPriority.High);
return priority;
}
}
private protected virtual CodeActionRequestPriority ComputeRequestPriority()
=> CodeActionRequestPriority.Normal;
}
}