mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(ast): add visit_span to Visit and VisitMut (#7816)
Add `Visit::visit_span` and `VisitMut::visit_span` methods, to facilitate #7811. Both are no-ops by default, and marked `#[inline]`, so this produces no performance impact.
This commit is contained in:
parent
d14d360061
commit
8991f33fc7
5 changed files with 416 additions and 5 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -56,7 +56,7 @@ use oxc_estree::ESTree;
|
||||||
///
|
///
|
||||||
/// [`expand`]: Span::expand
|
/// [`expand`]: Span::expand
|
||||||
/// [`shrink`]: Span::shrink
|
/// [`shrink`]: Span::shrink
|
||||||
#[ast]
|
#[ast(visit)]
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[generate_derive(ESTree)]
|
#[generate_derive(ESTree)]
|
||||||
#[non_exhaustive] // Disallow struct expression constructor `Span {}`
|
#[non_exhaustive] // Disallow struct expression constructor `Span {}`
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ use crate::{
|
||||||
|
|
||||||
use super::define_generator;
|
use super::define_generator;
|
||||||
|
|
||||||
|
pub const BLACK_LIST: [&str; 1] = ["Span"];
|
||||||
|
|
||||||
pub struct AstBuilderGenerator;
|
pub struct AstBuilderGenerator;
|
||||||
|
|
||||||
define_generator!(AstBuilderGenerator);
|
define_generator!(AstBuilderGenerator);
|
||||||
|
|
@ -26,7 +28,11 @@ impl Generator for AstBuilderGenerator {
|
||||||
let fns = schema
|
let fns = schema
|
||||||
.defs
|
.defs
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|it| it.is_visitable())
|
.filter(|def| {
|
||||||
|
let is_visitable = def.is_visitable();
|
||||||
|
let is_blacklisted = BLACK_LIST.contains(&def.name());
|
||||||
|
is_visitable && !is_blacklisted
|
||||||
|
})
|
||||||
.map(|it| generate_builder_fn(it, schema))
|
.map(|it| generate_builder_fn(it, schema))
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ pub struct AstKindGenerator;
|
||||||
|
|
||||||
define_generator!(AstKindGenerator);
|
define_generator!(AstKindGenerator);
|
||||||
|
|
||||||
pub const BLACK_LIST: [&str; 61] = [
|
pub const BLACK_LIST: [&str; 62] = [
|
||||||
|
"Span",
|
||||||
"Expression",
|
"Expression",
|
||||||
"ObjectPropertyKind",
|
"ObjectPropertyKind",
|
||||||
"TemplateElement",
|
"TemplateElement",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue