提交 4a180e39 编写于 作者: S Sam Harwell

Avoid passing options to AddAnchorIndentationOperations

上级 8df8f936
...@@ -269,7 +269,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.LineCommit ...@@ -269,7 +269,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.LineCommit
Private Class NoAnchorFormatterRule Private Class NoAnchorFormatterRule
Inherits CompatAbstractFormattingRule Inherits CompatAbstractFormattingRule
Public Overrides Sub AddAnchorIndentationOperationsSlow(list As List(Of AnchorIndentationOperation), node As SyntaxNode, options As AnalyzerConfigOptions, ByRef nextOperation As NextAnchorIndentationOperationAction) Public Overrides Sub AddAnchorIndentationOperationsSlow(list As List(Of AnchorIndentationOperation), node As SyntaxNode, ByRef nextOperation As NextAnchorIndentationOperationAction)
' no anchor/relative formatting ' no anchor/relative formatting
Return Return
End Sub End Sub
......
...@@ -55,7 +55,7 @@ public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken p ...@@ -55,7 +55,7 @@ public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken p
return operation; return operation;
} }
public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextAnchorIndentationOperationAction nextOperation) public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
{ {
if (node.IsKind(SyntaxKind.SimpleLambdaExpression) || node.IsKind(SyntaxKind.ParenthesizedLambdaExpression) || node.IsKind(SyntaxKind.AnonymousMethodExpression)) if (node.IsKind(SyntaxKind.SimpleLambdaExpression) || node.IsKind(SyntaxKind.ParenthesizedLambdaExpression) || node.IsKind(SyntaxKind.AnonymousMethodExpression))
{ {
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.CSharp.DocumentationComments; using Microsoft.CodeAnalysis.CSharp.DocumentationComments;
using Microsoft.CodeAnalysis.CSharp.Simplification; using Microsoft.CodeAnalysis.CSharp.Simplification;
using Microsoft.CodeAnalysis.CSharp.Utilities; using Microsoft.CodeAnalysis.CSharp.Utilities;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.DocumentationComments; using Microsoft.CodeAnalysis.DocumentationComments;
using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Formatting.Rules; using Microsoft.CodeAnalysis.Formatting.Rules;
...@@ -115,7 +114,7 @@ protected override AdjustNewLinesOperation GetAdjustNewLinesOperationBetweenMemb ...@@ -115,7 +114,7 @@ protected override AdjustNewLinesOperation GetAdjustNewLinesOperationBetweenMemb
return FormattingOperations.CreateAdjustNewLinesOperation(GetNumberOfLines(triviaList) + 1, AdjustNewLinesOption.ForceLines); return FormattingOperations.CreateAdjustNewLinesOperation(GetNumberOfLines(triviaList) + 1, AdjustNewLinesOption.ForceLines);
} }
public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextAnchorIndentationOperationAction nextOperation) public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
{ {
return; return;
} }
......
...@@ -25,10 +25,10 @@ public override sealed void AddSuppressOperations(List<SuppressOperation> list, ...@@ -25,10 +25,10 @@ public override sealed void AddSuppressOperations(List<SuppressOperation> list,
[Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)] [Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override sealed void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextAnchorIndentationOperationAction nextOperation) public override sealed void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
{ {
var nextOperationCopy = nextOperation; var nextOperationCopy = nextOperation;
AddAnchorIndentationOperationsSlow(list, node, options, ref nextOperationCopy); AddAnchorIndentationOperationsSlow(list, node, ref nextOperationCopy);
} }
[Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)] [Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)]
...@@ -74,8 +74,8 @@ public virtual void AddSuppressOperationsSlow(List<SuppressOperation> list, Synt ...@@ -74,8 +74,8 @@ public virtual void AddSuppressOperationsSlow(List<SuppressOperation> list, Synt
/// <summary> /// <summary>
/// returns AnchorIndentationOperations under a node either by itself or by filtering/replacing operations returned by NextOperation /// returns AnchorIndentationOperations under a node either by itself or by filtering/replacing operations returned by NextOperation
/// </summary> /// </summary>
public virtual void AddAnchorIndentationOperationsSlow(List<AnchorIndentationOperation> list, SyntaxNode node, AnalyzerConfigOptions options, ref NextAnchorIndentationOperationAction nextOperation) public virtual void AddAnchorIndentationOperationsSlow(List<AnchorIndentationOperation> list, SyntaxNode node, ref NextAnchorIndentationOperationAction nextOperation)
=> base.AddAnchorIndentationOperations(list, node, options, in nextOperation); => base.AddAnchorIndentationOperations(list, node, in nextOperation);
/// <summary> /// <summary>
/// returns IndentBlockOperations under a node either by itself or by filtering/replacing operations returned by NextOperation /// returns IndentBlockOperations under a node either by itself or by filtering/replacing operations returned by NextOperation
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
Imports System.Collections.Immutable Imports System.Collections.Immutable
Imports System.Threading Imports System.Threading
Imports Microsoft.CodeAnalysis.CodeGeneration Imports Microsoft.CodeAnalysis.CodeGeneration
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.DocumentationComments
Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.Formatting.Rules Imports Microsoft.CodeAnalysis.Formatting.Rules
...@@ -108,7 +107,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.MetadataAsSource ...@@ -108,7 +107,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.MetadataAsSource
Return FormattingOperations.CreateAdjustNewLinesOperation(GetNumberOfLines(triviaList) + 1, AdjustNewLinesOption.ForceLines) Return FormattingOperations.CreateAdjustNewLinesOperation(GetNumberOfLines(triviaList) + 1, AdjustNewLinesOption.ForceLines)
End Function End Function
Public Overrides Sub AddAnchorIndentationOperationsSlow(list As List(Of AnchorIndentationOperation), node As SyntaxNode, options As AnalyzerConfigOptions, ByRef nextOperation As NextAnchorIndentationOperationAction) Public Overrides Sub AddAnchorIndentationOperationsSlow(list As List(Of AnchorIndentationOperation), node As SyntaxNode, ByRef nextOperation As NextAnchorIndentationOperationAction)
Return Return
End Sub End Sub
......
...@@ -26,7 +26,7 @@ public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxN ...@@ -26,7 +26,7 @@ public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxN
{ {
} }
public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextAnchorIndentationOperationAction nextOperation) public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
{ {
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Formatting.Rules; using Microsoft.CodeAnalysis.Formatting.Rules;
namespace Microsoft.CodeAnalysis.CSharp.Formatting namespace Microsoft.CodeAnalysis.CSharp.Formatting
...@@ -15,7 +14,7 @@ internal class AnchorIndentationFormattingRule : BaseFormattingRule ...@@ -15,7 +14,7 @@ internal class AnchorIndentationFormattingRule : BaseFormattingRule
{ {
internal const string Name = "CSharp Anchor Indentation Formatting Rule"; internal const string Name = "CSharp Anchor Indentation Formatting Rule";
public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextAnchorIndentationOperationAction nextOperation) public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
{ {
nextOperation.Invoke(); nextOperation.Invoke();
......
...@@ -84,7 +84,7 @@ public override void AddIndentBlockOperations(List<IndentBlockOperation> list, S ...@@ -84,7 +84,7 @@ public override void AddIndentBlockOperations(List<IndentBlockOperation> list, S
} }
} }
public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextAnchorIndentationOperationAction nextOperation) public override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
{ {
nextOperation.Invoke(); nextOperation.Invoke();
switch (node) switch (node)
......
...@@ -54,7 +54,7 @@ public void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode curre ...@@ -54,7 +54,7 @@ public void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode curre
public void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode currentNode) public void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode currentNode)
{ {
var action = new NextAnchorIndentationOperationAction(_addAnchorIndentationOperationsRules, index: 0, currentNode, _options, list); var action = new NextAnchorIndentationOperationAction(_addAnchorIndentationOperationsRules, index: 0, currentNode, list);
action.Invoke(); action.Invoke();
} }
......
...@@ -28,7 +28,7 @@ public virtual void AddSuppressOperations(List<SuppressOperation> list, SyntaxNo ...@@ -28,7 +28,7 @@ public virtual void AddSuppressOperations(List<SuppressOperation> list, SyntaxNo
/// <summary> /// <summary>
/// returns AnchorIndentationOperations under a node either by itself or by filtering/replacing operations returned by NextOperation /// returns AnchorIndentationOperations under a node either by itself or by filtering/replacing operations returned by NextOperation
/// </summary> /// </summary>
public virtual void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextAnchorIndentationOperationAction nextOperation) public virtual void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
=> nextOperation.Invoke(); => nextOperation.Invoke();
/// <summary> /// <summary>
......
...@@ -24,10 +24,10 @@ public override sealed void AddSuppressOperations(List<SuppressOperation> list, ...@@ -24,10 +24,10 @@ public override sealed void AddSuppressOperations(List<SuppressOperation> list,
[Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)] [Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override sealed void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, AnalyzerConfigOptions options, in NextAnchorIndentationOperationAction nextOperation) public override sealed void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
{ {
var nextOperationCopy = nextOperation; var nextOperationCopy = nextOperation;
AddAnchorIndentationOperationsSlow(list, node, options, ref nextOperationCopy); AddAnchorIndentationOperationsSlow(list, node, ref nextOperationCopy);
} }
[Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)] [Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)]
...@@ -73,8 +73,8 @@ public virtual void AddSuppressOperationsSlow(List<SuppressOperation> list, Synt ...@@ -73,8 +73,8 @@ public virtual void AddSuppressOperationsSlow(List<SuppressOperation> list, Synt
/// <summary> /// <summary>
/// returns AnchorIndentationOperations under a node either by itself or by filtering/replacing operations returned by NextOperation /// returns AnchorIndentationOperations under a node either by itself or by filtering/replacing operations returned by NextOperation
/// </summary> /// </summary>
public virtual void AddAnchorIndentationOperationsSlow(List<AnchorIndentationOperation> list, SyntaxNode node, AnalyzerConfigOptions options, ref NextAnchorIndentationOperationAction nextOperation) public virtual void AddAnchorIndentationOperationsSlow(List<AnchorIndentationOperation> list, SyntaxNode node, ref NextAnchorIndentationOperationAction nextOperation)
=> base.AddAnchorIndentationOperations(list, node, options, in nextOperation); => base.AddAnchorIndentationOperations(list, node, in nextOperation);
/// <summary> /// <summary>
/// returns IndentBlockOperations under a node either by itself or by filtering/replacing operations returned by NextOperation /// returns IndentBlockOperations under a node either by itself or by filtering/replacing operations returned by NextOperation
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Diagnostics;
using Roslyn.Utilities; using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Formatting.Rules namespace Microsoft.CodeAnalysis.Formatting.Rules
...@@ -17,25 +16,22 @@ namespace Microsoft.CodeAnalysis.Formatting.Rules ...@@ -17,25 +16,22 @@ namespace Microsoft.CodeAnalysis.Formatting.Rules
private readonly ImmutableArray<AbstractFormattingRule> _formattingRules; private readonly ImmutableArray<AbstractFormattingRule> _formattingRules;
private readonly int _index; private readonly int _index;
private readonly SyntaxNode _node; private readonly SyntaxNode _node;
private readonly AnalyzerConfigOptions _options;
private readonly List<AnchorIndentationOperation> _list; private readonly List<AnchorIndentationOperation> _list;
public NextAnchorIndentationOperationAction( public NextAnchorIndentationOperationAction(
ImmutableArray<AbstractFormattingRule> formattingRules, ImmutableArray<AbstractFormattingRule> formattingRules,
int index, int index,
SyntaxNode node, SyntaxNode node,
AnalyzerConfigOptions options,
List<AnchorIndentationOperation> list) List<AnchorIndentationOperation> list)
{ {
_formattingRules = formattingRules; _formattingRules = formattingRules;
_index = index; _index = index;
_node = node; _node = node;
_options = options;
_list = list; _list = list;
} }
private NextAnchorIndentationOperationAction NextAction private NextAnchorIndentationOperationAction NextAction
=> new NextAnchorIndentationOperationAction(_formattingRules, _index + 1, _node, _options, _list); => new NextAnchorIndentationOperationAction(_formattingRules, _index + 1, _node, _list);
public void Invoke() public void Invoke()
{ {
...@@ -47,7 +43,7 @@ public void Invoke() ...@@ -47,7 +43,7 @@ public void Invoke()
else else
{ {
// Call the handler at the index, passing a continuation that will come back to here with index + 1 // Call the handler at the index, passing a continuation that will come back to here with index + 1
_formattingRules[_index].AddAnchorIndentationOperations(_list, _node, _options, NextAction); _formattingRules[_index].AddAnchorIndentationOperations(_list, _node, NextAction);
return; return;
} }
} }
......
...@@ -25,7 +25,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting ...@@ -25,7 +25,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public Overrides Sub AddSuppressOperationsSlow(operations As List(Of SuppressOperation), node As SyntaxNode, ByRef nextAction As NextSuppressOperationAction) Public Overrides Sub AddSuppressOperationsSlow(operations As List(Of SuppressOperation), node As SyntaxNode, ByRef nextAction As NextSuppressOperationAction)
End Sub End Sub
Public Overrides Sub AddAnchorIndentationOperationsSlow(operations As List(Of AnchorIndentationOperation), node As SyntaxNode, options As AnalyzerConfigOptions, ByRef nextAction As NextAnchorIndentationOperationAction) Public Overrides Sub AddAnchorIndentationOperationsSlow(operations As List(Of AnchorIndentationOperation), node As SyntaxNode, ByRef nextAction As NextAnchorIndentationOperationAction)
End Sub 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, options As AnalyzerConfigOptions, ByRef nextAction As NextIndentBlockOperationAction)
......
...@@ -15,7 +15,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting ...@@ -15,7 +15,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public Overrides Sub AddAnchorIndentationOperationsSlow(operations As List(Of AnchorIndentationOperation), Public Overrides Sub AddAnchorIndentationOperationsSlow(operations As List(Of AnchorIndentationOperation),
node As SyntaxNode, node As SyntaxNode,
options As AnalyzerConfigOptions,
ByRef nextOperation As NextAnchorIndentationOperationAction) ByRef nextOperation As NextAnchorIndentationOperationAction)
nextOperation.Invoke() nextOperation.Invoke()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册