diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-10-14 15:45:01 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-10-14 15:45:01 +0400 |
commit | c917b7e05745fbea633aaf3a26471315bd39d6a3 (patch) | |
tree | f8295500b982de29e1351fd43b0b375d53e61e30 /main/src/addins/MonoDevelop.Refactoring | |
parent | 41df217bd73074d26ca838840571fce043a24c7f (diff) |
Worked on stetic conversion.
Diffstat (limited to 'main/src/addins/MonoDevelop.Refactoring')
2 files changed, 24 insertions, 1 deletions
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs index 3b82bce422..01a7b2696b 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs @@ -37,6 +37,8 @@ using MonoDevelop.Ide.ProgressMonitoring; using ICSharpCode.NRefactory.CSharp.Refactoring; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem.Implementation; +using MonoDevelop.Core.ProgressMonitoring; + namespace MonoDevelop.Refactoring.Rename { @@ -68,6 +70,27 @@ namespace MonoDevelop.Refactoring.Rename } return false; } + + public static void Rename (ITypeResolveContext ctx, IEntity entity, string newName) + { + using (var monitor = new NullProgressMonitor ()) { + var col = ReferenceFinder.FindReferences (entity, monitor); + + List<Change> result = new List<Change> (); + foreach (var memberRef in col) { + var change = new TextReplaceChange (); + change.FileName = memberRef.FileName; + change.Offset = memberRef.Offset; + change.RemovedChars = memberRef.Length; + change.InsertedText = newName; + change.Description = string.Format (GettextCatalog.GetString ("Replace '{0}' with '{1}'"), memberRef.Entity.Name, newName); + result.Add (change); + } + if (result.Count > 0) { + RefactoringService.AcceptChanges (monitor, ctx, result); + } + } + } public override string GetMenuDescription (RefactoringOptions options) { diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindReferencesHandler.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindReferencesHandler.cs index ace2ae1a4e..5adcaa13b2 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindReferencesHandler.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindReferencesHandler.cs @@ -45,7 +45,7 @@ namespace MonoDevelop.Refactoring var solution = IdeApp.ProjectOperations.CurrentSelectedSolution; ThreadPool.QueueUserWorkItem (delegate { try { - foreach (var mref in ReferenceFinder.FindReferences (solution, entity, monitor)) { + foreach (var mref in ReferenceFinder.FindReferences (solution, entity, ReferenceFinder.RefactoryScope.Unknown, monitor)) { monitor.ReportResult (mref); } } catch (Exception ex) { |