style(ast_tools): reorder imports (#6904)

Pure refactor. Re-order imports for clarity.
This commit is contained in:
overlookmotel 2024-10-25 21:23:28 +00:00
parent 45333bc8d2
commit 6e68c9398b
17 changed files with 35 additions and 17 deletions

View file

@ -3,13 +3,14 @@ use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use syn::Ident;
use super::{define_derive, Derive};
use crate::{
codegen::LateCtx,
markers::CloneInAttribute,
schema::{EnumDef, GetIdent, StructDef, TypeDef},
};
use super::{define_derive, Derive};
pub struct DeriveCloneIn;
define_derive!(DeriveCloneIn);

View file

@ -2,13 +2,14 @@ use itertools::Itertools;
use proc_macro2::TokenStream;
use quote::quote;
use super::{define_derive, Derive};
use crate::{
codegen::LateCtx,
schema::{EnumDef, GetGenerics, StructDef, ToType, TypeDef},
util::ToIdent,
};
use super::{define_derive, Derive};
pub struct DeriveContentEq;
define_derive!(DeriveContentEq);

View file

@ -2,13 +2,14 @@ use itertools::Itertools;
use proc_macro2::TokenStream;
use quote::quote;
use super::{define_derive, Derive};
use crate::{
codegen::LateCtx,
schema::{EnumDef, GetGenerics, StructDef, ToType, TypeDef},
util::ToIdent,
};
use super::{define_derive, Derive};
pub struct DeriveContentHash;
define_derive!(DeriveContentHash);

View file

@ -2,7 +2,6 @@ use convert_case::{Case, Casing};
use proc_macro2::TokenStream;
use quote::quote;
use super::{define_derive, Derive};
use crate::{
codegen::LateCtx,
markers::ESTreeStructAttribute,
@ -12,6 +11,8 @@ use crate::{
},
};
use super::{define_derive, Derive};
pub struct DeriveESTree;
define_derive!(DeriveESTree);

View file

@ -2,13 +2,14 @@ use proc_macro2::TokenStream;
use quote::quote;
use syn::Ident;
use super::{define_derive, Derive};
use crate::{
codegen::LateCtx,
schema::{EnumDef, GetGenerics, StructDef, ToType, TypeDef},
util::{ToIdent, TypeWrapper},
};
use super::{define_derive, Derive};
pub struct DeriveGetSpan;
define_derive!(DeriveGetSpan);

View file

@ -2,7 +2,6 @@ use proc_macro2::TokenStream;
use quote::quote;
use syn::Type;
use super::define_generator;
use crate::{
codegen::LateCtx,
output::{output_path, Output},
@ -11,6 +10,8 @@ use crate::{
Generator,
};
use super::define_generator;
pub struct AssertLayouts;
define_generator!(AssertLayouts);

View file

@ -8,7 +8,6 @@ use quote::{format_ident, quote, ToTokens};
use rustc_hash::FxHashMap;
use syn::{parse_quote, Ident, Type};
use super::define_generator;
use crate::{
codegen::LateCtx,
output::{output_path, Output},
@ -19,6 +18,8 @@ use crate::{
Generator,
};
use super::define_generator;
pub struct AstBuilderGenerator;
define_generator!(AstBuilderGenerator);

View file

@ -3,7 +3,6 @@ use itertools::Itertools;
use quote::{format_ident, quote};
use syn::{parse_quote, Arm, ImplItemFn, Variant};
use super::define_generator;
use crate::{
codegen::LateCtx,
output::{output_path, Output},
@ -11,6 +10,8 @@ use crate::{
Generator,
};
use super::define_generator;
pub struct AstKindGenerator;
define_generator!(AstKindGenerator);

View file

@ -1,7 +1,6 @@
use convert_case::{Case, Casing};
use itertools::Itertools;
use super::define_generator;
use crate::{
codegen::LateCtx,
output::{output_path, Output},
@ -12,6 +11,8 @@ use crate::{
Generator,
};
use super::define_generator;
const CUSTOM_TYPESCRIPT: &str = include_str!("../../../../crates/oxc_ast/src/ast/types.d.ts");
pub struct TypescriptGenerator;

View file

@ -7,7 +7,6 @@ use quote::{format_ident, quote, ToTokens};
use rustc_hash::FxHashMap;
use syn::{parse_quote, Ident};
use super::define_generator;
use crate::{
codegen::LateCtx,
generators::ast_kind::BLACK_LIST as KIND_BLACK_LIST,
@ -18,6 +17,8 @@ use crate::{
Generator,
};
use super::define_generator;
pub struct VisitGenerator;
define_generator!(VisitGenerator);

View file

@ -1,4 +1,5 @@
#![allow(clippy::disallowed_methods)]
use std::{cell::RefCell, io::Read, path::PathBuf, rc::Rc};
use bpaf::{Bpaf, Parser};

View file

@ -6,7 +6,6 @@ use quote::ToTokens;
use rustc_hash::FxHashMap;
use syn::Type;
use super::{define_pass, Pass};
use crate::{
codegen::EarlyCtx,
layout::{KnownLayout, Layout},
@ -15,6 +14,8 @@ use crate::{
Result,
};
use super::{define_pass, Pass};
/// We use compiler to infer 64bit type layouts.
#[cfg(not(target_pointer_width = "64"))]
compile_error!("This module only supports 64bit architectures.");

View file

@ -2,9 +2,10 @@ use std::borrow::Cow;
use syn::parse_quote;
use super::{define_pass, AstType, Pass, Result};
use crate::{codegen::EarlyCtx, rust_ast::Inherit, util::NormalizeError};
use super::{define_pass, AstType, Pass, Result};
pub trait Unresolved {
fn unresolved(&self) -> bool;

View file

@ -9,10 +9,11 @@ use syn::{
Variant, Visibility,
};
use super::{parse_file, Itertools, PathBuf, Rc, Read, RefCell, Result};
use crate::{
layout::Layout,
parse_file,
util::{unexpanded_macro_err, NormalizeError},
Itertools, PathBuf, Rc, Read, RefCell, Result,
};
pub type AstRef = Rc<RefCell<AstType>>;

View file

@ -1,7 +1,6 @@
use serde::Serialize;
use syn::Ident;
use super::{with_either, TypeName};
use crate::{
markers::{
DeriveAttributes, ESTreeEnumAttribute, ESTreeStructAttribute, ScopeAttribute, ScopeMarkers,
@ -11,6 +10,8 @@ use crate::{
TypeId,
};
use super::{with_either, TypeName};
#[derive(Debug, Serialize)]
#[serde(untagged)]
pub enum TypeDef {

View file

@ -1,10 +1,11 @@
use syn::Ident;
use crate::util::ToIdent;
use super::{
defs::{EnumDef, StructDef, TypeDef},
with_either,
};
use crate::util::ToIdent;
pub trait GetIdent {
fn ident(&self) -> Ident;

View file

@ -1,7 +1,9 @@
use super::{EnumDef, StructDef, VariantDef};
use crate::{markers::ESTreeStructAttribute, schema::GetIdent};
use convert_case::{Case, Casing};
use crate::{markers::ESTreeStructAttribute, schema::GetIdent};
use super::{EnumDef, StructDef, VariantDef};
pub fn enum_variant_name(var: &VariantDef, enm: &EnumDef) -> String {
match var.markers.derive_attributes.estree.rename.as_ref() {
Some(rename) => rename.to_string(),