Ejemplo n.º 1
0
        public static void ComputeRefactorings(RefactoringContext context, LiteralExpressionSyntax literalExpression)
        {
            switch (literalExpression.Kind())
            {
            case SyntaxKind.TrueLiteralExpression:
            case SyntaxKind.FalseLiteralExpression:
            {
                if (context.IsRefactoringEnabled(RefactoringIdentifiers.NegateBooleanLiteral) &&
                    literalExpression.Span.Contains(context.Span))
                {
                    context.RegisterRefactoring(
                        "Negate boolean literal",
                        cancellationToken => NegateBooleanLiteralRefactoring.RefactorAsync(context.Document, literalExpression, cancellationToken));
                }

                break;
            }

            case SyntaxKind.StringLiteralExpression:
            {
                StringLiteralExpressionRefactoring.ComputeRefactorings(context, literalExpression);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        public static async Task ComputeRefactoringsAsync(RefactoringContext context, LiteralExpressionSyntax literalExpression)
        {
            switch (literalExpression.Kind())
            {
            case SyntaxKind.TrueLiteralExpression:
            case SyntaxKind.FalseLiteralExpression:
            {
                if (context.IsRefactoringEnabled(RefactoringIdentifiers.NegateBooleanLiteral) &&
                    literalExpression.Span.Contains(context.Span))
                {
                    context.RegisterRefactoring(
                        "Negate boolean literal",
                        cancellationToken => NegateBooleanLiteralRefactoring.RefactorAsync(context.Document, literalExpression, cancellationToken));
                }

                break;
            }

            case SyntaxKind.StringLiteralExpression:
            {
                if (context.Span.IsContainedInSpanOrBetweenSpans(literalExpression))
                {
                    await StringLiteralExpressionRefactoring.ComputeRefactoringsAsync(context, literalExpression).ConfigureAwait(false);
                }

                break;
            }
            }
        }