提交 b03a0623 编写于 作者: S Sam Harwell

Avoid passing options to AddIndentBlockOperations

上级 4a180e39
......@@ -54,7 +54,7 @@ private bool IsQuestionOrColonOfNewConditional(SyntaxToken token)
}
public override void AddIndentBlockOperations(
List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
if (node.HasAnnotation(SpecializedFormattingAnnotation) &&
node is ConditionalExpressionSyntax conditional)
......
......@@ -50,7 +50,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UseConditionalExpression
End Function
Public Overrides Sub AddIndentBlockOperationsSlow(
list As List(Of IndentBlockOperation), node As SyntaxNode, options As AnalyzerConfigOptions, ByRef nextOperation As NextIndentBlockOperationAction)
list As List(Of IndentBlockOperation), node As SyntaxNode, ByRef nextOperation As NextIndentBlockOperationAction)
If node.HasAnnotation(UseConditionalExpressionCodeFixHelpers.SpecializedFormattingAnnotation) AndAlso
TypeOf node Is TernaryConditionalExpressionSyntax Then
......
......@@ -22,7 +22,7 @@ internal sealed class ChangeSignatureFormattingRule : BaseFormattingRule
SyntaxKind.BracketedArgumentList,
SyntaxKind.AttributeArgumentList);
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
nextOperation.Invoke();
......
......@@ -45,7 +45,7 @@ public FormatLargeBinaryExpressionRule(ISyntaxFactsService syntaxFacts)
/// ...
/// </summary>
public override void AddIndentBlockOperations(
List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
if (_syntaxFacts.IsReturnStatement(node))
{
......
......@@ -33,10 +33,10 @@ public override sealed void AddAnchorIndentationOperations(List<AnchorIndentatio
[Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public override sealed void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
public override sealed void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
var nextOperationCopy = nextOperation;
AddIndentBlockOperationsSlow(list, node, options, ref nextOperationCopy);
AddIndentBlockOperationsSlow(list, node, ref nextOperationCopy);
}
[Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)]
......@@ -80,8 +80,8 @@ public virtual void AddAnchorIndentationOperationsSlow(List<AnchorIndentationOpe
/// <summary>
/// returns IndentBlockOperations under a node either by itself or by filtering/replacing operations returned by NextOperation
/// </summary>
public virtual void AddIndentBlockOperationsSlow(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, ref NextIndentBlockOperationAction nextOperation)
=> base.AddIndentBlockOperations(list, node, options, in nextOperation);
public virtual void AddIndentBlockOperationsSlow(List<IndentBlockOperation> list, SyntaxNode node, ref NextIndentBlockOperationAction nextOperation)
=> base.AddIndentBlockOperations(list, node, in nextOperation);
/// <summary>
/// returns AlignTokensOperations under a node either by itself or by filtering/replacing operations returned by NextOperation
......
......@@ -11,7 +11,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature
Friend NotInheritable Class ChangeSignatureFormattingRule
Inherits BaseFormattingRule
Public Overrides Sub AddIndentBlockOperationsSlow(list As List(Of IndentBlockOperation), node As SyntaxNode, options As AnalyzerConfigOptions, ByRef nextOperation As NextIndentBlockOperationAction)
Public Overrides Sub AddIndentBlockOperationsSlow(list As List(Of IndentBlockOperation), node As SyntaxNode, ByRef nextOperation As NextIndentBlockOperationAction)
nextOperation.Invoke()
If node.IsKind(SyntaxKind.ParameterList) OrElse node.IsKind(SyntaxKind.ArgumentList) Then
......
......@@ -138,7 +138,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Venus
Public Shared Shadows Instance As AbstractFormattingRule = New VisualBasicHelperFormattingRule()
Public Overrides Sub AddIndentBlockOperationsSlow(list As List(Of IndentBlockOperation), node As SyntaxNode, options As AnalyzerConfigOptions, ByRef nextOperation As NextIndentBlockOperationAction)
Public Overrides Sub AddIndentBlockOperationsSlow(list As List(Of IndentBlockOperation), node As SyntaxNode, ByRef nextOperation As NextIndentBlockOperationAction)
' we need special behavior for VB due to @Helper code generation weird-ness.
' this will looking for code gen specific style to make it not so expansive
If IsEndHelperPattern(node) Then
......@@ -150,7 +150,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Venus
Return
End If
MyBase.AddIndentBlockOperationsSlow(list, node, options, nextOperation)
MyBase.AddIndentBlockOperationsSlow(list, node, nextOperation)
End Sub
Private Shared Function IsHelperSubLambda(multiLineLambda As MultiLineLambdaExpressionSyntax) As Boolean
......
......@@ -8,7 +8,6 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.Host.Mef;
......@@ -107,7 +106,7 @@ private static bool IsInvalidToken(SyntaxToken token)
private class FormattingRule : AbstractFormattingRule
{
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
// these nodes should be from syntax tree from ITextSnapshot.
Debug.Assert(node.SyntaxTree != null);
......
......@@ -30,7 +30,7 @@ public override void AddAnchorIndentationOperations(List<AnchorIndentationOperat
{
}
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
}
......
......@@ -11,6 +11,7 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.Text;
......@@ -18,21 +19,45 @@
namespace Microsoft.CodeAnalysis.CSharp.Formatting
{
internal class IndentBlockFormattingRule : BaseFormattingRule
internal sealed class IndentBlockFormattingRule : BaseFormattingRule
{
internal const string Name = "CSharp IndentBlock Formatting Rule";
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
private readonly CachedOptions _options;
public IndentBlockFormattingRule()
: this(new CachedOptions(null))
{
}
private IndentBlockFormattingRule(CachedOptions options)
{
_options = options;
}
public override AbstractFormattingRule WithOptions(AnalyzerConfigOptions options)
{
var cachedOptions = new CachedOptions(options);
if (cachedOptions == _options)
{
return this;
}
return new IndentBlockFormattingRule(cachedOptions);
}
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
nextOperation.Invoke();
AddAlignmentBlockOperation(list, node);
AddBlockIndentationOperation(list, node, options);
AddBlockIndentationOperation(list, node);
AddLabelIndentationOperation(list, node, options);
AddLabelIndentationOperation(list, node);
AddSwitchIndentationOperation(list, node, options);
AddSwitchIndentationOperation(list, node);
AddEmbeddedStatementsIndentationOperation(list, node);
......@@ -48,7 +73,7 @@ private void AddTypeParameterConstraintClauseOperation(List<IndentBlockOperation
}
}
private void AddSwitchIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options)
private void AddSwitchIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
{
if (!(node is SwitchSectionSyntax section))
{
......@@ -62,25 +87,23 @@ private void AddSwitchIndentationOperation(List<IndentBlockOperation> list, Synt
return;
}
var indentSwitchCase = options.GetOption(CSharpFormattingOptions2.IndentSwitchCaseSection);
var indentSwitchCaseWhenBlock = options.GetOption(CSharpFormattingOptions2.IndentSwitchCaseSectionWhenBlock);
if (!indentSwitchCase && !indentSwitchCaseWhenBlock)
if (!_options.IndentSwitchCaseSection && !_options.IndentSwitchCaseSectionWhenBlock)
{
// Never indent
return;
}
var alwaysIndent = indentSwitchCase && indentSwitchCaseWhenBlock;
var alwaysIndent = _options.IndentSwitchCaseSection && _options.IndentSwitchCaseSectionWhenBlock;
if (!alwaysIndent)
{
// Only one of these values can be true at this point.
Debug.Assert(indentSwitchCase != indentSwitchCaseWhenBlock);
Debug.Assert(_options.IndentSwitchCaseSection != _options.IndentSwitchCaseSectionWhenBlock);
var firstStatementIsBlock =
section.Statements.Count > 0 &&
section.Statements[0].IsKind(SyntaxKind.Block);
if (indentSwitchCaseWhenBlock != firstStatementIsBlock)
if (_options.IndentSwitchCaseSectionWhenBlock != firstStatementIsBlock)
{
return;
}
......@@ -113,18 +136,16 @@ private void AddSwitchIndentationOperation(List<IndentBlockOperation> list, Synt
AddIndentBlockOperation(list, startToken, endToken, span);
}
private void AddLabelIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options)
private void AddLabelIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
{
// label statement
if (node is LabeledStatementSyntax labeledStatement)
{
var labelPositioningOption = options.GetOption(CSharpFormattingOptions2.LabelPositioning);
if (labelPositioningOption == LabelPositionOptions.OneLess)
if (_options.LabelPositioning == LabelPositionOptions.OneLess)
{
AddUnindentBlockOperation(list, labeledStatement.Identifier, labeledStatement.ColonToken);
}
else if (labelPositioningOption == LabelPositionOptions.LeftMost)
else if (_options.LabelPositioning == LabelPositionOptions.LeftMost)
{
AddAbsoluteZeroIndentBlockOperation(list, labeledStatement.Identifier, labeledStatement.ColonToken);
}
......@@ -178,7 +199,7 @@ private void SetAlignmentBlockOperation(List<IndentBlockOperation> list, SyntaxN
SetAlignmentBlockOperation(list, baseToken, firstToken, lastToken, option);
}
private void AddBlockIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options)
private void AddBlockIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
{
var bracePair = node.GetBracePair();
......@@ -200,13 +221,13 @@ private void AddBlockIndentationOperation(List<IndentBlockOperation> list, Synta
AddAlignmentBlockOperationRelativeToFirstTokenOnBaseTokenLine(list, bracePair);
}
if (node is BlockSyntax && !options.GetOption(CSharpFormattingOptions2.IndentBlock))
if (node is BlockSyntax && !_options.IndentBlock)
{
// do not add indent operation for block
return;
}
if (node is SwitchStatementSyntax && !options.GetOption(CSharpFormattingOptions2.IndentSwitchSection))
if (node is SwitchStatementSyntax && !_options.IndentSwitchSection)
{
// do not add indent operation for switch statement
return;
......@@ -299,5 +320,60 @@ private void AddEmbeddedStatementsIndentationOperation(List<IndentBlockOperation
AddIndentBlockOperation(list, firstToken, lastToken, TextSpan.FromBounds(firstToken.FullSpan.Start, lastToken.FullSpan.End));
}
}
private readonly struct CachedOptions : IEquatable<CachedOptions>
{
public readonly LabelPositionOptions LabelPositioning;
public readonly bool IndentBlock;
public readonly bool IndentSwitchCaseSection;
public readonly bool IndentSwitchCaseSectionWhenBlock;
public readonly bool IndentSwitchSection;
public CachedOptions(AnalyzerConfigOptions? options)
{
LabelPositioning = GetOptionOrDefault(options, CSharpFormattingOptions2.LabelPositioning);
IndentBlock = GetOptionOrDefault(options, CSharpFormattingOptions2.IndentBlock);
IndentSwitchCaseSection = GetOptionOrDefault(options, CSharpFormattingOptions2.IndentSwitchCaseSection);
IndentSwitchCaseSectionWhenBlock = GetOptionOrDefault(options, CSharpFormattingOptions2.IndentSwitchCaseSectionWhenBlock);
IndentSwitchSection = GetOptionOrDefault(options, CSharpFormattingOptions2.IndentSwitchSection);
}
public static bool operator ==(CachedOptions left, CachedOptions right)
=> left.Equals(right);
public static bool operator !=(CachedOptions left, CachedOptions right)
=> !(left == right);
private static T GetOptionOrDefault<T>(AnalyzerConfigOptions? options, Option2<T> option)
{
if (options is null)
return option.DefaultValue;
return options.GetOption(option);
}
public override bool Equals(object? obj)
=> obj is CachedOptions options && Equals(options);
public bool Equals(CachedOptions other)
{
return LabelPositioning == other.LabelPositioning
&& IndentBlock == other.IndentBlock
&& IndentSwitchCaseSection == other.IndentSwitchCaseSection
&& IndentSwitchCaseSectionWhenBlock == other.IndentSwitchCaseSectionWhenBlock
&& IndentSwitchSection == other.IndentSwitchSection;
}
public override int GetHashCode()
{
var hashCode = 0;
hashCode = (hashCode << 2) + (int)LabelPositioning;
hashCode = (hashCode << 1) + (IndentBlock ? 1 : 0);
hashCode = (hashCode << 1) + (IndentSwitchCaseSection ? 1 : 0);
hashCode = (hashCode << 1) + (IndentSwitchCaseSectionWhenBlock ? 1 : 0);
hashCode = (hashCode << 1) + (IndentSwitchSection ? 1 : 0);
return hashCode;
}
}
}
}
......@@ -4,15 +4,41 @@
#nullable enable
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.Options;
namespace Microsoft.CodeAnalysis.CSharp.Formatting
{
internal class IndentUserSettingsFormattingRule : BaseFormattingRule
internal sealed class IndentUserSettingsFormattingRule : BaseFormattingRule
{
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
private readonly CachedOptions _options;
public IndentUserSettingsFormattingRule()
: this(new CachedOptions(null))
{
}
private IndentUserSettingsFormattingRule(CachedOptions options)
{
_options = options;
}
public override AbstractFormattingRule WithOptions(AnalyzerConfigOptions options)
{
var cachedOptions = new CachedOptions(options);
if (cachedOptions == _options)
{
return this;
}
return new IndentUserSettingsFormattingRule(cachedOptions);
}
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
nextOperation.Invoke();
......@@ -24,11 +50,50 @@ public override void AddIndentBlockOperations(List<IndentBlockOperation> list, S
return;
}
if (options.GetOption(CSharpFormattingOptions2.IndentBraces))
if (_options.IndentBraces)
{
AddIndentBlockOperation(list, bracePair.Item1, bracePair.Item1, bracePair.Item1.Span);
AddIndentBlockOperation(list, bracePair.Item2, bracePair.Item2, bracePair.Item2.Span);
}
}
private readonly struct CachedOptions : IEquatable<CachedOptions>
{
public readonly bool IndentBraces;
public CachedOptions(AnalyzerConfigOptions? options)
{
IndentBraces = GetOptionOrDefault(options, CSharpFormattingOptions2.IndentBraces);
}
public static bool operator ==(CachedOptions left, CachedOptions right)
=> left.Equals(right);
public static bool operator !=(CachedOptions left, CachedOptions right)
=> !(left == right);
private static T GetOptionOrDefault<T>(AnalyzerConfigOptions? options, Option2<T> option)
{
if (options is null)
return option.DefaultValue;
return options.GetOption(option);
}
public override bool Equals(object? obj)
=> obj is CachedOptions options && Equals(options);
public bool Equals(CachedOptions other)
{
return IndentBraces == other.IndentBraces;
}
public override int GetHashCode()
{
var hashCode = 0;
hashCode = (hashCode << 1) + (IndentBraces ? 1 : 0);
return hashCode;
}
}
}
}
......@@ -56,7 +56,7 @@ private void AddIndentBlockOperationsForFromClause(List<IndentBlockOperation> li
AddIndentBlockOperation(list, baseToken, startToken, endToken);
}
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
nextOperation.Invoke();
......
......@@ -60,7 +60,7 @@ public void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list
public void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode currentNode)
{
var action = new NextIndentBlockOperationAction(_addIndentBlockOperationsRules, index: 0, currentNode, _options, list);
var action = new NextIndentBlockOperationAction(_addIndentBlockOperationsRules, index: 0, currentNode, list);
action.Invoke();
}
......
......@@ -34,7 +34,7 @@ public virtual void AddAnchorIndentationOperations(List<AnchorIndentationOperati
/// <summary>
/// returns IndentBlockOperations under a node either by itself or by filtering/replacing operations returned by NextOperation
/// </summary>
public virtual void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
public virtual void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
=> nextOperation.Invoke();
/// <summary>
......
......@@ -6,7 +6,6 @@
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
......@@ -31,7 +30,7 @@ public BaseIndentationFormattingRule(SyntaxNode root, TextSpan span, int baseInd
_vbHelperFormattingRule = vbHelperFormattingRule;
}
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
// for the common node itself, return absolute indentation
if (_commonNode == node)
......@@ -48,21 +47,21 @@ public override void AddIndentBlockOperations(List<IndentBlockOperation> list, S
}
// Add everything to the list.
AddNextIndentBlockOperations(list, node, options, in nextOperation);
AddNextIndentBlockOperations(list, node, in nextOperation);
// Filter out everything that encompasses our span.
AdjustIndentBlockOperation(list);
}
private void AddNextIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
private void AddNextIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
if (_vbHelperFormattingRule == null)
{
base.AddIndentBlockOperations(list, node, options, in nextOperation);
base.AddIndentBlockOperations(list, node, in nextOperation);
return;
}
_vbHelperFormattingRule.AddIndentBlockOperations(list, node, options, in nextOperation);
_vbHelperFormattingRule.AddIndentBlockOperations(list, node, in nextOperation);
}
private void AdjustIndentBlockOperation(List<IndentBlockOperation> list)
......
......@@ -32,10 +32,10 @@ public override sealed void AddAnchorIndentationOperations(List<AnchorIndentatio
[Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public override sealed void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextIndentBlockOperationAction nextOperation)
public override sealed void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
{
var nextOperationCopy = nextOperation;
AddIndentBlockOperationsSlow(list, node, options, ref nextOperationCopy);
AddIndentBlockOperationsSlow(list, node, ref nextOperationCopy);
}
[Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)]
......@@ -79,8 +79,8 @@ public virtual void AddAnchorIndentationOperationsSlow(List<AnchorIndentationOpe
/// <summary>
/// returns IndentBlockOperations under a node either by itself or by filtering/replacing operations returned by NextOperation
/// </summary>
public virtual void AddIndentBlockOperationsSlow(List<IndentBlockOperation> list, SyntaxNode node, AnalyzerConfigOptions options, ref NextIndentBlockOperationAction nextOperation)
=> base.AddIndentBlockOperations(list, node, options, in nextOperation);
public virtual void AddIndentBlockOperationsSlow(List<IndentBlockOperation> list, SyntaxNode node, ref NextIndentBlockOperationAction nextOperation)
=> base.AddIndentBlockOperations(list, node, in nextOperation);
/// <summary>
/// returns AlignTokensOperations under a node either by itself or by filtering/replacing operations returned by NextOperation
......
......@@ -6,7 +6,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Diagnostics;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Formatting.Rules
......@@ -17,25 +16,22 @@ namespace Microsoft.CodeAnalysis.Formatting.Rules
private readonly ImmutableArray<AbstractFormattingRule> _formattingRules;
private readonly int _index;
private readonly SyntaxNode _node;
private readonly AnalyzerConfigOptions _options;
private readonly List<IndentBlockOperation> _list;
public NextIndentBlockOperationAction(
ImmutableArray<AbstractFormattingRule> formattingRules,
int index,
SyntaxNode node,
AnalyzerConfigOptions options,
List<IndentBlockOperation> list)
{
_formattingRules = formattingRules;
_index = index;
_node = node;
_options = options;
_list = list;
}
private NextIndentBlockOperationAction NextAction
=> new NextIndentBlockOperationAction(_formattingRules, _index + 1, _node, _options, _list);
=> new NextIndentBlockOperationAction(_formattingRules, _index + 1, _node, _list);
public void Invoke()
{
......@@ -47,7 +43,7 @@ public void Invoke()
else
{
// Call the handler at the index, passing a continuation that will come back to here with index + 1
_formattingRules[_index].AddIndentBlockOperations(_list, _node, _options, NextAction);
_formattingRules[_index].AddIndentBlockOperations(_list, _node, NextAction);
return;
}
}
......
......@@ -28,7 +28,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public Overrides Sub AddAnchorIndentationOperationsSlow(operations As List(Of AnchorIndentationOperation), node As SyntaxNode, ByRef nextAction As NextAnchorIndentationOperationAction)
End Sub
Public Overrides Sub AddIndentBlockOperationsSlow(operations As List(Of IndentBlockOperation), node As SyntaxNode, options As AnalyzerConfigOptions, ByRef nextAction As NextIndentBlockOperationAction)
Public Overrides Sub AddIndentBlockOperationsSlow(operations As List(Of IndentBlockOperation), node As SyntaxNode, ByRef nextAction As NextIndentBlockOperationAction)
End Sub
Public Overrides Sub AddAlignTokensOperationsSlow(operations As List(Of AlignTokensOperation), node As SyntaxNode, options As AnalyzerConfigOptions, ByRef nextAction As NextAlignTokensOperationAction)
......
......@@ -19,7 +19,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
nextOperation.Invoke()
End Sub
Public Overrides Sub AddIndentBlockOperationsSlow(list As List(Of IndentBlockOperation), node As SyntaxNode, options As AnalyzerConfigOptions, ByRef nextOperation As NextIndentBlockOperationAction)
Public Overrides Sub AddIndentBlockOperationsSlow(list As List(Of IndentBlockOperation), node As SyntaxNode, ByRef nextOperation As NextIndentBlockOperationAction)
nextOperation.Invoke()
If node.Kind = SyntaxKind.ObjectMemberInitializer Then
......
......@@ -3,7 +3,6 @@
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Formatting.Rules
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
......@@ -49,7 +48,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public Overrides Sub AddIndentBlockOperationsSlow(operations As List(Of IndentBlockOperation),
node As SyntaxNode,
options As AnalyzerConfigOptions,
ByRef nextOperation As NextIndentBlockOperationAction)
nextOperation.Invoke()
......
......@@ -54,7 +54,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation
Return spaceOperation
End Function
Public Overrides Sub AddIndentBlockOperationsSlow(list As List(Of IndentBlockOperation), node As SyntaxNode, options As AnalyzerConfigOptions, ByRef nextOperation As NextIndentBlockOperationAction)
Public Overrides Sub AddIndentBlockOperationsSlow(list As List(Of IndentBlockOperation), node As SyntaxNode, ByRef nextOperation As NextIndentBlockOperationAction)
nextOperation.Invoke()
Dim singleLineLambdaFunction = TryCast(node, SingleLineLambdaExpressionSyntax)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册