提交 59e3fefb 编写于 作者: M Manish Vasani

Add annotation based Formatter overload in CodeStyle layer that is used by the...

Add annotation based Formatter overload in CodeStyle layer that is used by the code fixer - it is an internal Formatter API in Workspaces layer
上级 750e1eb7
......@@ -10,6 +10,7 @@
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions;
using static Microsoft.CodeAnalysis.Formatting.FormattingExtensions;
namespace Microsoft.CodeAnalysis.Formatting
{
......@@ -77,6 +78,23 @@ internal static async Task<SyntaxTree> FormatAsync(SyntaxTree syntaxTree, ISynta
public static SyntaxNode Format(SyntaxNode node, ISyntaxFormattingService syntaxFormattingService, OptionSet options, CancellationToken cancellationToken)
=> Format(node, syntaxFormattingService, SpecializedCollections.SingletonEnumerable(node.FullSpan), options, rules: null, cancellationToken: cancellationToken);
/// <summary>
/// Formats the whitespace of a syntax tree.
/// </summary>
/// <param name="node">The root node of a syntax tree.</param>
/// <param name="annotation">The descendant nodes of the root to format.</param>
/// <param name="options">An optional set of formatting options. If these options are not supplied the current set of options from the workspace will be used.</param>
/// <param name="cancellationToken">An optional cancellation token.</param>
/// <returns>The formatted tree's root node.</returns>
public static SyntaxNode Format(SyntaxNode node, ISyntaxFormattingService syntaxFormattingService, SyntaxAnnotation annotation, OptionSet options, IEnumerable<AbstractFormattingRule> rules, CancellationToken cancellationToken)
{
var spans = (annotation == SyntaxAnnotation.ElasticAnnotation)
? GetElasticSpans(node)
: GetAnnotatedSpans(node, annotation);
return Format(node, syntaxFormattingService, spans, options, rules, cancellationToken: cancellationToken);
}
internal static SyntaxNode Format(SyntaxNode node, ISyntaxFormattingService syntaxFormattingService, IEnumerable<TextSpan> spans, OptionSet options, IEnumerable<AbstractFormattingRule> rules, CancellationToken cancellationToken)
{
var formattingResult = GetFormattingResult(node, syntaxFormattingService, spans, options, rules, cancellationToken);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册