public async Task ComputeRefactoringsForNodeAsync() { SyntaxNode node = Root.FindNode(Span, findInsideTrivia: false, getInnermostNodeForTie: true); if (node == null) { return; } bool fAccessor = false; bool fArgument = false; bool fArgumentList = false; bool fAttributeArgumentList = false; bool fArrowExpressionClause = false; bool fParameter = false; bool fParameterList = false; bool fSwitchSection = false; bool fVariableDeclaration = false; bool fVariableDeclarator = false; bool fInterpolatedStringText = false; bool fElseClause = false; bool fCaseSwitchLabel = false; bool fUsingDirective = false; bool fDeclarationPattern = false; bool fTypeParameterConstraintClause = false; bool fExpression = false; bool fAnonymousMethod = false; bool fAssignmentExpression = false; bool fBinaryExpression = false; bool fConditionalExpression = false; bool fQualifiedName = false; bool fGenericName = false; bool fIdentifierName = false; bool fInitializerExpression = false; bool fInterpolatedStringExpression = false; bool fInterpolation = false; bool fInvocationExpression = false; bool fLambdaExpression = false; bool fLiteralExpression = false; bool fSimpleMemberAccessExpression = false; bool fParenthesizedExpression = false; bool fPostfixUnaryExpression = false; bool fPrefixUnaryExpression = false; bool fAwaitExpression = false; bool fCastExpression = false; bool fThrowExpression = false; bool fDeclarationExpression = false; bool fIsPatternExpression = false; bool fMemberDeclaration = false; bool fStatement = false; bool fDoStatement = false; bool fExpressionStatement = false; bool fForEachStatement = false; bool fForStatement = false; bool fIfStatement = false; bool fLocalDeclarationStatement = false; bool fReturnStatement = false; bool fSwitchStatement = false; bool fUsingStatement = false; bool fWhileStatement = false; bool fYieldReturnStatement = false; bool fLockStatement = false; bool fBlock = false; bool fStatementRefactoring = false; bool fThrowStatement = false; bool fLocalFunctionStatement = false; SyntaxNode firstNode = node; using (IEnumerator <SyntaxNode> en = node.AncestorsAndSelf().GetEnumerator()) { while (en.MoveNext()) { node = en.Current; SyntaxKind kind = node.Kind(); Debug.WriteLine(kind.ToString()); if (!fAccessor && (node is AccessorDeclarationSyntax accessor)) { AccessorDeclarationRefactoring.ComputeRefactorings(this, accessor); fAccessor = true; continue; } if (!fArgument && kind == SyntaxKind.Argument) { await ArgumentRefactoring.ComputeRefactoringsAsync(this, (ArgumentSyntax)node).ConfigureAwait(false); fArgument = true; continue; } if (!fArgumentList && kind == SyntaxKind.ArgumentList) { await ArgumentListRefactoring.ComputeRefactoringsAsync(this, (ArgumentListSyntax)node).ConfigureAwait(false); fArgumentList = true; continue; } if (!fAttributeArgumentList && kind == SyntaxKind.AttributeArgumentList) { await AttributeArgumentListRefactoring.ComputeRefactoringsAsync(this, (AttributeArgumentListSyntax)node).ConfigureAwait(false); fAttributeArgumentList = true; continue; } if (!fArrowExpressionClause && kind == SyntaxKind.ArrowExpressionClause) { await ArrowExpressionClauseRefactoring.ComputeRefactoringsAsync(this, (ArrowExpressionClauseSyntax)node).ConfigureAwait(false); fArrowExpressionClause = true; continue; } if (!fParameter && kind == SyntaxKind.Parameter) { await ParameterRefactoring.ComputeRefactoringsAsync(this, (ParameterSyntax)node).ConfigureAwait(false); fParameter = true; continue; } if (!fParameterList && kind == SyntaxKind.ParameterList) { await ParameterListRefactoring.ComputeRefactoringsAsync(this, (ParameterListSyntax)node).ConfigureAwait(false); fParameterList = true; continue; } if (!fSwitchSection && kind == SyntaxKind.SwitchSection) { await SwitchSectionRefactoring.ComputeRefactoringsAsync(this, (SwitchSectionSyntax)node).ConfigureAwait(false); fSwitchSection = true; continue; } if (!fVariableDeclaration && kind == SyntaxKind.VariableDeclaration) { await VariableDeclarationRefactoring.ComputeRefactoringsAsync(this, (VariableDeclarationSyntax)node).ConfigureAwait(false); fVariableDeclaration = true; continue; } if (!fVariableDeclarator && kind == SyntaxKind.VariableDeclarator) { VariableDeclaratorRefactoring.ComputeRefactorings(this, (VariableDeclaratorSyntax)node); fVariableDeclarator = true; continue; } if (!fInterpolatedStringText && kind == SyntaxKind.InterpolatedStringText) { await InterpolatedStringTextRefactoring.ComputeRefactoringsAsync(this, (InterpolatedStringTextSyntax)node).ConfigureAwait(false); fInterpolatedStringText = true; continue; } if (!fInterpolation && kind == SyntaxKind.Interpolation) { InterpolationRefactoring.ComputeRefactorings(this, (InterpolationSyntax)node); fInterpolation = true; continue; } if (!fElseClause && kind == SyntaxKind.ElseClause) { ElseClauseRefactoring.ComputeRefactorings(this, (ElseClauseSyntax)node); fElseClause = true; continue; } if (!fCaseSwitchLabel && kind == SyntaxKind.CaseSwitchLabel) { await CaseSwitchLabelRefactoring.ComputeRefactoringsAsync(this, (CaseSwitchLabelSyntax)node).ConfigureAwait(false); fCaseSwitchLabel = true; continue; } if (!fUsingDirective && kind == SyntaxKind.UsingDirective) { UsingDirectiveRefactoring.ComputeRefactoring(this, (UsingDirectiveSyntax)node); fUsingDirective = true; continue; } if (!fDeclarationPattern && kind == SyntaxKind.DeclarationPattern) { await DeclarationPatternRefactoring.ComputeRefactoringAsync(this, (DeclarationPatternSyntax)node).ConfigureAwait(false); fDeclarationPattern = true; continue; } if (!fTypeParameterConstraintClause && kind == SyntaxKind.TypeParameterConstraintClause) { TypeParameterConstraintClauseRefactoring.ComputeRefactoring(this, (TypeParameterConstraintClauseSyntax)node); fTypeParameterConstraintClause = true; continue; } if (node is ExpressionSyntax expression) { if (!fExpression) { await ExpressionRefactoring.ComputeRefactoringsAsync(this, expression).ConfigureAwait(false); fExpression = true; } if (!fAssignmentExpression && (node is AssignmentExpressionSyntax assignmentExpression)) { await AssignmentExpressionRefactoring.ComputeRefactoringsAsync(this, assignmentExpression).ConfigureAwait(false); fAssignmentExpression = true; } if (!fAnonymousMethod && kind == SyntaxKind.AnonymousMethodExpression) { AnonymousMethodExpressionRefactoring.ComputeRefactorings(this, (AnonymousMethodExpressionSyntax)node); fAnonymousMethod = true; } if (!fBinaryExpression && (node is BinaryExpressionSyntax binaryExpression)) { await BinaryExpressionRefactoring.ComputeRefactoringsAsync(this, binaryExpression).ConfigureAwait(false); fBinaryExpression = true; } if (!fConditionalExpression && kind == SyntaxKind.ConditionalExpression) { await ConditionalExpressionRefactoring.ComputeRefactoringsAsync(this, (ConditionalExpressionSyntax)expression).ConfigureAwait(false); fConditionalExpression = true; } if (!fQualifiedName && kind == SyntaxKind.QualifiedName) { await QualifiedNameRefactoring.ComputeRefactoringsAsync(this, (QualifiedNameSyntax)expression).ConfigureAwait(false); fQualifiedName = true; } if (!fGenericName && kind == SyntaxKind.GenericName) { GenericNameRefactoring.ComputeRefactorings(this, (GenericNameSyntax)expression); fGenericName = true; } if (!fIdentifierName && kind == SyntaxKind.IdentifierName) { await IdentifierNameRefactoring.ComputeRefactoringsAsync(this, (IdentifierNameSyntax)expression).ConfigureAwait(false); fIdentifierName = true; } if (!fInitializerExpression && (node is InitializerExpressionSyntax initializer)) { await InitializerExpressionRefactoring.ComputeRefactoringsAsync(this, initializer).ConfigureAwait(false); fInitializerExpression = true; } if (!fInterpolatedStringExpression && kind == SyntaxKind.InterpolatedStringExpression) { InterpolatedStringRefactoring.ComputeRefactorings(this, (InterpolatedStringExpressionSyntax)expression); fInterpolatedStringExpression = true; } if (!fInvocationExpression && kind == SyntaxKind.InvocationExpression) { await InvocationExpressionRefactoring.ComputeRefactoringsAsync(this, (InvocationExpressionSyntax)expression).ConfigureAwait(false); fInvocationExpression = true; } if (!fLambdaExpression && (node is LambdaExpressionSyntax lambdaExpression)) { LambdaExpressionRefactoring.ComputeRefactorings(this, lambdaExpression); fLambdaExpression = true; } if (!fLiteralExpression && (node is LiteralExpressionSyntax literalExpression)) { await LiteralExpressionRefactoring.ComputeRefactoringsAsync(this, literalExpression).ConfigureAwait(false); fLiteralExpression = true; } if (!fSimpleMemberAccessExpression && kind == SyntaxKind.SimpleMemberAccessExpression) { await SimpleMemberAccessExpressionRefactoring.ComputeRefactoringAsync(this, (MemberAccessExpressionSyntax)node).ConfigureAwait(false); fSimpleMemberAccessExpression = true; } if (!fParenthesizedExpression && kind == SyntaxKind.ParenthesizedExpression) { ParenthesizedExpressionRefactoring.ComputeRefactorings(this, (ParenthesizedExpressionSyntax)expression); fParenthesizedExpression = true; } if (!fPostfixUnaryExpression && (node is PostfixUnaryExpressionSyntax postfixUnaryExpression)) { PostfixUnaryExpressionRefactoring.ComputeRefactorings(this, postfixUnaryExpression); fPostfixUnaryExpression = true; } if (!fPrefixUnaryExpression && (node is PrefixUnaryExpressionSyntax prefixUnaryExpression)) { PrefixUnaryExpressionRefactoring.ComputeRefactorings(this, prefixUnaryExpression); fPrefixUnaryExpression = true; } if (!fAwaitExpression && kind == SyntaxKind.AwaitExpression) { await AwaitExpressionRefactoring.ComputeRefactoringsAsync(this, (AwaitExpressionSyntax)node).ConfigureAwait(false); fAwaitExpression = true; } if (!fCastExpression && kind == SyntaxKind.CastExpression) { CastExpressionRefactoring.ComputeRefactorings(this, (CastExpressionSyntax)node); fCastExpression = true; } if (!fThrowExpression && kind == SyntaxKind.ThrowExpression) { await ThrowExpressionRefactoring.ComputeRefactoringsAsync(this, (ThrowExpressionSyntax)node).ConfigureAwait(false); fThrowExpression = true; } if (!fDeclarationExpression && kind == SyntaxKind.DeclarationExpression) { await DeclarationExpressionRefactoring.ComputeRefactoringsAsync(this, (DeclarationExpressionSyntax)node).ConfigureAwait(false); fDeclarationExpression = true; } if (!fIsPatternExpression && kind == SyntaxKind.IsPatternExpression) { NegateIsExpressionRefactoring.ComputeRefactoring(this, (IsPatternExpressionSyntax)node); fIsPatternExpression = true; } continue; } if (node is MemberDeclarationSyntax memberDeclaration) { if (!fMemberDeclaration) { await MemberDeclarationRefactoring.ComputeRefactoringsAsync(this, memberDeclaration).ConfigureAwait(false); AttributeListRefactoring.ComputeRefactorings(this, memberDeclaration); await IntroduceConstructorRefactoring.ComputeRefactoringsAsync(this, memberDeclaration).ConfigureAwait(false); fMemberDeclaration = true; } continue; } if (node is StatementSyntax statement) { if (!fDoStatement && kind == SyntaxKind.DoStatement) { DoStatementRefactoring.ComputeRefactorings(this, (DoStatementSyntax)statement); fDoStatement = true; } if (!fExpressionStatement && kind == SyntaxKind.ExpressionStatement) { await ExpressionStatementRefactoring.ComputeRefactoringsAsync(this, (ExpressionStatementSyntax)statement).ConfigureAwait(false); fExpressionStatement = true; } if (!fForEachStatement && kind == SyntaxKind.ForEachStatement) { await ForEachStatementRefactoring.ComputeRefactoringsAsync(this, (ForEachStatementSyntax)statement).ConfigureAwait(false); fForEachStatement = true; } if (!fForStatement && kind == SyntaxKind.ForStatement) { await ForStatementRefactoring.ComputeRefactoringsAsync(this, (ForStatementSyntax)statement).ConfigureAwait(false); fForStatement = true; } if (!fIfStatement && kind == SyntaxKind.IfStatement) { await IfStatementRefactoring.ComputeRefactoringsAsync(this, (IfStatementSyntax)statement).ConfigureAwait(false); fIfStatement = true; } if (!fLocalDeclarationStatement && kind == SyntaxKind.LocalDeclarationStatement) { await LocalDeclarationStatementRefactoring.ComputeRefactoringsAsync(this, (LocalDeclarationStatementSyntax)statement).ConfigureAwait(false); fLocalDeclarationStatement = true; } if (!fReturnStatement && kind == SyntaxKind.ReturnStatement) { await ReturnStatementRefactoring.ComputeRefactoringsAsync(this, (ReturnStatementSyntax)statement).ConfigureAwait(false); fReturnStatement = true; } if (!fSwitchStatement && kind == SyntaxKind.SwitchStatement) { await SwitchStatementRefactoring.ComputeRefactoringsAsync(this, (SwitchStatementSyntax)statement).ConfigureAwait(false); fSwitchStatement = true; } if (!fUsingStatement && kind == SyntaxKind.UsingStatement) { UsingStatementRefactoring.ComputeRefactorings(this, (UsingStatementSyntax)statement); fUsingStatement = true; } if (!fWhileStatement && kind == SyntaxKind.WhileStatement) { WhileStatementRefactoring.ComputeRefactorings(this, (WhileStatementSyntax)statement); fWhileStatement = true; } if (!fYieldReturnStatement && (node is YieldStatementSyntax yieldStatement)) { await YieldStatementRefactoring.ComputeRefactoringsAsync(this, yieldStatement).ConfigureAwait(false); fYieldReturnStatement = true; } if (!fLockStatement && kind == SyntaxKind.LockStatement) { LockStatementRefactoring.ComputeRefactorings(this, (LockStatementSyntax)node); fLockStatement = true; } if (!fBlock && kind == SyntaxKind.Block) { await BlockRefactoring.ComputeRefactoringAsync(this, (BlockSyntax)node).ConfigureAwait(false); fBlock = true; } if (!fThrowStatement && kind == SyntaxKind.ThrowStatement) { await ThrowStatementRefactoring.ComputeRefactoringAsync(this, (ThrowStatementSyntax)node).ConfigureAwait(false); fThrowStatement = true; } if (!fLocalFunctionStatement && kind == SyntaxKind.LocalFunctionStatement) { await LocalFunctionStatementRefactoring.ComputeRefactoringsAsync(this, (LocalFunctionStatementSyntax)node).ConfigureAwait(false); fLocalFunctionStatement = true; } if (!fStatement) { AddBracesRefactoring.ComputeRefactoring(this, statement); RemoveBracesRefactoring.ComputeRefactoring(this, statement); ExtractStatementRefactoring.ComputeRefactoring(this, statement); EmbeddedStatementRefactoring.ComputeRefactoring(this, statement); fStatement = true; } if (!fStatementRefactoring) { if (kind == SyntaxKind.Block) { StatementRefactoring.ComputeRefactoring(this, (BlockSyntax)node); fStatementRefactoring = true; } else if (kind == SyntaxKind.SwitchStatement) { StatementRefactoring.ComputeRefactoring(this, (SwitchStatementSyntax)node); fStatementRefactoring = true; } } continue; } } } await SyntaxNodeRefactoring.ComputeRefactoringsAsync(this, firstNode).ConfigureAwait(false); CommentTriviaRefactoring.ComputeRefactorings(this, firstNode); }
public static async Task ComputeRefactoringsForNodeAsync(this RefactoringContext context) { SyntaxNode node = context.FindNode(); if (node == null) { return; } bool fAccessor = false; bool fArgument = false; bool fArgumentList = false; bool fAttributeArgumentList = false; bool fArrowExpressionClause = false; bool fParameter = false; bool fParameterList = false; bool fSwitchSection = false; bool fVariableDeclaration = false; bool fInterpolatedStringText = false; bool fElseClause = false; bool fCaseSwitchLabel = false; bool fUsingDirective = false; bool fExpression = false; bool fAnonymousMethod = false; bool fAssignmentExpression = false; bool fBinaryExpression = false; bool fConditionalExpression = false; bool fQualifiedName = false; bool fGenericName = false; bool fIdentifierName = false; bool fInitializerExpression = false; bool fInterpolatedStringExpression = false; bool fInterpolation = false; bool fInvocationExpression = false; bool fLambdaExpression = false; bool fLiteralExpression = false; bool fSimpleMemberAccessExpression = false; bool fParenthesizedExpression = false; bool fPostfixUnaryExpression = false; bool fPrefixUnaryExpression = false; bool fAwaitExpression = false; bool fMemberDeclaration = false; bool fStatement = false; bool fDoStatement = false; bool fExpressionStatement = false; bool fForEachStatement = false; bool fForStatement = false; bool fIfStatement = false; bool fLocalDeclarationStatement = false; bool fReturnStatement = false; bool fSwitchStatement = false; bool fUsingStatement = false; bool fWhileStatement = false; bool fYieldReturnStatement = false; bool fBlock = false; bool fStatementRefactoring = false; SyntaxNode firstNode = node; using (IEnumerator <SyntaxNode> en = node.AncestorsAndSelf().GetEnumerator()) { while (en.MoveNext()) { node = en.Current; SyntaxKind kind = node.Kind(); Debug.WriteLine(kind.ToString()); if (!fAccessor) { var accessor = node as AccessorDeclarationSyntax; if (accessor != null) { AccessorDeclarationRefactoring.ComputeRefactorings(context, accessor); fAccessor = true; continue; } } if (!fArgument && kind == SyntaxKind.Argument) { await ArgumentRefactoring.ComputeRefactoringsAsync(context, (ArgumentSyntax)node).ConfigureAwait(false); fArgument = true; continue; } if (!fArgumentList && kind == SyntaxKind.ArgumentList) { await ArgumentListRefactoring.ComputeRefactoringsAsync(context, (ArgumentListSyntax)node).ConfigureAwait(false); fArgumentList = true; continue; } if (!fAttributeArgumentList && kind == SyntaxKind.AttributeArgumentList) { await AttributeArgumentListRefactoring.ComputeRefactoringsAsync(context, (AttributeArgumentListSyntax)node).ConfigureAwait(false); fAttributeArgumentList = true; continue; } if (!fArrowExpressionClause && kind == SyntaxKind.ArrowExpressionClause) { await ArrowExpressionClauseRefactoring.ComputeRefactoringsAsync(context, (ArrowExpressionClauseSyntax)node).ConfigureAwait(false); fArrowExpressionClause = true; continue; } if (!fParameter && kind == SyntaxKind.Parameter) { await ParameterRefactoring.ComputeRefactoringsAsync(context, (ParameterSyntax)node).ConfigureAwait(false); fParameter = true; continue; } if (!fParameterList && kind == SyntaxKind.ParameterList) { await ParameterListRefactoring.ComputeRefactoringsAsync(context, (ParameterListSyntax)node).ConfigureAwait(false); fParameterList = true; continue; } if (!fSwitchSection && kind == SyntaxKind.SwitchSection) { await SwitchSectionRefactoring.ComputeRefactoringsAsync(context, (SwitchSectionSyntax)node).ConfigureAwait(false); fSwitchSection = true; continue; } if (!fVariableDeclaration && kind == SyntaxKind.VariableDeclaration) { await VariableDeclarationRefactoring.ComputeRefactoringsAsync(context, (VariableDeclarationSyntax)node).ConfigureAwait(false); fVariableDeclaration = true; continue; } if (!fInterpolatedStringText && kind == SyntaxKind.InterpolatedStringText) { InterpolatedStringTextRefactoring.ComputeRefactorings(context, (InterpolatedStringTextSyntax)node); fInterpolatedStringText = true; continue; } if (!fInterpolation && kind == SyntaxKind.Interpolation) { InterpolationRefactoring.ComputeRefactorings(context, (InterpolationSyntax)node); fInterpolation = true; continue; } if (!fElseClause && kind == SyntaxKind.ElseClause) { ElseClauseRefactoring.ComputeRefactorings(context, (ElseClauseSyntax)node); fElseClause = true; continue; } if (!fCaseSwitchLabel && kind == SyntaxKind.CaseSwitchLabel) { await CaseSwitchLabelRefactoring.ComputeRefactoringsAsync(context, (CaseSwitchLabelSyntax)node).ConfigureAwait(false); fCaseSwitchLabel = true; continue; } if (!fUsingDirective && kind == SyntaxKind.UsingDirective) { UsingDirectiveRefactoring.ComputeRefactoring(context, (UsingDirectiveSyntax)node); fUsingDirective = true; continue; } var expression = node as ExpressionSyntax; if (expression != null) { if (!fExpression) { ExpressionRefactoring.ComputeRefactorings(context, expression); fExpression = true; } if (!fAssignmentExpression) { var assignmentExpression = node as AssignmentExpressionSyntax; if (assignmentExpression != null) { await AssignmentExpressionRefactoring.ComputeRefactoringsAsync(context, assignmentExpression).ConfigureAwait(false); fAssignmentExpression = true; } } if (!fAnonymousMethod && kind == SyntaxKind.AnonymousMethodExpression) { AnonymousMethodExpressionRefactoring.ComputeRefactorings(context, (AnonymousMethodExpressionSyntax)node); fAnonymousMethod = true; } if (!fBinaryExpression) { var binaryExpression = node as BinaryExpressionSyntax; if (binaryExpression != null) { await BinaryExpressionRefactoring.ComputeRefactoringsAsync(context, binaryExpression).ConfigureAwait(false); fBinaryExpression = true; } } if (!fConditionalExpression && kind == SyntaxKind.ConditionalExpression) { ConditionalExpressionRefactoring.ComputeRefactorings(context, (ConditionalExpressionSyntax)expression); fConditionalExpression = true; } if (!fQualifiedName && kind == SyntaxKind.QualifiedName) { await QualifiedNameRefactoring.ComputeRefactoringsAsync(context, (QualifiedNameSyntax)expression).ConfigureAwait(false); fQualifiedName = true; } if (!fGenericName && kind == SyntaxKind.GenericName) { GenericNameRefactoring.ComputeRefactorings(context, (GenericNameSyntax)expression); fGenericName = true; } if (!fIdentifierName && kind == SyntaxKind.IdentifierName) { await IdentifierNameRefactoring.ComputeRefactoringsAsync(context, (IdentifierNameSyntax)expression).ConfigureAwait(false); fIdentifierName = true; } if (!fInitializerExpression) { var initializer = node as InitializerExpressionSyntax; if (initializer != null) { await InitializerExpressionRefactoring.ComputeRefactoringsAsync(context, initializer).ConfigureAwait(false); fInitializerExpression = true; } } if (!fInterpolatedStringExpression && kind == SyntaxKind.InterpolatedStringExpression) { InterpolatedStringRefactoring.ComputeRefactorings(context, (InterpolatedStringExpressionSyntax)expression); fInterpolatedStringExpression = true; } if (!fInvocationExpression && kind == SyntaxKind.InvocationExpression) { await InvocationExpressionRefactoring.ComputeRefactoringsAsync(context, (InvocationExpressionSyntax)expression).ConfigureAwait(false); fInvocationExpression = true; } if (!fLambdaExpression) { var lambdaExpression = node as LambdaExpressionSyntax; if (lambdaExpression != null) { LambdaExpressionRefactoring.ComputeRefactorings(context, lambdaExpression); fLambdaExpression = true; } } if (!fLiteralExpression) { var literalExpression = node as LiteralExpressionSyntax; if (literalExpression != null) { LiteralExpressionRefactoring.ComputeRefactorings(context, literalExpression); fLiteralExpression = true; } } if (!fSimpleMemberAccessExpression && kind == SyntaxKind.SimpleMemberAccessExpression) { await SimpleMemberAccessExpressionRefactoring.ComputeRefactoringAsync(context, (MemberAccessExpressionSyntax)node).ConfigureAwait(false); fSimpleMemberAccessExpression = true; } if (!fParenthesizedExpression && kind == SyntaxKind.ParenthesizedExpression) { ParenthesizedExpressionRefactoring.ComputeRefactorings(context, (ParenthesizedExpressionSyntax)expression); fParenthesizedExpression = true; } if (!fPostfixUnaryExpression) { var postfixUnaryExpression = node as PostfixUnaryExpressionSyntax; if (postfixUnaryExpression != null) { PostfixUnaryExpressionRefactoring.ComputeRefactorings(context, postfixUnaryExpression); fPostfixUnaryExpression = true; } } if (!fPrefixUnaryExpression) { var prefixUnaryExpression = node as PrefixUnaryExpressionSyntax; if (prefixUnaryExpression != null) { PrefixUnaryExpressionRefactoring.ComputeRefactorings(context, prefixUnaryExpression); fPrefixUnaryExpression = true; } } if (!fAwaitExpression && kind == SyntaxKind.AwaitExpression) { await AwaitExpressionRefactoring.ComputeRefactoringsAsync(context, (AwaitExpressionSyntax)node).ConfigureAwait(false); fAwaitExpression = true; } continue; } var memberDeclaration = node as MemberDeclarationSyntax; if (memberDeclaration != null) { if (!fMemberDeclaration) { await MemberDeclarationRefactoring.ComputeRefactoringsAsync(context, memberDeclaration).ConfigureAwait(false); AttributeListRefactoring.ComputeRefactorings(context, memberDeclaration); await IntroduceConstructorRefactoring.ComputeRefactoringsAsync(context, memberDeclaration).ConfigureAwait(false); fMemberDeclaration = true; } continue; } var statement = node as StatementSyntax; if (statement != null) { if (!fDoStatement && kind == SyntaxKind.DoStatement) { await DoStatementRefactoring.ComputeRefactoringsAsync(context, (DoStatementSyntax)statement).ConfigureAwait(false); fDoStatement = true; } if (!fExpressionStatement && kind == SyntaxKind.ExpressionStatement) { await ExpressionStatementRefactoring.ComputeRefactoringsAsync(context, (ExpressionStatementSyntax)statement).ConfigureAwait(false); fExpressionStatement = true; } if (!fForEachStatement && kind == SyntaxKind.ForEachStatement) { await ForEachStatementRefactoring.ComputeRefactoringsAsync(context, (ForEachStatementSyntax)statement).ConfigureAwait(false); fForEachStatement = true; } if (!fForStatement && kind == SyntaxKind.ForStatement) { await ForStatementRefactoring.ComputeRefactoringsAsync(context, (ForStatementSyntax)statement).ConfigureAwait(false); fForStatement = true; } if (!fIfStatement && kind == SyntaxKind.IfStatement) { await IfStatementRefactoring.ComputeRefactoringsAsync(context, (IfStatementSyntax)statement).ConfigureAwait(false); fIfStatement = true; } if (!fLocalDeclarationStatement && kind == SyntaxKind.LocalDeclarationStatement) { await LocalDeclarationStatementRefactoring.ComputeRefactoringsAsync(context, (LocalDeclarationStatementSyntax)statement).ConfigureAwait(false); fLocalDeclarationStatement = true; } if (!fReturnStatement && kind == SyntaxKind.ReturnStatement) { await ReturnStatementRefactoring.ComputeRefactoringsAsync(context, (ReturnStatementSyntax)statement).ConfigureAwait(false); fReturnStatement = true; } if (!fSwitchStatement && kind == SyntaxKind.SwitchStatement) { await SwitchStatementRefactoring.ComputeRefactoringsAsync(context, (SwitchStatementSyntax)statement).ConfigureAwait(false); fSwitchStatement = true; } if (!fUsingStatement && kind == SyntaxKind.UsingStatement) { UsingStatementRefactoring.ComputeRefactorings(context, (UsingStatementSyntax)statement); fUsingStatement = true; } if (!fWhileStatement && kind == SyntaxKind.WhileStatement) { await WhileStatementRefactoring.ComputeRefactoringsAsync(context, (WhileStatementSyntax)statement).ConfigureAwait(false); fWhileStatement = true; } if (!fYieldReturnStatement) { var yieldStatement = node as YieldStatementSyntax; if (yieldStatement != null) { await YieldReturnStatementRefactoring.ComputeRefactoringsAsync(context, yieldStatement).ConfigureAwait(false); fYieldReturnStatement = true; } } if (!fBlock && kind == SyntaxKind.Block) { await BlockRefactoring.ComputeRefactoringAsync(context, (BlockSyntax)node).ConfigureAwait(false); fBlock = true; } if (!fStatement) { AddBracesRefactoring.ComputeRefactoring(context, statement); RemoveBracesRefactoring.ComputeRefactoring(context, statement); ExtractStatementRefactoring.ComputeRefactoring(context, statement); fStatement = true; } if (!fStatementRefactoring) { if (kind == SyntaxKind.Block) { StatementRefactoring.ComputeRefactoring(context, (BlockSyntax)node); fStatementRefactoring = true; } else if (kind == SyntaxKind.SwitchStatement) { StatementRefactoring.ComputeRefactoring(context, (SwitchStatementSyntax)node); fStatementRefactoring = true; } } continue; } } } await SyntaxNodeRefactoring.ComputeRefactoringsAsync(context, firstNode).ConfigureAwait(false); CommentTriviaRefactoring.ComputeRefactorings(context, firstNode); }