Skip to content

Commit 8c36cd0

Browse files
committed
Set up check for Compile On Demand
1 parent 2f2f093 commit 8c36cd0

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

RetailCoder.VBE/UI/Command/ReparseCommand.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Rubberduck.Settings;
99
using Rubberduck.SettingsProvider;
1010
using Rubberduck.UI.CodeExplorer.Commands;
11+
using Rubberduck.VBERuntime;
1112
using Rubberduck.VBEditor.ComManagement.TypeLibsAPI;
1213
using Rubberduck.VBEditor.SafeComWrappers;
1314
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
@@ -20,13 +21,15 @@ public class ReparseCommand : CommandBase
2021
{
2122
private readonly IVBE _vbe;
2223
private readonly IVBETypeLibsAPI _typeLibApi;
24+
private readonly IVBESettings _vbeSettings;
2325
private readonly IMessageBox _messageBox;
2426
private readonly RubberduckParserState _state;
2527
private readonly GeneralSettings _settings;
2628

27-
public ReparseCommand(IVBE vbe, IConfigProvider<GeneralSettings> settingsProvider, RubberduckParserState state, IVBETypeLibsAPI typeLibApi, IMessageBox messageBox) : base(LogManager.GetCurrentClassLogger())
29+
public ReparseCommand(IVBE vbe, IConfigProvider<GeneralSettings> settingsProvider, RubberduckParserState state, IVBETypeLibsAPI typeLibApi, IVBESettings vbeSettings, IMessageBox messageBox) : base(LogManager.GetCurrentClassLogger())
2830
{
2931
_vbe = vbe;
32+
_vbeSettings = vbeSettings;
3033
_typeLibApi = typeLibApi;
3134
_state = state;
3235
_settings = settingsProvider.Create();
@@ -46,6 +49,11 @@ protected override void OnExecute(object parameter)
4649
{
4750
if (_settings.CompileBeforeParse)
4851
{
52+
if (!VerifyCompileOnDemand())
53+
{
54+
return;
55+
}
56+
4957
if (CompileAllProjects(out var failedNames))
5058
{
5159
if (!PromptUserToContinue(failedNames))
@@ -57,6 +65,20 @@ protected override void OnExecute(object parameter)
5765
_state.OnParseRequested(this);
5866
}
5967

68+
private bool VerifyCompileOnDemand()
69+
{
70+
//Command_Reparse_CompileOnDemandEnabled
71+
72+
if (_vbeSettings.CompileOnDemand)
73+
{
74+
return DialogResult.Yes == _messageBox.Show(RubberduckUI.Command_Reparse_CompileOnDemandEnabled,
75+
RubberduckUI.Command_Reparse_CompileOnDemandEnabled_Caption, MessageBoxButtons.YesNo,
76+
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
77+
}
78+
79+
return true;
80+
}
81+
6082
private bool CompileAllProjects(out List<string> failedNames)
6183
{
6284
failedNames = new List<string>();

0 commit comments

Comments
 (0)