Ejemplo n.º 1
0
        public static void RenameClass(IClass c, string newName)
        {
            c = c.GetCompoundClass();             // get compound class if class is partial

            List <Reference> list = RefactoringService.FindReferences(c, null);

            if (list == null)
            {
                return;
            }

            // Add the class declaration(s)
            foreach (IClass part in GetClassParts(c))
            {
                AddDeclarationAsReference(list, part.CompilationUnit.FileName, part.Region, part.Name);
            }

            // Add the constructors
            foreach (IMethod m in c.Methods)
            {
                if (m.IsConstructor)
                {
                    AddDeclarationAsReference(list, m.DeclaringType.CompilationUnit.FileName, m.Region, c.Name);
                }
            }

            FindReferencesAndRenameHelper.RenameReferences(list, newName);
        }
        public static void Run(LocalResolveResult local)
        {
            string newName = MessageService.ShowInputBox("${res:SharpDevelop.Refactoring.Rename}", "${res:SharpDevelop.Refactoring.RenameMemberText}", local.VariableName);

            if (!FindReferencesAndRenameHelper.CheckName(newName, local.VariableName))
            {
                return;
            }

            List <Reference> list = RefactoringService.FindReferences(local, null);

            if (list == null)
            {
                return;
            }
            FindReferencesAndRenameHelper.RenameReferences(list, newName);
        }
Ejemplo n.º 3
0
        public override void Run()
        {
            LocalResolveResult local   = (LocalResolveResult)Owner;
            string             newName = MessageService.ShowInputBox("${res:SharpDevelop.Refactoring.Rename}", "${res:SharpDevelop.Refactoring.RenameMemberText}", local.Field.Name);

            if (!FindReferencesAndRenameHelper.CheckName(newName, local.Field.Name))
            {
                return;
            }

            List <Reference> list = RefactoringService.FindReferences(local, null);

            if (list == null)
            {
                return;
            }
            FindReferencesAndRenameHelper.RenameReferences(list, newName);
        }
        public static bool RenameMember(IMember member, string newName)
        {
            List <Reference> list;

            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.Rename}"))
            {
                list = RefactoringService.FindReferences(member, monitor);
                if (list == null)
                {
                    return(false);
                }
                FindReferencesAndRenameHelper.RenameReferences(list, newName);
            }

            if (member is IField)
            {
                IProperty property = FindProperty((IField)member);
                if (property != null)
                {
                    string newPropertyName = member.DeclaringType.ProjectContent.Language.CodeGenerator.GetPropertyName(newName);
                    if (newPropertyName != newName && newPropertyName != property.Name)
                    {
                        if (MessageService.AskQuestionFormatted("${res:SharpDevelop.Refactoring.Rename}", "${res:SharpDevelop.Refactoring.RenameFieldAndProperty}", property.FullyQualifiedName, newPropertyName))
                        {
                            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.Rename}"))
                            {
                                list = RefactoringService.FindReferences(property, monitor);
                                if (list != null)
                                {
                                    FindReferencesAndRenameHelper.RenameReferences(list, newPropertyName);
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }