Exemple #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);
            }
        }
        public static async Task ComputeRefactoringAsync(RefactoringContext context, EnumDeclarationSyntax enumDeclaration)
        {
            if (!SeparatedSyntaxListSelection <EnumMemberDeclarationSyntax> .TryCreate(enumDeclaration.Members, context.Span, out SeparatedSyntaxListSelection <EnumMemberDeclarationSyntax> selection))
            {
                return;
            }

            if (selection.Count > 1)
            {
                if (context.IsRefactoringEnabled(RefactoringIdentifiers.SortMemberDeclarations))
                {
                    await SortEnumMemberDeclarationsRefactoring.ComputeRefactoringAsync(context, enumDeclaration, selection).ConfigureAwait(false);
                }

                if (context.IsRefactoringEnabled(RefactoringIdentifiers.GenerateCombinedEnumMember))
                {
                    SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);

                    GenerateCombinedEnumMemberRefactoring.ComputeRefactoring(context, enumDeclaration, selection, semanticModel);
                }
            }

            if (context.IsRefactoringEnabled(RefactoringIdentifiers.RemoveEnumMemberValue))
            {
                RemoveEnumMemberValueRefactoring.ComputeRefactoring(context, enumDeclaration, selection);
            }
        }