To write a compiler plugin, you have to register a callback which will be invoked whenever your plugin needs to do something. If I’m reading the source code correctly, it seems like there’s no way to write a compiler plugin which gets invoked over the whole AST and gets to make any modifications it likes?
The reason that I ask is that I’m trying to write a compiler plugin which selectively disables certain code blocks, and that shouldn’t need the user to explicitly mark which blocks need to be disabled - the whole point is to have the plugin figure it out automatically. But as far as I can tell, the only options are to register a syntax extension, which requires a particular keyword to be used, or to register a procedural macro, which requires a named macro to be invoked. Is there something I’m missing, or is this really impossible?