提交 fae2e094 编写于 作者: A Alireza Habibi

Rename methods

Rename IsEquivalentToSwitchExpression -> SetInitialOrIsEquivalentToSwitchExpression
Rename PatternSwitchSection -> SwitchSectionFromLabels
上级 4443cfcc
......@@ -43,7 +43,7 @@ protected override IPattern CreatePatternFromExpression(ExpressionSyntax operand
return null;
}
if (!IsEquivalentToSwitchExpression(expression))
if (!SetInitialOrIsEquivalentToSwitchExpression(expression))
{
return null;
}
......@@ -56,7 +56,7 @@ protected override IPattern CreatePatternFromExpression(ExpressionSyntax operand
// Look for the form "x is T" where "x" is equivalent to the switch expression.
// This will turn into a discarded type pattern e.g. "case T _:".
var node = (BinaryExpressionSyntax)operand;
if (!IsEquivalentToSwitchExpression(node.Left))
if (!SetInitialOrIsEquivalentToSwitchExpression(node.Left))
{
return null;
}
......@@ -69,7 +69,7 @@ protected override IPattern CreatePatternFromExpression(ExpressionSyntax operand
// Look for the form "x is T t" where "x" is equivalent to the switch expression.
// This will turn into a type pattern e.g. "case T t:".
var node = (IsPatternExpressionSyntax)operand;
if (!IsEquivalentToSwitchExpression(node.Expression))
if (!SetInitialOrIsEquivalentToSwitchExpression(node.Expression))
{
return null;
}
......
......@@ -116,7 +116,7 @@ public async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
UpdateDocumentAsync(root, document, ifStatement, switchDefaultBody, switchSections)));
}
protected bool IsEquivalentToSwitchExpression(TExpressionSyntax expression)
protected bool SetInitialOrIsEquivalentToSwitchExpression(TExpressionSyntax expression)
{
// If we have not figured the switch expression yet,
// we will assume that the first expression is the one.
......@@ -169,7 +169,7 @@ private bool IsConstant(TExpressionSyntax node)
{
var generator = SyntaxGenerator.GetGenerator(document);
var sectionList =
sections.Select(s => generator.PatternSwitchSection(
sections.Select(s => generator.SwitchSectionFromLabels(
labels: s.patterns.Select(p => p.CreateSwitchLabel()),
statements: GetSwitchSectionBody(s.statement))).ToList();
......
......@@ -53,7 +53,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.ConvertIfToSwitch
Return Nothing
End If
If Not IsEquivalentToSwitchExpression(expression) Then
If Not SetInitialOrIsEquivalentToSwitchExpression(expression) Then
Return Nothing
End If
......@@ -102,7 +102,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.ConvertIfToSwitch
Return Nothing
End If
If Not IsEquivalentToSwitchExpression(leftExpression) Then
If Not SetInitialOrIsEquivalentToSwitchExpression(leftExpression) Then
Return Nothing
End If
......
......@@ -4037,7 +4037,7 @@ public override SyntaxNode SwitchSection(IEnumerable<SyntaxNode> expressions, IE
return SyntaxFactory.SwitchSection(AsSwitchLabels(expressions), AsStatementList(statements));
}
internal override SyntaxNode PatternSwitchSection(IEnumerable<SyntaxNode> labels, IEnumerable<SyntaxNode> statements)
internal override SyntaxNode SwitchSectionFromLabels(IEnumerable<SyntaxNode> labels, IEnumerable<SyntaxNode> statements)
{
return SyntaxFactory.SwitchSection(
labels.Cast<SwitchLabelSyntax>().ToSyntaxList(),
......
......@@ -1379,7 +1379,7 @@ public SyntaxNode SwitchStatement(SyntaxNode expression, params SyntaxNode[] sec
/// </summary>
public abstract SyntaxNode SwitchSection(IEnumerable<SyntaxNode> caseExpressions, IEnumerable<SyntaxNode> statements);
internal abstract SyntaxNode PatternSwitchSection(IEnumerable<SyntaxNode> labels, IEnumerable<SyntaxNode> statements);
internal abstract SyntaxNode SwitchSectionFromLabels(IEnumerable<SyntaxNode> labels, IEnumerable<SyntaxNode> statements);
/// <summary>
/// Creates a single-case section a switch statement.
......
......@@ -431,7 +431,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
GetStatementList(statements))
End Function
Friend Overrides Function PatternSwitchSection(labels As IEnumerable(Of SyntaxNode), statements As IEnumerable(Of SyntaxNode)) As SyntaxNode
Friend Overrides Function SwitchSectionFromLabels(labels As IEnumerable(Of SyntaxNode), statements As IEnumerable(Of SyntaxNode)) As SyntaxNode
Return SyntaxFactory.CaseBlock(
SyntaxFactory.CaseStatement(SyntaxFactory.SeparatedList(labels.Cast(Of CaseClauseSyntax))),
GetStatementList(statements))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册