Skip to content

Commit f8f1b14

Browse files
committed
no longer sets LoadingReferences parser state, only sets status text when *actually* loading COM references
1 parent 193c66a commit f8f1b14

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

RetailCoder.VBE/App.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public App(VBE vbe, IMessageBox messageBox,
6969
_configService.SettingsChanged += _configService_SettingsChanged;
7070
_configService.LanguageChanged += ConfigServiceLanguageChanged;
7171
_parser.State.StateChanged += Parser_StateChanged;
72+
_parser.State.StatusMessageUpdate += State_StatusMessageUpdate;
7273
_stateBar.Refresh += _stateBar_Refresh;
7374

7475
var sink = new VBProjectsEventsSink();
@@ -93,6 +94,18 @@ public App(VBE vbe, IMessageBox messageBox,
9394
UiDispatcher.Initialize();
9495
}
9596

97+
private void State_StatusMessageUpdate(object sender, RubberduckStatusMessageEventArgs e)
98+
{
99+
var message = e.Message;
100+
if (message == ParserState.LoadingReference.ToString())
101+
{
102+
// note: ugly hack to enable Rubberduck.Parsing assembly to do this
103+
message = RubberduckUI.ParserState_LoadingReference;
104+
}
105+
106+
_stateBar.SetStatusText(message);
107+
}
108+
96109
private void _hooks_MessageReceived(object sender, HookEventArgs e)
97110
{
98111
var hookType = sender.GetType();

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ public void Parse()
100100
.ToList();
101101

102102
var components = projects.SelectMany(p => p.VBComponents.Cast<VBComponent>()).ToList();
103-
_state.SetModuleState(ParserState.LoadingReference);
104-
105103
SyncComReferences(projects);
106104

107105
foreach (var component in components)
@@ -137,7 +135,6 @@ private void ParseAll()
137135
var modified = components.Where(_state.IsModified).ToList();
138136
var unchanged = components.Where(c => !_state.IsModified(c)).ToList();
139137

140-
_state.SetModuleState(ParserState.LoadingReference); // todo: change that to a simple statusbar text update
141138
SyncComReferences(projects);
142139

143140
if (!modified.Any())
@@ -190,6 +187,7 @@ private void SyncComReferences(IReadOnlyList<VBProject> projects)
190187

191188
if (!map.IsLoaded)
192189
{
190+
_state.OnStatusMessageUpdate(ParserState.LoadingReference.ToString());
193191
var items = _comReflector.GetDeclarationsForReference(reference).ToList();
194192
foreach (var declaration in items)
195193
{

Rubberduck.Parsing/VBA/RubberduckParserState.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,20 @@ public ParseRequestEventArgs(VBComponent component)
4242
public bool IsFullReparseRequest { get { return _component == null; } }
4343
}
4444

45-
public sealed class RubberduckParserState
45+
public class RubberduckStatusMessageEventArgs : EventArgs
4646
{
47-
public event EventHandler<ParseRequestEventArgs> ParseRequest;
47+
private readonly string _message;
48+
49+
public RubberduckStatusMessageEventArgs(string message)
50+
{
51+
_message = message;
52+
}
4853

54+
public string Message { get { return _message; } }
55+
}
56+
57+
public sealed class RubberduckParserState
58+
{
4959
// circumvents VBIDE API's tendency to return a new instance at every parse, which breaks reference equality checks everywhere
5060
private readonly IDictionary<string,Func<VBProject>> _projects = new Dictionary<string,Func<VBProject>>();
5161

@@ -76,6 +86,19 @@ public sealed class RubberduckParserState
7686
private readonly ConcurrentDictionary<QualifiedModuleName, IDictionary<Tuple<string, DeclarationType>, Attributes>> _moduleAttributes =
7787
new ConcurrentDictionary<QualifiedModuleName, IDictionary<Tuple<string, DeclarationType>, Attributes>>();
7888

89+
public event EventHandler<ParseRequestEventArgs> ParseRequest;
90+
public event EventHandler<RubberduckStatusMessageEventArgs> StatusMessageUpdate;
91+
92+
public void OnStatusMessageUpdate(string message)
93+
{
94+
var handler = StatusMessageUpdate;
95+
if (handler != null)
96+
{
97+
var args= new RubberduckStatusMessageEventArgs(message);
98+
handler.Invoke(this, args);
99+
}
100+
}
101+
79102
public void AddProject(VBProject project)
80103
{
81104
if (string.IsNullOrEmpty(project.HelpFile))

0 commit comments

Comments
 (0)