Skip to content

Conversation

@abgruszecki
Copy link
Contributor

@nicolasstucki I think we should allow defining a "final" callback in TastyInspector that runs after all compilation units are processed. The reason is very simple - this way, users can encode arbitrary operations on the full list of compilation units.

I've found a bunch of uses for that in the doctool and I suspect that external users will quickly need this as well.

This interface allows performing arbitrary operations on all compilation units.
override def run(implicit ctx: Context): Unit =
if !alreadyRan then
val qctx = QuoteContextImpl()
self.finishProcessingCompilationUnits(using qctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if finishProcessingCompilationUnits throws exception? Shound't we use
try self.finishProcessingCompilationUnits(using qctx) finally alreadyRan = true here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is already handled in the code that orchestrates Phase runs, Tasty Inspector will continue even if processCompilationUnit throws an exception and there's no special code for doing that above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point was not to run finishProcessingCompilationUnits twice in such case (there was only finally there without catch)

@abgruszecki abgruszecki merged commit 1ce60bc into scala:master Nov 18, 2020
@abgruszecki abgruszecki deleted the tasty-final-callback branch November 18, 2020 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants