Skip to content

Commit

Permalink
Prevent one failing listener from blowing up the whole parse task.
Browse files Browse the repository at this point in the history
  • Loading branch information
retailcoder committed Nov 22, 2017
1 parent 5bb807c commit 5573dc6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 2 additions & 8 deletions Rubberduck.Parsing/VBA/ComponentParseTask.cs
Expand Up @@ -87,11 +87,7 @@ public void Start(CancellationToken cancellationToken)
catch (COMException exception)
{
Logger.Error(exception, $"COM Exception thrown in thread {Thread.CurrentThread.ManagedThreadId} while parsing module {_module.ComponentName}, ParseTaskID {_taskId}.");
var failedHandler = ParseFailure;
failedHandler?.Invoke(this, new ParseFailureArgs
{
Cause = exception
});
ReportException(exception);
}
catch (PreprocessorSyntaxErrorException syntaxErrorException)
{
Expand Down Expand Up @@ -158,9 +154,7 @@ private static string GetCode(ICodeModule module)
return string.Empty;
}

var codeLines = module.GetLines(1, lines);
var code = string.Concat(codeLines);

var code = module.GetLines(1, lines);
return code;
}

Expand Down
11 changes: 9 additions & 2 deletions Rubberduck.Parsing/VBA/VBAModuleParser.cs
Expand Up @@ -4,7 +4,6 @@
using NLog;
using Rubberduck.Parsing.Grammar;
using System;
using Rubberduck.Parsing.Symbols;
using Rubberduck.Parsing.Symbols.ParsingExceptions;

namespace Rubberduck.Parsing.VBA
Expand Down Expand Up @@ -45,9 +44,17 @@ public sealed class VBAModuleParser
parser.Interpreter.PredictionMode = PredictionMode.Ll;
tree = parser.startRule();
}

foreach (var listener in listeners)
{
ParseTreeWalker.Default.Walk(listener, tree);
try
{
ParseTreeWalker.Default.Walk(listener, tree);
}
catch (Exception exception)
{
Logger.Error(exception, $"{listener.GetType().Name} threw an exception.");
}
}
return (tree, moduleTokens);
}
Expand Down

0 comments on commit 5573dc6

Please sign in to comment.