Skip to content

Commit fa8ac43

Browse files
authored
Merge pull request #2372 from retailcoder/next
Standardized Reparsing from Code Explorer and Inspection Results toolwindows
2 parents 2e6907c + f536d4d commit fa8ac43

File tree

13 files changed

+57
-80
lines changed

13 files changed

+57
-80
lines changed

RetailCoder.VBE/App.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public App(IVBE vbe,
5151
_configService.SettingsChanged += _configService_SettingsChanged;
5252
_parser.State.StateChanged += Parser_StateChanged;
5353
_parser.State.StatusMessageUpdate += State_StatusMessageUpdate;
54-
_stateBar.Refresh += _stateBar_Refresh;
5554

5655
UiDispatcher.Initialize();
5756
}
@@ -119,7 +118,7 @@ private void _configService_SettingsChanged(object sender, ConfigurationChangedE
119118
}
120119
}
121120

122-
private void EnsureDirectoriesExist()
121+
private static void EnsureLogFolderPathExists()
123122
{
124123
try
125124
{
@@ -141,7 +140,7 @@ private void UpdateLoggingLevel()
141140

142141
public void Startup()
143142
{
144-
EnsureDirectoriesExist();
143+
EnsureLogFolderPathExists();
145144
LoadConfig();
146145
_appMenus.Initialize();
147146
_stateBar.Initialize();
@@ -163,13 +162,6 @@ public void Shutdown()
163162
}
164163
}
165164

166-
private void _stateBar_Refresh(object sender, EventArgs e)
167-
{
168-
// handles "refresh" button click on "Rubberduck" command bar
169-
_parser.State.OnParseRequested(sender);
170-
_parser.State.StartEventSinks(); // no-op if already started
171-
}
172-
173165
private void Parser_StateChanged(object sender, EventArgs e)
174166
{
175167
Logger.Debug("App handles StateChanged ({0}), evaluating menu states...", _parser.State.Status);
@@ -221,11 +213,6 @@ public void Dispose()
221213
_configService.SettingsChanged -= _configService_SettingsChanged;
222214
}
223215

224-
if (_stateBar != null)
225-
{
226-
_stateBar.Refresh -= _stateBar_Refresh;
227-
}
228-
229216
if (_autoSave != null)
230217
{
231218
_autoSave.Dispose();

RetailCoder.VBE/Common/RubberduckHooks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public RubberduckHooks(IVBE vbe, IGeneralConfigService config, IEnumerable<Comma
4545

4646
private CommandBase Command(RubberduckHotkey hotkey)
4747
{
48-
return _commands.SingleOrDefault(s => s.Hotkey == hotkey);
48+
return _commands.FirstOrDefault(s => s.Hotkey == hotkey);
4949
}
5050

5151
public void HookHotkeys()

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState st
3131
_state.StateChanged += ParserState_StateChanged;
3232
_state.ModuleStateChanged += ParserState_ModuleStateChanged;
3333

34-
_refreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param => _state.OnParseRequested(this),
35-
param => !IsBusy && _state.IsDirty());
34+
var reparseCommand = commands.OfType<ReparseCommand>().SingleOrDefault();
35+
36+
_refreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(),
37+
reparseCommand == null ? (Action<object>)(o => { }) :
38+
o => reparseCommand.Execute(o),
39+
o => !IsBusy && reparseCommand != null && reparseCommand.CanExecute(o));
3640

3741
_navigateCommand = commands.OfType<UI.CodeExplorer.Commands.NavigateCommand>().SingleOrDefault();
3842

RetailCoder.VBE/Root/RubberduckModule.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
using Ninject.Extensions.NamedScope;
3131
using Rubberduck.Parsing.Symbols;
3232
using Rubberduck.UI.CodeExplorer.Commands;
33-
using Rubberduck.VBEditor;
3433
using Rubberduck.VBEditor.Application;
3534
using Rubberduck.VBEditor.Events;
3635
using Rubberduck.VBEditor.SafeComWrappers.Abstract;

RetailCoder.VBE/UI/CodeExplorer/Commands/AddClassModuleCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Rubberduck.UI.Command;
66
using Rubberduck.VBEditor.SafeComWrappers;
77
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
8-
using Rubberduck.VBEditor.SafeComWrappers.VBA;
98

109
namespace Rubberduck.UI.CodeExplorer.Commands
1110
{

RetailCoder.VBE/UI/CodeExplorer/Commands/AddStdModuleCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Rubberduck.UI.Command;
66
using Rubberduck.VBEditor.SafeComWrappers;
77
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
8-
using Rubberduck.VBEditor.SafeComWrappers.VBA;
98

109
namespace Rubberduck.UI.CodeExplorer.Commands
1110
{

RetailCoder.VBE/UI/CodeExplorer/Commands/AddUserFormCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Rubberduck.UI.Command;
66
using Rubberduck.VBEditor.SafeComWrappers;
77
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
8-
using Rubberduck.VBEditor.SafeComWrappers.VBA;
98

109
namespace Rubberduck.UI.CodeExplorer.Commands
1110
{

RetailCoder.VBE/UI/CodeExplorer/Commands/ExportCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Rubberduck.Navigation.CodeExplorer;
88
using Rubberduck.UI.Command;
99
using Rubberduck.VBEditor.SafeComWrappers;
10-
using Rubberduck.VBEditor.SafeComWrappers.VBA;
1110

1211
namespace Rubberduck.UI.CodeExplorer.Commands
1312
{

RetailCoder.VBE/UI/CodeExplorer/Commands/ImportCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Rubberduck.Navigation.CodeExplorer;
66
using Rubberduck.UI.Command;
77
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
8-
using Rubberduck.VBEditor.SafeComWrappers.VBA;
98

109
namespace Rubberduck.UI.CodeExplorer.Commands
1110
{

RetailCoder.VBE/UI/Command/MenuItems/RubberduckCommandBar.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ public class RubberduckCommandBar : IDisposable
1616
private readonly RubberduckParserState _state;
1717
private readonly IVBE _vbe;
1818
private readonly IShowParserErrorsCommand _command;
19+
private readonly ReparseCommand _reparseCommand;
1920

2021
private ICommandBarButton _refreshButton;
2122
private ICommandBarButton _statusButton;
2223
private ICommandBarButton _selectionButton;
2324
private ICommandBar _commandbar;
2425

25-
public RubberduckCommandBar(RubberduckParserState state, IVBE vbe, IShowParserErrorsCommand command)
26+
public RubberduckCommandBar(RubberduckParserState state, IVBE vbe, IShowParserErrorsCommand command, ReparseCommand reparseCommand)
2627
{
2728
_state = state;
2829
_vbe = vbe;
2930
_command = command;
31+
_reparseCommand = reparseCommand;
3032
}
3133

3234
public void SetSelectionText()
@@ -118,17 +120,6 @@ private void State_StateChanged(object sender, EventArgs e)
118120
}
119121
}
120122

121-
public event EventHandler Refresh;
122-
123-
private void OnRefresh()
124-
{
125-
var handler = Refresh;
126-
if (handler != null)
127-
{
128-
handler.Invoke(this, EventArgs.Empty);
129-
}
130-
}
131-
132123
public void Initialize()
133124
{
134125
_commandbar = _vbe.CommandBars.Add("Rubberduck", CommandBarPosition.Top);
@@ -163,7 +154,10 @@ public void Initialize()
163154

164155
private void refreshButton_Click(object sender, CommandBarButtonClickEventArgs e)
165156
{
166-
OnRefresh();
157+
if (_reparseCommand.CanExecute(null))
158+
{
159+
_reparseCommand.Execute(null);
160+
}
167161
e.Cancel = true;
168162
}
169163

0 commit comments

Comments
 (0)