Closed idubrov closed 5 years ago
One option is to use a comment marker indicating beginning and end of the generated code instead of relying on item range. Like:
// -- BEGIN GENERATED CODE --
code...
// -- END GENERATED CODE --
Another suggestion is to use another marker attribute:
#[sourcegen::sourcegen(..)]
struct Boo;
#[sourcegen::generated]
impl Boo {
}
And make the toolkit to consume all consecutive items with #[sourcegen::generated]
. Not clear if we should also give them back to the generator (would require changing its API). Initially, I think, it would be fine to only give the "primary" item, but replace all of them.
Fixed via #8
Sometimes it could be beneficial to let the sourcegen to generate multiple items:
However, it is not clear how to detect the end bound of the range to replace?