Skip to content

Commit 05a8bad

Browse files
committed
Address review comments.
1 parent d84f3e7 commit 05a8bad

File tree

8 files changed

+19
-11
lines changed

8 files changed

+19
-11
lines changed

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Rubberduck.VBEditor.SafeComWrappers;
77
using Rubberduck.Resources.CodeExplorer;
88
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
9+
using System;
910

1011
namespace Rubberduck.Navigation.CodeExplorer
1112
{
@@ -113,9 +114,9 @@ private void SetName()
113114
break;
114115
}
115116
}
116-
catch
117+
catch (Exception ex)
117118
{
118-
//Ignored;
119+
Logger.Trace(ex);
119120
}
120121

121122
OnNameChanged();

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public CodeExplorerCustomFolderViewModel(
4949
public override bool IsErrorState
5050
{
5151
get => false;
52-
set { }
52+
set { /* Folders can never be in an error state. */ }
5353
}
5454

5555
public override Comparer<ICodeExplorerNode> SortComparer => CodeExplorerItemComparer.Name;

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public virtual void Synchronize(List<Declaration> updated)
4141
return;
4242
}
4343

44-
var matching = updated.FirstOrDefault(decl => Declaration.QualifiedName.Equals(decl?.QualifiedName));
44+
var matching = updated.FirstOrDefault(decl => Declaration.DeclarationType == decl?.DeclarationType && Declaration.QualifiedName.Equals(decl?.QualifiedName));
4545

4646
if (matching is null)
4747
{

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerItemViewModelBase.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Globalization;
66
using System.Linq;
77
using System.Windows;
8+
using NLog;
89
using Rubberduck.Parsing;
910
using Rubberduck.Parsing.Symbols;
1011
using Rubberduck.Resources;
@@ -15,6 +16,8 @@ namespace Rubberduck.Navigation.CodeExplorer
1516
{
1617
public abstract class CodeExplorerItemViewModelBase : ViewModelBase, ICodeExplorerNode
1718
{
19+
protected static readonly Logger Logger = LogManager.GetCurrentClassLogger();
20+
1821
protected CodeExplorerItemViewModelBase(ICodeExplorerNode parent, Declaration declaration)
1922
{
2023
Parent = parent;

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerReferenceViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public CodeExplorerReferenceViewModel(ICodeExplorerNode parent, ReferenceModel r
3131
public override bool IsErrorState
3232
{
3333
get => false;
34-
set { }
34+
set { /* References can never be in an error state (in this context). */ }
3535
}
3636

3737
public override string ToolTip => Reference?.Description ?? string.Empty;

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public CodeExplorerViewModel(
6868
_vbe = vbe;
6969
_templateProvider = templateProvider;
7070

71-
CollapseAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseNodes);
72-
ExpandAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandNodes);
71+
CollapseAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseNodes, EvaluateCanSwitchNodeState);
72+
ExpandAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandNodes, EvaluateCanSwitchNodeState);
7373
ClearSearchCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteClearSearchCommand);
7474
if (_externalRemoveCommand != null)
7575
{
@@ -308,6 +308,11 @@ private void ExecuteClearSearchCommand(object parameter)
308308
}
309309
}
310310

311+
private bool EvaluateCanSwitchNodeState(object parameter)
312+
{
313+
return SelectedItem?.Children?.Any() ?? false;
314+
}
315+
311316
private void ExecuteCollapseNodes(object parameter)
312317
{
313318
if (!(parameter is ICodeExplorerNode node))

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ protected override bool EvaluateCanExecute(object parameter)
3333

3434
if (project != null || Vbe.ProjectsCount != 1)
3535
{
36-
return EvaluateCanExecuteCore(project, node);
36+
return EvaluateCanExecuteForProject(project, node);
3737
}
3838

3939
using (var vbProjects = Vbe.VBProjects)
4040
using (project = vbProjects[1])
4141
{
42-
return EvaluateCanExecuteCore(project, node);
42+
return EvaluateCanExecuteForProject(project, node);
4343
}
4444
}
4545

46-
private bool EvaluateCanExecuteCore(IVBProject project, CodeExplorerItemViewModel itemViewModel)
46+
private bool EvaluateCanExecuteForProject(IVBProject project, CodeExplorerItemViewModel itemViewModel)
4747
{
4848
if (project == null)
4949
{

Rubberduck.Core/UI/Command/SyncCodeExplorerCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ protected override bool EvaluateCanExecute(object parameter)
4848
{
4949
if (_state.Status != ParserState.Ready ||
5050
_explorer.IsBusy ||
51-
//_explorer.TreeViewVisibility != Visibility.Visible ||
5251
FindTargetNode() == null)
5352
{
5453
return false;

0 commit comments

Comments
 (0)