Skip to content

Commit 420f920

Browse files
authored
Merge pull request #2605 from MDoerner/ReworkParseCoordinatorPart1Bugfix
Rework parse coordinator part1 bugfix
2 parents f1a5df6 + 22ec3a4 commit 420f920

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Rubberduck.Parsing/VBA/ComponentParseTask.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ public void Start(CancellationToken token)
101101
Cause = exception
102102
});
103103
}
104-
catch (OperationCanceledException)
104+
catch (OperationCanceledException exception)
105105
{
106-
// no results to be used, so no results "returned"
106+
//We return this, so that the calling code knows that the operation actually has been cancelled.
107+
var failedHandler = ParseFailure;
108+
if (failedHandler != null)
109+
failedHandler.Invoke(this, new ParseFailureArgs
110+
{
111+
Cause = exception
112+
});
107113
}
108114
}
109115

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,14 @@ private void ParseComponents(List<IVBComponent> components, CancellationToken to
215215

216216
parser.ParseFailure += (sender, e) =>
217217
{
218-
tcs.SetException(e.Cause);
218+
if (e.Cause is OperationCanceledException)
219+
{
220+
tcs.SetCanceled();
221+
}
222+
else
223+
{
224+
tcs.SetException(e.Cause);
225+
}
219226
};
220227
parser.ParseCompleted += (sender, e) =>
221228
{
@@ -230,7 +237,6 @@ private void ParseComponents(List<IVBComponent> components, CancellationToken to
230237

231238
private void ProcessComponentParseResults(IVBComponent component, Task<ComponentParseTask.ParseCompletionArgs> finishedParseTask)
232239
{
233-
finishedParseTask.Wait();
234240
if (finishedParseTask.IsFaulted)
235241
{
236242
State.SetModuleState(component, ParserState.Error, finishedParseTask.Exception.InnerException as SyntaxErrorException);

0 commit comments

Comments
 (0)