//FIXME: why is this invalid on the parseddocuments loaded when the doc is first loaded? //maybe the item's type's SourceProject is null? public IEnumerable <IAnalysisFixAction> GetFixes(MonoDevelop.Ide.Gui.Document doc, object fix) { var renameFix = (RenameMemberFix)fix; var refactoring = new RenameRefactoring(); var options = new RefactoringOptions(doc) { SelectedItem = renameFix.Item, }; if (renameFix.Item == null) { ResolveResult resolveResult; options.SelectedItem = CurrentRefactoryOperationsHandler.GetItem(options.Document, out resolveResult); } if (!refactoring.IsValid(options)) { yield break; } var prop = new RenameRefactoring.RenameProperties() { NewName = renameFix.NewName, }; if (string.IsNullOrEmpty(renameFix.NewName)) { yield return(new RenameFixAction() { Label = GettextCatalog.GetString("Rename '{0}'...", renameFix.OldName), Refactoring = refactoring, Options = options, Properties = prop, Preview = false, }); yield break; } yield return(new RenameFixAction() { Label = GettextCatalog.GetString("Rename '{0}' to '{1}'", renameFix.OldName, renameFix.NewName), Refactoring = refactoring, Options = options, Properties = prop, Preview = false, }); yield return(new RenameFixAction() { Label = GettextCatalog.GetString("Rename '{0}' to '{1}' with preview", renameFix.OldName, renameFix.NewName), Refactoring = refactoring, Options = options, Properties = prop, Preview = true, }); }
protected override void Update(RefactoringOptions options, CommandInfo info) { info.Enabled = true; /* * LoggingService.LogDebug ("-------------------------------"); * LoggingService.LogDebug (options.SelectedItem.GetType().ToString()); * LoggingService.LogDebug ("-------------------------------"); */ RenameRefactoring renameRefactoring = new RenameRefactoring(); if (!renameRefactoring.IsValid(options)) { LoggingService.LogDebug("inside if"); } }
//FIXME: why is this invalid on the parseddocuments loaded when the doc is first loaded? //maybe the item's type's SourceProject is null? public IEnumerable <IAnalysisFixAction> GetFixes(MonoDevelop.Ide.Gui.Document doc, object fix) { var renameFix = (RenameMemberFix)fix; var refactoring = new RenameRefactoring(); var options = new RefactoringOptions() { Document = doc, Dom = doc.Dom, SelectedItem = renameFix.Item, }; if (!refactoring.IsValid(options)) { yield break; } var prop = new RenameRefactoring.RenameProperties() { NewName = renameFix.NewName, }; yield return(new RenameFixAction() { Label = GettextCatalog.GetString("Rename '{0}' to '{1}'", renameFix.Item.Name, renameFix.NewName), Refactoring = refactoring, Options = options, Properties = prop, Preview = false, }); yield return(new RenameFixAction() { Label = GettextCatalog.GetString("Rename '{0}' to '{1}' with preview", renameFix.Item.Name, renameFix.NewName), Refactoring = refactoring, Options = options, Properties = prop, Preview = true, }); }
protected override void Run(RefactoringOptions options) { RenameRefactoring renameRefactoring = new RenameRefactoring(); if (renameRefactoring.IsValid(options)) { if (options.SelectedItem is ITypeDefinition) { ITypeDefinition classname = options.SelectedItem as ITypeDefinition; //IEnumerable<IMethod> methodList = classname.Methods; IList <IMember> memList = classname.Members; foreach (IMember m in memList) { IEnumerable <IAttribute> attributelist = m.GetAttributes(true); /* * * * if (m is IParameterizedMember) { * IParameterizedMember iMem = m as IParameterizedMember; * LoggingService.LogDebug ("#################################################"); * LoggingService.LogDebug ("name of de iMemName " + iMem.Name); * IList<IParameter> para = iMem.Parameters; * * for(int i = 0 ; i<para.Count; i++){ * //ISymbol pMetre = para[i] as ISymbol; * //LoggingService.LogDebug ("pMetre " + pMetre.Name); * //IParameter p; * IVariable iVar = para[i] as IVariable; * LoggingService.LogDebug ("name1 " + iVar.Name); * RenameRefactoring.RenameVariable (iVar, NewRefector.MethodName [index++]); * //LoggingService.LogDebug ("name2 " + iVar.Name); * * } * LoggingService.LogDebug ("#################################################"); * } * */ if (m is IVariable) { if (m.IsPrivate) { bool change = true; foreach (IAttribute attribute in attributelist) { if (attribute.AttributeType.Name == "SerializeField") { change = false; LoggingService.LogDebug("serialized thats why mot changed " + m.Name); } } if (change) { IVariable var = m as IVariable; RenameRefactoring.RenameVariable(var, NewRefector.MethodName [index++]); LoggingService.LogDebug(" variable " + m.FullName); } } else if (m.IsPublic) { foreach (IAttribute attribute in attributelist) { if (attribute.AttributeType.Name == "Change") { IVariable var = m as IVariable; RenameRefactoring.RenameVariable(var, NewRefector.MethodName [index++]); } } } } else { bool changeMethod = true; foreach (IAttribute attr in attributelist) { if (attr.AttributeType.Name == "DoNotChange") { changeMethod = false; } } if (NewRefector.hasValue(m.Name)) { changeMethod = false; } if (m.IsAbstract || m.IsVirtual || m.IsOverride) { changeMethod = false; } if (changeMethod) { IEntity Method = m as IEntity; LoggingService.LogDebug("change method " + m.Name); //RenameRefactoring.Rename (Method, NewRefector.MethodName [index++]); } } } } } }