private bool TrySetNewName(IRenamePresenter presenter) { var result = presenter.Show(_model.Target); if (result == null) { return(false); } var conflictDeclarations = _state.DeclarationFinder.GetDeclarationsWithIdentifiersToAvoid(_model.Target) .Where(d => d.IdentifierName.Equals(_model.NewName, StringComparison.InvariantCultureIgnoreCase)); if (conflictDeclarations.Any()) { var message = string.Format(RubberduckUI.RenameDialog_ConflictingNames, _model.NewName, conflictDeclarations.FirstOrDefault().IdentifierName); var rename = _messageBox?.Show(message, RubberduckUI.RenameDialog_Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); return(rename.HasValue ? rename.Value == DialogResult.Yes : false); } return(true); }
private bool TrySetNewName(IRenamePresenter presenter) { var result = presenter.Show(_model.Target); if (result == null) { return(false); } var conflicts = _declarationFinderProvider.DeclarationFinder.FindNewDeclarationNameConflicts(_model.NewName, _model.Target); if (conflicts.Any()) { var message = string.Format(RubberduckUI.RenameDialog_ConflictingNames, _model.NewName, _model.Target.IdentifierName); return(_messageBox?.ConfirmYesNo(message, RubberduckUI.RenameDialog_Caption) ?? false); } return(true); }
private bool TrySetNewName(IRenamePresenter presenter) { var result = presenter.Show(_model.Target); if (result == null) { return(false); } var conflictDeclarations = _state.DeclarationFinder.GetDeclarationsWithIdentifiersToAvoid(_model.Target) .Where(d => d.IdentifierName.Equals(_model.NewName, StringComparison.InvariantCultureIgnoreCase)).ToList(); if (conflictDeclarations.Any()) { var message = string.Format(RubberduckUI.RenameDialog_ConflictingNames, _model.NewName, conflictDeclarations.First().IdentifierName); return(_messageBox?.ConfirmYesNo(message, RubberduckUI.RenameDialog_Caption) ?? false); } return(true); }