Skip to content

Commit

Permalink
style(ast_tools): reorder imports (#6904)
Browse files Browse the repository at this point in the history
Pure refactor. Re-order imports for clarity.
  • Loading branch information
overlookmotel committed Oct 25, 2024
1 parent 45333bc commit 6e68c93
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 17 deletions.
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/derives/clone_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/derives/content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/derives/content_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/derives/estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -12,6 +11,8 @@ use crate::{
},
};

use super::{define_derive, Derive};

pub struct DeriveESTree;

define_derive!(DeriveESTree);
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/derives/get_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/generators/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -11,6 +10,8 @@ use crate::{
Generator,
};

use super::define_generator;

pub struct AssertLayouts;

define_generator!(AssertLayouts);
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/generators/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -19,6 +18,8 @@ use crate::{
Generator,
};

use super::define_generator;

pub struct AstBuilderGenerator;

define_generator!(AstBuilderGenerator);
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/generators/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ 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},
schema::{GetIdent, ToType},
Generator,
};

use super::define_generator;

pub struct AstKindGenerator;

define_generator!(AstKindGenerator);
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/generators/typescript.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use convert_case::{Case, Casing};
use itertools::Itertools;

use super::define_generator;
use crate::{
codegen::LateCtx,
output::{output_path, Output},
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/generators/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,6 +17,8 @@ use crate::{
Generator,
};

use super::define_generator;

pub struct VisitGenerator;

define_generator!(VisitGenerator);
Expand Down
1 change: 1 addition & 0 deletions tasks/ast_tools/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(clippy::disallowed_methods)]

use std::{cell::RefCell, io::Read, path::PathBuf, rc::Rc};

use bpaf::{Bpaf, Parser};
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/passes/calc_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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.");
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/passes/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/rust_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/schema/defs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use serde::Serialize;
use syn::Ident;

use super::{with_either, TypeName};
use crate::{
markers::{
DeriveAttributes, ESTreeEnumAttribute, ESTreeStructAttribute, ScopeAttribute, ScopeMarkers,
Expand All @@ -11,6 +10,8 @@ use crate::{
TypeId,
};

use super::{with_either, TypeName};

#[derive(Debug, Serialize)]
#[serde(untagged)]
pub enum TypeDef {
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/schema/get_ident.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 4 additions & 2 deletions tasks/ast_tools/src/schema/serialize.rs
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down

0 comments on commit 6e68c93

Please sign in to comment.