3 ms·
Thanks! How would you do that for a #[cfg(test)] attribute in Rust? (I believe that the true identifier of test code; `mod test {}` is just a convention). I ass
by da39a3ee 3y ago
Thanks! How would you do that for a #[cfg(test)] attribute in Rust? (I believe that the true identifier of test code; `mod test {}` is just a convention). I assume Rust attributes "wrap" the AST node rooted at the node that follows them?
- herrington_d 3y agoYes you can! https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InJ1c3QiLCJxdWVyeSI6IicxMzMnIiwicmV3cml0ZSI6IiRBLmNoYXJzKCkuZW51bWVyYXRlKCkiLCJjb25maWciOiJydWxlOlxuICBwYXR0ZXJuOiBIYXNoTWFwXG4gIG5vdDpcbiAgICBpbnNpZGU6XG4gICAgICBwYXR0ZXJuOiBtb2QgJE0geyAkJCQgfVxuICAgICAgZm9sbG93czpcbiAgICAgICAgcGF0dGVybjogJyNbY2ZnKHRlc3QpXSdcbiAgICAgIHN0b3BCeTogZW5kIiwic291cmNlIjoiZm4gdGVzdCgpIHtcbiAgIEhhc2hNYXA6Om5ldygpOyBcbn1cblxuI1tjZmcodGVzdCldXG5tb2Qgbm90X3Rlc3Qge1xuICAgIGZuIHRlc3QyKCkge1xuICAgICAgICBIYXNoTWFwOjpuZXcoKTtcbiAgICB9XG59XG5cbm1vZCB0ZXN0IHtcbiAgICBmbiB0ZXN0MigpIHtcbiAgICAgICAgSGFzaE1hcDo6bmV3KCk7XG4gICAgfVxufSJ9 https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZ...