提交 a3c59f82 编写于 作者: C CyrusNajmabadi

Remove usage of TypeSwitch.

上级 e9d765cc
......@@ -8,22 +8,6 @@ internal static partial class ObjectExtensions
{
#region TypeSwitch on Func<T>
public static TResult TypeSwitch<TBaseType, TDerivedType1, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TBaseType, TResult> defaultFunc = null) where TDerivedType1 : TBaseType
{
if (obj is TDerivedType1)
{
return matchFunc1((TDerivedType1)obj);
}
else if (defaultFunc != null)
{
return defaultFunc(obj);
}
else
{
return default(TResult);
}
}
public static TResult TypeSwitch<TBaseType, TDerivedType1, TDerivedType2, TResult>(this TBaseType obj, Func<TDerivedType1, TResult> matchFunc1, Func<TDerivedType2, TResult> matchFunc2, Func<TBaseType, TResult> defaultFunc = null)
where TDerivedType1 : TBaseType
where TDerivedType2 : TBaseType
......
......@@ -521,9 +521,14 @@ Namespace Microsoft.CodeAnalysis.CodeCleanup.Providers
Private Function ProcessOmittedToken(originalToken As SyntaxToken, token As SyntaxToken, parent As SyntaxNode) As SyntaxToken
' multiline if statement with missing then keyword case
If parent.TypeSwitch(Function(p As IfStatementSyntax) Exist(p.Condition) AndAlso p.ThenKeyword = originalToken) Then
Return If(parent.GetAncestor(Of MultiLineIfBlockSyntax)() IsNot Nothing, CreateOmittedToken(token, SyntaxKind.ThenKeyword), token)
ElseIf TryCast(parent, IfDirectiveTriviaSyntax)?.ThenKeyword = originalToken Then
If TypeOf parent Is IfStatementSyntax Then
Dim ifStatement = DirectCast(parent, IfStatementSyntax)
If Exist(ifStatement.Condition) AndAlso ifStatement.ThenKeyword = originalToken Then
Return If(parent.GetAncestor(Of MultiLineIfBlockSyntax)() IsNot Nothing, CreateOmittedToken(token, SyntaxKind.ThenKeyword), token)
End If
End If
If TryCast(parent, IfDirectiveTriviaSyntax)?.ThenKeyword = originalToken Then
Return CreateOmittedToken(token, SyntaxKind.ThenKeyword)
ElseIf TryCast(parent, ElseIfStatementSyntax)?.ThenKeyword = originalToken Then
Return If(parent.GetAncestor(Of ElseIfBlockSyntax)() IsNot Nothing, CreateOmittedToken(token, SyntaxKind.ThenKeyword), token)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册