Example #1
0
        public static async Task ComputeRefactoringAsync(RefactoringContext context, EnumDeclarationSyntax enumDeclaration)
        {
            if (context.IsRefactoringEnabled(RefactoringDescriptors.ExtractTypeDeclarationToNewFile))
            {
                ExtractTypeDeclarationToNewFileRefactoring.ComputeRefactorings(context, enumDeclaration);
            }

            if (context.IsRefactoringEnabled(RefactoringDescriptors.RemoveEnumMemberValue) &&
                context.Span.IsEmptyAndContainedInSpan(enumDeclaration.Identifier))
            {
                RemoveEnumMemberValueRefactoring.ComputeRefactoring(context, enumDeclaration);
            }

            if (context.IsRefactoringEnabled(RefactoringDescriptors.GenerateEnumValues) &&
                context.Span.IsEmpty)
            {
                if (enumDeclaration.BracesSpan().Contains(context.Span))
                {
                    SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);

                    GenerateEnumValuesRefactoring.ComputeRefactoring(context, enumDeclaration, semanticModel);
                }

                if (enumDeclaration.Identifier.Span.Contains(context.Span))
                {
                    SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);

                    GenerateAllEnumValuesRefactoring.ComputeRefactoring(context, enumDeclaration, semanticModel);
                }
            }

            await SelectedEnumMemberDeclarationsRefactoring.ComputeRefactoringAsync(context, enumDeclaration).ConfigureAwait(false);

            if (context.IsRefactoringEnabled(RefactoringDescriptors.GenerateEnumMember) &&
                context.Span.IsEmpty &&
                enumDeclaration.BracesSpan().Contains(context.Span))
            {
                SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);

                GenerateEnumMemberRefactoring.ComputeRefactoring(context, enumDeclaration, semanticModel);
            }
        }
Example #2
0
        public static async Task ComputeRefactoringAsync(RefactoringContext context, EnumMemberDeclarationSyntax enumMemberDeclaration)
        {
            if (context.Span.IsEmpty &&
                enumMemberDeclaration.Parent is EnumDeclarationSyntax enumDeclaration)
            {
                if (context.IsRefactoringEnabled(RefactoringDescriptors.GenerateEnumValues))
                {
                    SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);

                    GenerateEnumValuesRefactoring.ComputeRefactoring(context, enumDeclaration, semanticModel);
                }

                if (context.IsRefactoringEnabled(RefactoringDescriptors.GenerateEnumMember))
                {
                    SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);

                    GenerateEnumMemberRefactoring.ComputeRefactoring(context, enumDeclaration, semanticModel);
                }
            }
        }
Example #3
0
        public static async Task ComputeRefactoringAsync(RefactoringContext context, EnumMemberDeclarationSyntax enumMemberDeclaration)
        {
            if (context.Span.IsEmptyAndContainedInSpan(enumMemberDeclaration))
            {
                SyntaxNode parent = enumMemberDeclaration.Parent;

                if (parent?.IsKind(SyntaxKind.EnumDeclaration) == true)
                {
                    var enumDeclaration = (EnumDeclarationSyntax)parent;

                    if (context.IsRefactoringEnabled(RefactoringIdentifiers.GenerateEnumValues))
                    {
                        await GenerateEnumValuesRefactoring.ComputeRefactoringAsync(context, enumDeclaration).ConfigureAwait(false);
                    }

                    if (context.IsRefactoringEnabled(RefactoringIdentifiers.GenerateEnumMember))
                    {
                        await GenerateEnumMemberRefactoring.ComputeRefactoringAsync(context, enumDeclaration).ConfigureAwait(false);
                    }
                }
            }
        }