-
Notifications
You must be signed in to change notification settings - Fork 666
feat(rome_analyze): add a codegen command for the analyzer #2646
Conversation
Deploying with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update the CONTRIBUTING.md
file with this new command.
@@ -0,0 +1,108 @@ | |||
use std::fmt::Write; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generate_analyzers.rs
? (plural)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rationale was that this is generating the code for the analyzer (well technically the registry), but isn't touching the code for the analyzers / rules themselves
use quote::{format_ident, quote}; | ||
use xtask::{glue::fs2, project_root}; | ||
|
||
pub fn generate_analyzer() -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn generate_analyzer() -> Result<()> { | |
pub fn generate_analyzers() -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you envision dynamic plugins/rules in the future?
@@ -1,3 +1,4 @@ | |||
mod flip_bin_exp; | |||
//! Generated file, do not edit by hand, see `xtask/codegen` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this file generated
or put into a generated
directory so that it automatically gets "hidden" in reviews. Or add it to the list in the gitattributes
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it's a bit complicated to rename just these files to generated
since they're "index files" in the middle of other, hand-written modules (like the auto-generated mod.rs
files in the formatter for instance). I could rely on a #[path]
attribute to load the rename file but it's probably easier to just add entries in gitattributes
Overall these auto-generated factories are just convenience functions, internally the |
Summary
This PR adds a
cargo codegen analyzer
to automatically generate theanalyzers.rs
andassists.rs
index modules inrome_analyze
as well as thewith_filter
builder onRuleRegistry
(through theimpl_registry_builders
macro), based on a list of analyzer rules generated automatically by listing all the files in theanalyzers
andassists
directories