refactor(semantic): re-order use statements (#5712)

Pure refactor. Re-order `use` statements in `oxc_semantic` to follow this order:

1. `std`
2. External crates.
3. `oxc_*` crates.
4. Local crate.
5. `super`
6. `mod`

This is intended to be in order from "furthest above" to "furthest below".
This commit is contained in:
overlookmotel 2024-09-11 20:41:49 +00:00
parent ac6203c891
commit e02621d2d1
16 changed files with 62 additions and 43 deletions

View file

@ -3,8 +3,8 @@
use std::{borrow::Cow, ptr};
#[allow(clippy::wildcard_imports)]
use oxc_ast::ast::*;
use oxc_ast::{
ast::*,
syntax_directed_operations::{BoundNames, IsSimpleParameterList},
AstKind,
};

View file

@ -6,6 +6,8 @@ use std::{
sync::Arc,
};
use rustc_hash::FxHashMap;
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, AstKind, Trivias, Visit};
use oxc_cfg::{
@ -15,7 +17,6 @@ use oxc_cfg::{
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::{Atom, CompactStr, SourceType, Span};
use oxc_syntax::{module_record::ModuleRecord, operator::AssignmentOperator};
use rustc_hash::FxHashMap;
use crate::{
binder::Binder,

View file

@ -1,3 +1,6 @@
use phf::{phf_set, Set};
use rustc_hash::FxHashMap;
#[allow(clippy::wildcard_imports)]
use oxc_ast::{
ast::*,
@ -11,8 +14,6 @@ use oxc_syntax::{
number::NumberBase,
operator::{AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator},
};
use phf::{phf_set, Set};
use rustc_hash::FxHashMap;
use crate::{builder::SemanticBuilder, diagnostics::redeclaration, scope::ScopeFlags, AstNode};

View file

@ -1,12 +1,13 @@
use oxc_ast::{
ast::{DoWhileStatement, ForStatement, WhileStatement},
AstKind,
};
mod javascript;
mod typescript;
use javascript as js;
pub use javascript::check_module_record;
use oxc_ast::{
ast::{DoWhileStatement, ForStatement, WhileStatement},
AstKind,
};
use typescript as ts;
use crate::{builder::SemanticBuilder, AstNode};

View file

@ -1,11 +1,15 @@
use std::borrow::Cow;
use oxc_ast::syntax_directed_operations::{BoundNames, PropName};
use rustc_hash::FxHashMap;
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, AstKind};
use oxc_ast::{
ast::*,
syntax_directed_operations::{BoundNames, PropName},
AstKind,
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::{Atom, GetSpan, Span};
use rustc_hash::FxHashMap;
use crate::{builder::SemanticBuilder, diagnostics::redeclaration};

View file

@ -8,11 +8,12 @@ use oxc_ast::{
use oxc_span::GetSpan;
use oxc_syntax::class::{ClassId, ElementKind};
use crate::{AstNodeId, AstNodes};
use super::{
table::{Element, PrivateIdentifierReference},
ClassTable,
};
use crate::{AstNodeId, AstNodes};
#[derive(Debug, Default)]
pub struct ClassTableBuilder {

View file

@ -1,7 +1,8 @@
use rustc_hash::FxHashMap;
use oxc_index::IndexVec;
use oxc_span::{CompactStr, Span};
use oxc_syntax::class::{ClassId, ElementId, ElementKind};
use rustc_hash::FxHashMap;
use crate::node::AstNodeId;

View file

@ -1,11 +1,13 @@
use std::collections::BTreeMap;
use rustc_hash::FxHashSet;
use oxc_ast::{AstKind, Comment, Trivias};
use oxc_span::{GetSpan, Span};
use rustc_hash::FxHashSet;
use crate::jsdoc::JSDocFinder;
use super::parser::JSDoc;
use crate::jsdoc::JSDocFinder;
pub struct JSDocBuilder<'a> {
source_text: &'a str,

View file

@ -2,9 +2,10 @@ use std::collections::BTreeMap;
use oxc_span::{GetSpan, Span};
use super::parser::JSDoc;
use crate::AstNode;
use super::parser::JSDoc;
#[derive(Debug, Default)]
pub struct JSDocFinder<'a> {
/// JSDocs by Span

View file

@ -1,9 +1,10 @@
use oxc_span::Span;
use crate::jsdoc::parser::utils;
use super::jsdoc_parts::{
JSDocCommentPart, JSDocTagKindPart, JSDocTagTypeNamePart, JSDocTagTypePart,
};
use crate::jsdoc::parser::utils;
// Initially, I attempted to parse into specific structures such as:
// - `@param {type} name comment`: `JSDocParameterTag { type, name, comment }`

View file

@ -4,6 +4,21 @@
//! ```rust
#![doc = include_str!("../examples/simple.rs")]
//! ```
use std::sync::Arc;
use oxc_ast::{ast::IdentifierReference, AstKind, Trivias};
use oxc_cfg::ControlFlowGraph;
use oxc_span::{GetSpan, SourceType, Span};
pub use oxc_syntax::{
module_record::ModuleRecord,
scope::{ScopeFlags, ScopeId},
symbol::{SymbolFlags, SymbolId},
};
pub mod dot;
pub mod post_transform_checker;
mod binder;
mod builder;
mod checker;
@ -19,29 +34,15 @@ mod scope;
mod symbol;
mod unresolved_stack;
pub mod dot;
pub mod post_transform_checker;
use std::sync::Arc;
pub use builder::{SemanticBuilder, SemanticBuilderReturn};
use class::ClassTable;
pub use jsdoc::{JSDoc, JSDocFinder, JSDocTag};
pub use node::{AstNode, AstNodeId, AstNodes};
use oxc_ast::{ast::IdentifierReference, AstKind, Trivias};
use oxc_cfg::ControlFlowGraph;
use oxc_span::{GetSpan, SourceType, Span};
pub use oxc_syntax::{
module_record::ModuleRecord,
scope::{ScopeFlags, ScopeId},
symbol::{SymbolFlags, SymbolId},
};
pub use crate::{
builder::{SemanticBuilder, SemanticBuilderReturn},
jsdoc::{JSDoc, JSDocFinder, JSDocTag},
node::{AstNode, AstNodeId, AstNodes},
reference::{Reference, ReferenceFlags, ReferenceId},
scope::ScopeTree,
symbol::{IsGlobalReference, SymbolTable},
};
use class::ClassTable;
/// Semantic analysis of a JavaScript/TypeScript program.
///

View file

@ -92,6 +92,8 @@ use std::{
};
use indexmap::IndexMap;
use rustc_hash::FxHasher;
use oxc_allocator::{Allocator, CloneIn};
#[allow(clippy::wildcard_imports)]
use oxc_ast::{ast::*, visit::walk, Visit};
@ -102,7 +104,6 @@ use oxc_syntax::{
scope::{ScopeFlags, ScopeId},
symbol::SymbolId,
};
use rustc_hash::FxHasher;
use crate::{ScopeTree, SemanticBuilder, SymbolTable};

View file

@ -1,12 +1,13 @@
// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]`
#![allow(non_snake_case)]
pub use oxc_syntax::reference::{ReferenceFlags, ReferenceId};
#[cfg(feature = "serialize")]
use serde::Serialize;
#[cfg(feature = "serialize")]
use tsify::Tsify;
pub use oxc_syntax::reference::{ReferenceFlags, ReferenceId};
use crate::{symbol::SymbolId, AstNodeId};
/// Describes where and how a Symbol is used in the AST.

View file

@ -1,11 +1,12 @@
use std::hash::BuildHasherDefault;
use indexmap::IndexMap;
use rustc_hash::{FxHashMap, FxHasher};
use oxc_index::IndexVec;
use oxc_span::CompactStr;
use oxc_syntax::reference::ReferenceId;
pub use oxc_syntax::scope::{ScopeFlags, ScopeId};
use rustc_hash::{FxHashMap, FxHasher};
use crate::{symbol::SymbolId, AstNodeId};

View file

@ -1,5 +1,10 @@
#![allow(non_snake_case)] // Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]`
#[cfg(feature = "serialize")]
use serde::Serialize;
#[cfg(feature = "serialize")]
use tsify::Tsify;
use oxc_ast::ast::{Expression, IdentifierReference};
use oxc_index::IndexVec;
use oxc_span::{CompactStr, Span};
@ -7,10 +12,6 @@ pub use oxc_syntax::{
scope::ScopeId,
symbol::{RedeclarationId, SymbolFlags, SymbolId},
};
#[cfg(feature = "serialize")]
use serde::Serialize;
#[cfg(feature = "serialize")]
use tsify::Tsify;
use crate::{
node::AstNodeId,

View file

@ -1,7 +1,8 @@
use assert_unchecked::assert_unchecked;
use rustc_hash::FxHashMap;
use oxc_span::Atom;
use oxc_syntax::reference::ReferenceId;
use rustc_hash::FxHashMap;
/// The difference with Scope's `UnresolvedReferences` is that this type uses Atom as the key. its clone is very cheap!
type TempUnresolvedReferences<'a> = FxHashMap<Atom<'a>, Vec<ReferenceId>>;