Skip to content

Commit 1226055

Browse files
committed
Performance improvements (allocations), comments.
1 parent 7f97098 commit 1226055

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

Rubberduck.Core/UI/CodeExplorer/Commands/DeleteCommand.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public DeleteCommand(RemoveCommand removeCommand, IProjectsProvider projectsProv
2727
AddToCanExecuteEvaluation(SpecialEvaluateCanExecute);
2828
}
2929

30-
public override IEnumerable<Type> ApplicableNodeTypes => new List<Type> { typeof(CodeExplorerComponentViewModel) };
30+
public override IEnumerable<Type> ApplicableNodeTypes { get; } = new List<Type> { typeof(CodeExplorerComponentViewModel) };
3131

3232
private bool SpecialEvaluateCanExecute(object parameter)
3333
{
@@ -42,14 +42,14 @@ protected override void OnExecute(object parameter)
4242
return;
4343
}
4444

45-
var qualifiedModuleName = node.Declaration.QualifiedName.QualifiedModuleName;
45+
var qualifiedModuleName = node.Declaration.QualifiedModuleName;
4646
var component = _projectsProvider.Component(qualifiedModuleName);
4747
if (component is null)
4848
{
4949
return;
5050
}
5151

52-
// Permanent operation, prompt for confirm
52+
// "{qualifiedModuleName.Name} will be permanently deleted. Continue?" (localized)
5353
var message = string.Format(Resources.CodeExplorer.CodeExplorerUI.ConfirmBeforeDelete_Prompt, qualifiedModuleName.Name);
5454
if (!_messageBox.ConfirmYesNo(message, Resources.CodeExplorer.CodeExplorerUI.ConfirmBeforeDelete_Caption))
5555
{
@@ -89,6 +89,7 @@ protected override void OnExecute(object parameter)
8989
// Let the user know if there are any component files left on disk
9090
if (failedDeletions.Any())
9191
{
92+
// "The following files could not be deleted: {fileDeletions}" (localized)
9293
message = string.Format(Resources.CodeExplorer.CodeExplorerUI.DeleteFailed_Message, string.Join(Environment.NewLine, failedDeletions));
9394
_messageBox.NotifyWarn(message, Resources.CodeExplorer.CodeExplorerUI.DeleteFailed_Caption);
9495
}

Rubberduck.Core/UI/CodeExplorer/Commands/RemoveCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ public RemoveCommand(ExportCommand exportCommand, IProjectsRepository projectsRe
2727
AddToCanExecuteEvaluation(SpecialEvaluateCanExecute);
2828
}
2929

30-
public override IEnumerable<Type> ApplicableNodeTypes => new List<Type> { typeof(CodeExplorerComponentViewModel) };
30+
public override IEnumerable<Type> ApplicableNodeTypes { get; } = new List<Type> { typeof(CodeExplorerComponentViewModel)};
3131

3232
private bool SpecialEvaluateCanExecute(object parameter)
3333
{
3434
return _exportCommand.CanExecute(parameter) &&
3535
parameter is CodeExplorerComponentViewModel viewModel &&
36+
viewModel.Declaration != null &&
3637
viewModel.Declaration.QualifiedModuleName.ComponentType != ComponentType.Document;
3738
}
3839

Rubberduck.Resources/CodeExplorer/CodeExplorerUI.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Resources/CodeExplorer/CodeExplorerUI.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,6 @@
434434
<value>Delete Failed</value>
435435
</data>
436436
<data name="DeleteFailed_Message" xml:space="preserve">
437-
<value>The following files could not be deleted\r\n\r\n{0}</value>
437+
<value>The following files could not be deleted:\r\n\r\n{0}</value>
438438
</data>
439439
</root>

0 commit comments

Comments
 (0)