提交 454067f7 编写于 作者: S Sam Harwell

Share ISyntaxFormattingService and implementations

上级 fa39d3ad
// 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.Collections.Generic;
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.Shared.Collections;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp.Formatting
{
internal class CSharpSyntaxFormattingService : AbstractSyntaxFormattingService
{
private readonly ImmutableList<IFormattingRule> _rules;
public CSharpSyntaxFormattingService()
{
_rules = ImmutableList.Create<IFormattingRule>(
new WrappingFormattingRule(),
new SpacingFormattingRule(),
new NewLineUserSettingFormattingRule(),
new IndentUserSettingsFormattingRule(),
new ElasticTriviaFormattingRule(),
new EndOfFileTokenFormattingRule(),
new StructuredTriviaFormattingRule(),
new IndentBlockFormattingRule(),
new SuppressFormattingRule(),
new AnchorIndentationFormattingRule(),
new QueryExpressionFormattingRule(),
new TokenBasedFormattingRule(),
new DefaultOperationProvider());
}
public override IEnumerable<IFormattingRule> GetDefaultFormattingRules()
{
return _rules;
}
protected override IFormattingResult CreateAggregatedFormattingResult(SyntaxNode node, IList<AbstractFormattingResult> results, SimpleIntervalTree<TextSpan> formattingSpans = null)
{
return new AggregatedFormattingResult(node, results, formattingSpans);
}
protected override AbstractFormattingResult Format(SyntaxNode node, OptionSet optionSet, IEnumerable<IFormattingRule> formattingRules, SyntaxToken token1, SyntaxToken token2, CancellationToken cancellationToken)
{
return new CSharpFormatEngine(node, optionSet, formattingRules, token1, token2).Format(cancellationToken);
}
}
}
......@@ -27,6 +27,7 @@
<Compile Include="..\..\..\Workspaces\CSharp\Portable\Extensions\SyntaxNodeExtensions_SharedWithCodeStyle.cs" Link="Formatting\SyntaxNodeExtensions_SharedWithCodeStyle.cs" />
<Compile Include="..\..\..\Workspaces\CSharp\Portable\Extensions\SyntaxTokenExtensions_SharedWithCodeStyle.cs" Link="Formatting\SyntaxTokenExtensions_SharedWithCodeStyle.cs" />
<Compile Include="..\..\..\Workspaces\CSharp\Portable\Extensions\SyntaxTriviaExtensions.cs" Link="Formatting\SyntaxTriviaExtensions.cs" />
<Compile Include="..\..\..\Workspaces\CSharp\Portable\Formatting\CSharpSyntaxFormattingService.cs" Link="Formatting\CSharpSyntaxFormattingService.cs" />
<Compile Include="..\..\..\Workspaces\CSharp\Portable\Formatting\DefaultOperationProvider.cs" Link="Formatting\DefaultOperationProvider.cs" />
<Compile Include="..\..\..\Workspaces\CSharp\Portable\Formatting\Engine\AggregatedFormattingResult.cs" Link="Formatting\Engine\AggregatedFormattingResult.cs" />
<Compile Include="..\..\..\Workspaces\CSharp\Portable\Formatting\Engine\CSharpFormatEngine.cs" Link="Formatting\Engine\CSharpFormatEngine.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;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared;
using Microsoft.CodeAnalysis.Shared.Collections;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Formatting
{
internal abstract class AbstractSyntaxFormattingService : ISyntaxFormattingService
{
private static readonly Func<TextSpan, bool> s_notEmpty = s => !s.IsEmpty;
private static readonly Func<TextSpan, int> s_spanLength = s => s.Length;
protected AbstractSyntaxFormattingService()
{
}
public abstract IEnumerable<IFormattingRule> GetDefaultFormattingRules();
protected abstract IFormattingResult CreateAggregatedFormattingResult(SyntaxNode node, IList<AbstractFormattingResult> results, SimpleIntervalTree<TextSpan> formattingSpans = null);
protected abstract AbstractFormattingResult Format(SyntaxNode node, OptionSet options, IEnumerable<IFormattingRule> rules, SyntaxToken token1, SyntaxToken token2, CancellationToken cancellationToken);
public IFormattingResult Format(SyntaxNode node, IEnumerable<TextSpan> spans, OptionSet options, IEnumerable<IFormattingRule> rules, CancellationToken cancellationToken)
{
CheckArguments(node, spans, options, rules);
// quick exit check
var spansToFormat = new NormalizedTextSpanCollection(spans.Where(s_notEmpty));
if (spansToFormat.Count == 0)
{
return CreateAggregatedFormattingResult(node, SpecializedCollections.EmptyList<AbstractFormattingResult>());
}
// check what kind of formatting strategy to use
if (AllowDisjointSpanMerging(spansToFormat, options.GetOption(FormattingOptions.AllowDisjointSpanMerging)))
{
return FormatMergedSpan(node, options, rules, spansToFormat, cancellationToken);
}
return FormatIndividually(node, options, rules, spansToFormat, cancellationToken);
}
private IFormattingResult FormatMergedSpan(
SyntaxNode node, OptionSet options, IEnumerable<IFormattingRule> rules, IList<TextSpan> spansToFormat, CancellationToken cancellationToken)
{
var spanToFormat = TextSpan.FromBounds(spansToFormat[0].Start, spansToFormat[spansToFormat.Count - 1].End);
var pair = node.ConvertToTokenPair(spanToFormat);
if (node.IsInvalidTokenRange(pair.Item1, pair.Item2))
{
return CreateAggregatedFormattingResult(node, SpecializedCollections.EmptyList<AbstractFormattingResult>());
}
// more expensive case
var result = Format(node, options, rules, pair.Item1, pair.Item2, cancellationToken);
return CreateAggregatedFormattingResult(node, new List<AbstractFormattingResult>(1) { result }, SimpleIntervalTree.Create(TextSpanIntervalIntrospector.Instance, spanToFormat));
}
private IFormattingResult FormatIndividually(
SyntaxNode node, OptionSet options, IEnumerable<IFormattingRule> rules, IList<TextSpan> spansToFormat, CancellationToken cancellationToken)
{
List<AbstractFormattingResult> results = null;
foreach (var pair in node.ConvertToTokenPairs(spansToFormat))
{
if (node.IsInvalidTokenRange(pair.Item1, pair.Item2))
{
continue;
}
results = results ?? new List<AbstractFormattingResult>();
results.Add(Format(node, options, rules, pair.Item1, pair.Item2, cancellationToken));
}
// quick simple case check
if (results == null)
{
return CreateAggregatedFormattingResult(node, SpecializedCollections.EmptyList<AbstractFormattingResult>());
}
if (results.Count == 1)
{
return results[0];
}
// more expensive case
return CreateAggregatedFormattingResult(node, results);
}
private bool AllowDisjointSpanMerging(IList<TextSpan> list, bool shouldUseFormattingSpanCollapse)
{
// If the user is specific about the formatting specific spans then honor users settings
if (!shouldUseFormattingSpanCollapse)
{
return false;
}
// most common case. it is either just formatting a whole file, a selection or some generate XXX refactoring.
if (list.Count <= 3)
{
// don't collapse formatting spans
return false;
}
// too many formatting spans, just collapse them and format at once
if (list.Count > 30)
{
// figuring out base indentation at random place in a file takes about 2ms.
// doing 30 times will make it cost about 60ms. that is about same cost, for the same file, engine will
// take to create full formatting context. basically after that, creating full context is cheaper than
// doing bottom up base indentation calculation for each span.
return true;
}
// check how much area we are formatting
var formattingSpan = TextSpan.FromBounds(list[0].Start, list[list.Count - 1].End);
var actualFormattingSize = list.Sum(s_spanLength);
// we are formatting more than half of the collapsed span.
return (formattingSpan.Length / Math.Max(actualFormattingSize, 1)) < 2;
}
private static void CheckArguments(SyntaxNode node, IEnumerable<TextSpan> spans, OptionSet options, IEnumerable<IFormattingRule> rules)
{
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
if (spans == null)
{
throw new ArgumentNullException(nameof(spans));
}
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
if (rules == null)
{
throw new ArgumentException("rules");
}
}
}
}
// 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.Collections.Generic;
using System.Threading;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Formatting
{
internal interface ISyntaxFormattingService
{
IEnumerable<IFormattingRule> GetDefaultFormattingRules();
IFormattingResult Format(SyntaxNode node, IEnumerable<TextSpan> spans, OptionSet options, IEnumerable<IFormattingRule> rules, CancellationToken cancellationToken);
}
}
......@@ -53,6 +53,7 @@
<Compile Include="..\..\..\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs" Link="InternalUtilities\SyntaxTreeExtensions.cs" />
<Compile Include="..\..\..\Features\Core\Portable\Diagnostics\Analyzers\IDEDiagnosticIds.cs" Link="IDEDiagnosticIds.cs" />
<Compile Include="..\..\..\Features\Core\Portable\Diagnostics\DiagnosticCustomTags.cs" Link="DiagnosticCustomTags.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\AbstractSyntaxFormattingService.cs" Link="Formatting\AbstractSyntaxFormattingService.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\BottomUpBaseIndentationFinder.cs" Link="Formatting\BottomUpBaseIndentationFinder.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\ContextIntervalTree.cs" Link="Formatting\ContextIntervalTree.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\Context\FormattingContext.AnchorData.cs" Link="Formatting\Context\FormattingContext.AnchorData.cs" />
......@@ -90,6 +91,7 @@
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\Engine\TriviaDataWithList.cs" Link="Formatting\Engine\TriviaDataWithList.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\FormattingExtensions.cs" Link="Formatting\FormattingExtensions.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\IFormattingResult.cs" Link="Formatting\IFormattingResult.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\ISyntaxFormattingService.cs" Link="Formatting\ISyntaxFormattingService.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\ListPool.cs" Link="Formatting\ListPool.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\Rules\AbstractFormattingRule.cs" Link="Formatting\Rules\AbstractFormattingRule.cs" />
<Compile Include="..\..\..\Workspaces\Core\Portable\Formatting\Rules\BaseIndentationFormattingRule.cs" Link="Formatting\Rules\BaseIndentationFormattingRule.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.
Imports System.Collections.Immutable
Imports System.Threading
Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.Formatting.Rules
Imports Microsoft.CodeAnalysis.Shared.Collections
Imports Microsoft.CodeAnalysis.Text
Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Friend Class VisualBasicSyntaxFormattingService
Inherits AbstractSyntaxFormattingService
Private ReadOnly _rules As ImmutableList(Of IFormattingRule)
Public Sub New()
_rules = ImmutableList.Create(Of IFormattingRule)(
New StructuredTriviaFormattingRule(),
New ElasticTriviaFormattingRule(),
New AdjustSpaceFormattingRule(),
New AlignTokensFormattingRule(),
New NodeBasedFormattingRule(),
New DefaultOperationProvider())
End Sub
Public Overrides Function GetDefaultFormattingRules() As IEnumerable(Of IFormattingRule)
Return _rules
End Function
Protected Overrides Function CreateAggregatedFormattingResult(node As SyntaxNode, results As IList(Of AbstractFormattingResult), Optional formattingSpans As SimpleIntervalTree(Of TextSpan) = Nothing) As IFormattingResult
Return New AggregatedFormattingResult(node, results, formattingSpans)
End Function
Protected Overrides Function Format(root As SyntaxNode, options As OptionSet, formattingRules As IEnumerable(Of IFormattingRule), token1 As SyntaxToken, token2 As SyntaxToken, cancellationToken As CancellationToken) As AbstractFormattingResult
Return New VisualBasicFormatEngine(root, options, formattingRules, token1, token2).Format(cancellationToken)
End Function
End Class
End Namespace
......@@ -35,6 +35,7 @@
<Compile Include="..\..\..\Workspaces\VisualBasic\Portable\Formatting\Rules\ElasticTriviaFormattingRule.vb" Link="Formatting\Rules\ElasticTriviaFormattingRule.vb" />
<Compile Include="..\..\..\Workspaces\VisualBasic\Portable\Formatting\Rules\NodeBasedFormattingRule.vb" Link="Formatting\Rules\NodeBasedFormattingRule.vb" />
<Compile Include="..\..\..\Workspaces\VisualBasic\Portable\Formatting\Rules\StructuredTriviaFormattingRule.vb" Link="Formatting\Rules\StructuredTriviaFormattingRule.vb" />
<Compile Include="..\..\..\Workspaces\VisualBasic\Portable\Formatting\VisualBasicSyntaxFormattingService.vb" Link="Formatting\VisualBasicSyntaxFormattingService.vb" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.CodeAnalysis.Shared.Extensions" />
......
// 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.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Collections;
using Microsoft.CodeAnalysis.Text;
#if !CODE_STYLE
using System;
using System.Composition;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
#endif
namespace Microsoft.CodeAnalysis.CSharp.Formatting
{
#if !CODE_STYLE
[ExportLanguageService(typeof(ISyntaxFormattingService), LanguageNames.CSharp), Shared]
#endif
internal class CSharpSyntaxFormattingService : AbstractSyntaxFormattingService
{
private readonly ImmutableList<IFormattingRule> _rules;
#if !CODE_STYLE
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
#endif
public CSharpSyntaxFormattingService()
{
_rules = ImmutableList.Create<IFormattingRule>(
......@@ -50,9 +56,9 @@ protected override IFormattingResult CreateAggregatedFormattingResult(SyntaxNode
return new AggregatedFormattingResult(node, results, formattingSpans);
}
protected override Task<AbstractFormattingResult> FormatAsync(SyntaxNode node, OptionSet optionSet, IEnumerable<IFormattingRule> formattingRules, SyntaxToken token1, SyntaxToken token2, CancellationToken cancellationToken)
protected override AbstractFormattingResult Format(SyntaxNode node, OptionSet optionSet, IEnumerable<IFormattingRule> formattingRules, SyntaxToken token1, SyntaxToken token2, CancellationToken cancellationToken)
{
return Task.FromResult(new CSharpFormatEngine(node, optionSet, formattingRules, token1, token2).Format(cancellationToken));
return new CSharpFormatEngine(node, optionSet, formattingRules, token1, token2).Format(cancellationToken);
}
}
}
......@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared;
......@@ -28,9 +27,9 @@ protected AbstractSyntaxFormattingService()
protected abstract IFormattingResult CreateAggregatedFormattingResult(SyntaxNode node, IList<AbstractFormattingResult> results, SimpleIntervalTree<TextSpan> formattingSpans = null);
protected abstract Task<AbstractFormattingResult> FormatAsync(SyntaxNode node, OptionSet options, IEnumerable<IFormattingRule> rules, SyntaxToken token1, SyntaxToken token2, CancellationToken cancellationToken);
protected abstract AbstractFormattingResult Format(SyntaxNode node, OptionSet options, IEnumerable<IFormattingRule> rules, SyntaxToken token1, SyntaxToken token2, CancellationToken cancellationToken);
public Task<IFormattingResult> FormatAsync(SyntaxNode node, IEnumerable<TextSpan> spans, OptionSet options, IEnumerable<IFormattingRule> rules, CancellationToken cancellationToken)
public IFormattingResult Format(SyntaxNode node, IEnumerable<TextSpan> spans, OptionSet options, IEnumerable<IFormattingRule> rules, CancellationToken cancellationToken)
{
CheckArguments(node, spans, options, rules);
......@@ -38,19 +37,19 @@ public Task<IFormattingResult> FormatAsync(SyntaxNode node, IEnumerable<TextSpan
var spansToFormat = new NormalizedTextSpanCollection(spans.Where(s_notEmpty));
if (spansToFormat.Count == 0)
{
return Task.FromResult(CreateAggregatedFormattingResult(node, SpecializedCollections.EmptyList<AbstractFormattingResult>()));
return CreateAggregatedFormattingResult(node, SpecializedCollections.EmptyList<AbstractFormattingResult>());
}
// check what kind of formatting strategy to use
if (AllowDisjointSpanMerging(spansToFormat, options.GetOption(FormattingOptions.AllowDisjointSpanMerging)))
{
return FormatMergedSpanAsync(node, options, rules, spansToFormat, cancellationToken);
return FormatMergedSpan(node, options, rules, spansToFormat, cancellationToken);
}
return FormatIndividuallyAsync(node, options, rules, spansToFormat, cancellationToken);
return FormatIndividually(node, options, rules, spansToFormat, cancellationToken);
}
private async Task<IFormattingResult> FormatMergedSpanAsync(
private IFormattingResult FormatMergedSpan(
SyntaxNode node, OptionSet options, IEnumerable<IFormattingRule> rules, IList<TextSpan> spansToFormat, CancellationToken cancellationToken)
{
var spanToFormat = TextSpan.FromBounds(spansToFormat[0].Start, spansToFormat[spansToFormat.Count - 1].End);
......@@ -62,11 +61,11 @@ public Task<IFormattingResult> FormatAsync(SyntaxNode node, IEnumerable<TextSpan
}
// more expensive case
var result = await FormatAsync(node, options, rules, pair.Item1, pair.Item2, cancellationToken).ConfigureAwait(false);
var result = Format(node, options, rules, pair.Item1, pair.Item2, cancellationToken);
return CreateAggregatedFormattingResult(node, new List<AbstractFormattingResult>(1) { result }, SimpleIntervalTree.Create(TextSpanIntervalIntrospector.Instance, spanToFormat));
}
private async Task<IFormattingResult> FormatIndividuallyAsync(
private IFormattingResult FormatIndividually(
SyntaxNode node, OptionSet options, IEnumerable<IFormattingRule> rules, IList<TextSpan> spansToFormat, CancellationToken cancellationToken)
{
List<AbstractFormattingResult> results = null;
......@@ -78,7 +77,7 @@ public Task<IFormattingResult> FormatAsync(SyntaxNode node, IEnumerable<TextSpan
}
results = results ?? new List<AbstractFormattingResult>();
results.Add(await FormatAsync(node, options, rules, pair.Item1, pair.Item2, cancellationToken).ConfigureAwait(false));
results.Add(Format(node, options, rules, pair.Item1, pair.Item2, cancellationToken));
}
// quick simple case check
......
......@@ -295,7 +295,7 @@ internal static Task<IFormattingResult> GetFormattingResult(SyntaxNode node, IEn
options = options ?? workspace.Options;
rules = rules ?? GetDefaultFormattingRules(workspace, node.Language);
spans = spans ?? SpecializedCollections.SingletonEnumerable(node.FullSpan);
return languageFormatter.FormatAsync(node, spans, options, rules, cancellationToken);
return Task.FromResult(languageFormatter.Format(node, spans, options, rules, cancellationToken));
}
/// <summary>
......
......@@ -2,17 +2,22 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.Text;
#if !CODE_STYLE
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Text;
#endif
namespace Microsoft.CodeAnalysis.Formatting
{
internal interface ISyntaxFormattingService : ILanguageService
internal interface ISyntaxFormattingService
#if !CODE_STYLE
: ILanguageService
#endif
{
IEnumerable<IFormattingRule> GetDefaultFormattingRules();
Task<IFormattingResult> FormatAsync(SyntaxNode node, IEnumerable<TextSpan> spans, OptionSet options, IEnumerable<IFormattingRule> rules, CancellationToken cancellationToken);
IFormattingResult Format(SyntaxNode node, IEnumerable<TextSpan> spans, OptionSet options, IEnumerable<IFormattingRule> rules, CancellationToken cancellationToken);
}
}
' 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.Collections.Immutable
Imports System.Composition
Imports System.Threading
Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.Formatting.Rules
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.CodeAnalysis.Shared.Collections
Imports Microsoft.CodeAnalysis.Text
#If Not CODE_STYLE Then
Imports System.Composition
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.Options
#End If
Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
#If Not CODE_STYLE Then
<ExportLanguageService(GetType(ISyntaxFormattingService), LanguageNames.VisualBasic), [Shared]>
Friend Class VisualBasicSyntaxFormattingService
#Else
Friend Class VisualBasicSyntaxFormattingService
#End If
Inherits AbstractSyntaxFormattingService
Private ReadOnly _rules As ImmutableList(Of IFormattingRule)
#If Not CODE_STYLE Then
<ImportingConstructor>
<Obsolete(MefConstruction.ImportingConstructorMessage, True)>
Public Sub New()
#Else
Public Sub New()
#End If
_rules = ImmutableList.Create(Of IFormattingRule)(
New StructuredTriviaFormattingRule(),
New ElasticTriviaFormattingRule(),
......@@ -37,8 +48,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Return New AggregatedFormattingResult(node, results, formattingSpans)
End Function
Protected Overrides Function FormatAsync(root As SyntaxNode, optionSet As OptionSet, formattingRules As IEnumerable(Of IFormattingRule), token1 As SyntaxToken, token2 As SyntaxToken, cancellationToken As CancellationToken) As Task(Of AbstractFormattingResult)
Return Task.FromResult(New VisualBasicFormatEngine(root, optionSet, formattingRules, token1, token2).Format(cancellationToken))
Protected Overrides Function Format(root As SyntaxNode, optionSet As OptionSet, formattingRules As IEnumerable(Of IFormattingRule), token1 As SyntaxToken, token2 As SyntaxToken, cancellationToken As CancellationToken) As AbstractFormattingResult
Return New VisualBasicFormatEngine(root, optionSet, formattingRules, token1, token2).Format(cancellationToken)
End Function
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册