Esempio n. 1
0
        public static async Task ComputeRefactoringAsync(RefactoringContext context, EnumDeclarationSyntax enumDeclaration)
        {
            if (context.IsRefactoringEnabled(RefactoringIdentifiers.ExtractTypeDeclarationToNewFile))
            {
                ExtractTypeDeclarationToNewFileRefactoring.ComputeRefactorings(context, enumDeclaration);
            }

            if (context.IsRefactoringEnabled(RefactoringIdentifiers.SortMemberDeclarations) &&
                enumDeclaration.BracesSpan().Contains(context.Span))
            {
                await SortEnumMemberDeclarationsRefactoring.ComputeRefactoringAsync(context, enumDeclaration).ConfigureAwait(false);
            }

            if (context.IsRefactoringEnabled(RefactoringIdentifiers.GenerateCombinedEnumMember) &&
                enumDeclaration.BracesSpan().Contains(context.Span))
            {
                await GenerateCombinedEnumMemberRefactoring.ComputeRefactoringAsync(context, enumDeclaration).ConfigureAwait(false);
            }

            if (context.IsRefactoringEnabled(RefactoringIdentifiers.GenerateEnumMember) &&
                context.Span.IsEmpty &&
                enumDeclaration.BracesSpan().Contains(context.Span))
            {
                await GenerateEnumMemberRefactoring.ComputeRefactoringAsync(context, enumDeclaration).ConfigureAwait(false);
            }
        }
Esempio n. 2
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);
            }
        }