Closed bclothier closed 5 years ago
Sounds like CodeMetricsAnalyst
could try/catch its work and wrap any exception inside some CodeMetricsException
(with the original exception as the InnerException
), and then we could catch that in OnStateChanged
(?), log it, and not break the entire parser state.
Wouldn't fix it, but would help segregating state-change handlers' exceptions from the rest of the parse run.
It might be a good idea to wrap the execution of the event handlers in RubberduckParserState.OnStateChanged
into a try catch block and then log and swallow all exceptions there, with the exception of OperationCanceledException
.
I'm almost positive the failing line of code is this one: https://github.com/rubberduck-vba/Rubberduck/blob/next/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs#L44
I suspect what is happening is that a Declaration
is passing the equity test there that shouldn't be. That would prevent the node from being removed from the active tree, and since the context on the Declaration
is the one that is being evaluated against the now current parse tree, the context search fails in the listener.
Ref #4714
Rubberduck version information Version 2.4.0.4532 OS: Microsoft Windows NT 10.0.17763.0, x64 Host Product: Microsoft Office x64 Host Version: 16.0.11231.20174 Host Executable: MSACCESS.EXE
Description After a lengthy session, I managed to arrive to a state where code metrics would not run correctly, throwing an exception. Because the code metrics is run as part of parsing, the exception runs up all the parsing stack, resulting in a parser state of
Unexpected error
To Reproduce Not sure yet. Will update.
Expected behavior Code metrics should not throw exceptions to the parser. Ever. Let it faceplant without pulling down everyone down.
Logfile
Additional context Restarting the program and reparsing worked. This may be due to having had parsing using bad code module. Furthermore, I was changing the name via the properties toolwindows. The parsing starts as soon as I type a letter and get cancelled when I type the next. It's conceivable that while I was renaming, it got confused about what's what and code metrics picks it up. Once it arrives into that state, reparsing does not apparently help; only restarting.