Skip to content

Commit 3fe56a2

Browse files
committed
Repaired optimization not to parse unaltered components that got lost in the refactoring
1 parent bf65bf0 commit 3fe56a2

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,23 @@ public void Parse(CancellationTokenSource token)
109109
// tests do not fire events when components are removed--clear components
110110
ClearComponentStateCacheForTests();
111111

112-
ExecuteCommenParseActivities(components, token);
112+
// invalidation cleanup should go into ParseAsync?
113+
CleanUpComponentAttributes(components);
114+
115+
ExecuteCommonParseActivities(components, token);
113116

114117
}
115118

116-
private void ExecuteCommenParseActivities(List<IVBComponent> components, CancellationTokenSource token)
119+
private void ExecuteCommonParseActivities(List<IVBComponent> toParse, CancellationTokenSource token)
117120
{
118-
SetModuleStates(components, ParserState.Pending);
121+
SetModuleStates(toParse, ParserState.Pending);
119122

120123
SyncComReferences(State.Projects);
121124
RefreshDeclarationFinder();
122125

123126
AddBuiltInDeclarations();
124127
RefreshDeclarationFinder();
125128

126-
// invalidation cleanup should go into ParseAsync?
127-
CleanUpComponentAttributes(components);
128-
129129
if (token.IsCancellationRequested)
130130
{
131131
return;
@@ -134,14 +134,14 @@ private void ExecuteCommenParseActivities(List<IVBComponent> components, Cancell
134134
_projectDeclarations.Clear();
135135
State.ClearBuiltInReferences();
136136

137-
ParseComponents(components, token.Token);
137+
ParseComponents(toParse, token.Token);
138138

139139
if (token.IsCancellationRequested || State.Status >= ParserState.Error)
140140
{
141141
return;
142142
}
143143

144-
ResolveAllDeclarations(components, token.Token);
144+
ResolveAllDeclarations(toParse, token.Token);
145145
RefreshDeclarationFinder();
146146

147147
if (token.IsCancellationRequested || State.Status >= ParserState.Error)
@@ -198,8 +198,8 @@ private void ParseComponents(List<IVBComponent> components, CancellationToken to
198198
options,
199199
component =>
200200
{
201-
State.ClearStateCache(component);
202201
State.SetModuleState(component, ParserState.Parsing);
202+
State.ClearStateCache(component);
203203
var finishedParseTask = FinishedParseComponentTask(component, token);
204204
ProcessComponentParseResults(component, finishedParseTask);
205205
}
@@ -255,6 +255,7 @@ private void ProcessComponentParseResults(IVBComponent component, Task<Component
255255
}
256256
}
257257

258+
258259
private void ResolveAllDeclarations(List<IVBComponent> components, CancellationToken token)
259260
{
260261
var options = new ParallelOptions();
@@ -288,9 +289,12 @@ private void ParseAll(object requestor, CancellationTokenSource token)
288289
State.RefreshProjects(_vbe);
289290

290291
var components = State.Projects.SelectMany(project => project.VBComponents).ToList();
291-
292+
292293
var componentsRemoved = ClearStateCashForRemovedComponents(components);
293-
294+
295+
// invalidation cleanup should go into ParseAsync?
296+
CleanUpComponentAttributes(components);
297+
294298
var toParse = components.Where(component => State.IsNewOrModified(component)).ToList();
295299

296300
if (toParse.Count == 0)
@@ -304,7 +308,7 @@ private void ParseAll(object requestor, CancellationTokenSource token)
304308
//return; // returning here leaves state in 'ResolvedDeclarations' when a module is removed, which disables refresh
305309
}
306310

307-
ExecuteCommenParseActivities(components, token);
311+
ExecuteCommonParseActivities(toParse, token);
308312
}
309313

310314
/// <summary>

0 commit comments

Comments
 (0)