public override void Run(ResolveResult symbol) { var entity = GetSymbol(symbol); if ((entity is IMember) && ((entity.SymbolKind == SymbolKind.Constructor) || (entity.SymbolKind == SymbolKind.Destructor))) { // Don't rename constructors/destructors, rename their declaring type instead entity = ((IMember) entity).DeclaringType.GetDefinition(); } if (entity != null) { var project = GetProjectFromSymbol(entity); if (project != null) { var languageBinding = project.LanguageBinding; RenameSymbolDialog renameDialog = new RenameSymbolDialog(name => CheckName(name, languageBinding)) { Owner = SD.Workbench.MainWindow, OldSymbolName = entity.Name, NewSymbolName = entity.Name }; if ((bool) renameDialog.ShowDialog()) { AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation( "${res:SharpDevelop.Refactoring.Rename}", progressMonitor => FindReferenceService.RenameSymbol(entity, renameDialog.NewSymbolName, progressMonitor) .ObserveOnUIThread() .Subscribe(error => SD.MessageService.ShowError(error.Message), ex => SD.MessageService.ShowException(ex), () => {})); } } } }
public static void RunRename(ISymbol symbol, string newName = null) { if ((symbol is IMember) && ((symbol.SymbolKind == SymbolKind.Constructor) || (symbol.SymbolKind == SymbolKind.Destructor))) { // Don't rename constructors/destructors, rename their declaring type instead symbol = ((IMember) symbol).DeclaringType.GetDefinition(); } if (symbol != null) { var project = GetProjectFromSymbol(symbol); if (project != null) { var languageBinding = project.LanguageBinding; if (newName == null) { RenameSymbolDialog renameDialog = new RenameSymbolDialog(name => CheckName(name, languageBinding)) { Owner = SD.Workbench.MainWindow, OldSymbolName = symbol.Name, NewSymbolName = symbol.Name }; if (renameDialog.ShowDialog() == true) { newName = renameDialog.NewSymbolName; } else { return; } } AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation( "${res:SharpDevelop.Refactoring.Rename}", progressMonitor => FindReferenceService.RenameSymbol(symbol, newName, progressMonitor) .ObserveOnUIThread() .Subscribe(error => SD.MessageService.ShowError(error.Message), ex => SD.MessageService.ShowException(ex), () => {})); } } }
public override void Run(ResolveResult symbol) { var entity = GetSymbol(symbol); if (entity != null) { var project = GetProjectFromSymbol(entity); if (project != null) { var languageBinding = project.LanguageBinding; RenameSymbolDialog renameDialog = new RenameSymbolDialog(name => CheckName(name, languageBinding)) { Owner = SD.Workbench.MainWindow, OldSymbolName = entity.Name, NewSymbolName = entity.Name }; if ((bool) renameDialog.ShowDialog()) { AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation( "${res:SharpDevelop.Refactoring.Rename}", progressMonitor => FindReferenceService.RenameSymbol(entity, renameDialog.NewSymbolName, progressMonitor) .ObserveOnUIThread() .Subscribe(error => SD.MessageService.ShowError(error.Message), ex => SD.MessageService.ShowException(ex), () => {})); } } } }