I was trying to create an analyzer plugin to create a lint rule for circular import dependencies.
This turned out to be quite tricky, since a plugin's normal node visitor pattern is to be called for each node (to determine a possible warning/message for it), but this kind of rule depends on the whole package state, and a change to another file can affect the result for the currently visited file.
It's not difficult or slow to find import cycles within a package when run once - but it's not performant to run the same search from scratch for every import node visited. So I investigated caching the search and looking it up for each import node visited instead. But this is not straight-forward, especially cache invalidation becomes hard (upon an import statement being modified or deleted).
I couldn't find answers to the following in the docs, can someone assist?
A. Analyzer processing lifecycle
When are the nodes of a given compilation unit actually revisited? When reprocessing a compilation unit, is it known what has changed, or do I need to determine the delta myself? Is it possible to plug in to this "compilation unit revisit" directly instead of on the individual AST nodes?
B. Internal cycle awareness
The analyzer by nature of resolving the Dart language already has an idea of the referential cycles in the source code, explicitly or implicitly. Is this information more explicitly available to a plugin, in which case identifying circular dependencies might be straight-forward?
Cheers,
/ Christer