mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 12:51:57 +00:00
This PR renames the `oxc_ast_codegen` crate to `oxc_ast_tools`, It improves the readability and organization of the codebase by giving the crate a name that better reflects its purpose and contents. It also improves the error message in CI.
38 lines
689 B
Rust
38 lines
689 B
Rust
use syn::parse_quote;
|
|
|
|
use super::{
|
|
defs::{EnumDef, StructDef, TypeDef},
|
|
with_either,
|
|
};
|
|
|
|
pub trait GetGenerics {
|
|
fn has_lifetime(&self) -> bool {
|
|
false
|
|
}
|
|
|
|
fn generics(&self) -> Option<syn::Generics> {
|
|
if self.has_lifetime() {
|
|
Some(parse_quote!(<'a>))
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
}
|
|
|
|
impl GetGenerics for TypeDef {
|
|
fn has_lifetime(&self) -> bool {
|
|
with_either!(self, it => it.has_lifetime())
|
|
}
|
|
}
|
|
|
|
impl GetGenerics for StructDef {
|
|
fn has_lifetime(&self) -> bool {
|
|
self.has_lifetime
|
|
}
|
|
}
|
|
|
|
impl GetGenerics for EnumDef {
|
|
fn has_lifetime(&self) -> bool {
|
|
self.has_lifetime
|
|
}
|
|
}
|