Skip to content

Commit 6cc21bc

Browse files
committed
refactor(semantic): re-order use statements
1 parent 1b4412f commit 6cc21bc

16 files changed

+62
-43
lines changed

crates/oxc_semantic/src/binder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use std::{borrow::Cow, ptr};
44

55
#[allow(clippy::wildcard_imports)]
6-
use oxc_ast::ast::*;
76
use oxc_ast::{
7+
ast::*,
88
syntax_directed_operations::{BoundNames, IsSimpleParameterList},
99
AstKind,
1010
};

crates/oxc_semantic/src/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use std::{
66
sync::Arc,
77
};
88

9+
use rustc_hash::FxHashMap;
10+
911
#[allow(clippy::wildcard_imports)]
1012
use oxc_ast::{ast::*, AstKind, Trivias, Visit};
1113
use oxc_cfg::{
@@ -15,7 +17,6 @@ use oxc_cfg::{
1517
use oxc_diagnostics::OxcDiagnostic;
1618
use oxc_span::{Atom, CompactStr, SourceType, Span};
1719
use oxc_syntax::{module_record::ModuleRecord, operator::AssignmentOperator};
18-
use rustc_hash::FxHashMap;
1920

2021
use crate::{
2122
binder::Binder,

crates/oxc_semantic/src/checker/javascript.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use phf::{phf_set, Set};
2+
use rustc_hash::FxHashMap;
3+
14
#[allow(clippy::wildcard_imports)]
25
use oxc_ast::{
36
ast::*,
@@ -11,8 +14,6 @@ use oxc_syntax::{
1114
number::NumberBase,
1215
operator::{AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator},
1316
};
14-
use phf::{phf_set, Set};
15-
use rustc_hash::FxHashMap;
1617

1718
use crate::{builder::SemanticBuilder, diagnostics::redeclaration, scope::ScopeFlags, AstNode};
1819

crates/oxc_semantic/src/checker/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
use oxc_ast::{
2+
ast::{DoWhileStatement, ForStatement, WhileStatement},
3+
AstKind,
4+
};
5+
16
mod javascript;
27
mod typescript;
38

49
use javascript as js;
510
pub use javascript::check_module_record;
6-
use oxc_ast::{
7-
ast::{DoWhileStatement, ForStatement, WhileStatement},
8-
AstKind,
9-
};
1011
use typescript as ts;
1112

1213
use crate::{builder::SemanticBuilder, AstNode};

crates/oxc_semantic/src/checker/typescript.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
use std::borrow::Cow;
22

3-
use oxc_ast::syntax_directed_operations::{BoundNames, PropName};
3+
use rustc_hash::FxHashMap;
4+
45
#[allow(clippy::wildcard_imports)]
5-
use oxc_ast::{ast::*, AstKind};
6+
use oxc_ast::{
7+
ast::*,
8+
syntax_directed_operations::{BoundNames, PropName},
9+
AstKind,
10+
};
611
use oxc_diagnostics::OxcDiagnostic;
712
use oxc_span::{Atom, GetSpan, Span};
8-
use rustc_hash::FxHashMap;
913

1014
use crate::{builder::SemanticBuilder, diagnostics::redeclaration};
1115

crates/oxc_semantic/src/class/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ use oxc_ast::{
88
use oxc_span::GetSpan;
99
use oxc_syntax::class::{ClassId, ElementKind};
1010

11+
use crate::{AstNodeId, AstNodes};
12+
1113
use super::{
1214
table::{Element, PrivateIdentifierReference},
1315
ClassTable,
1416
};
15-
use crate::{AstNodeId, AstNodes};
1617

1718
#[derive(Debug, Default)]
1819
pub struct ClassTableBuilder {

crates/oxc_semantic/src/class/table.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
use rustc_hash::FxHashMap;
2+
13
use oxc_index::IndexVec;
24
use oxc_span::{CompactStr, Span};
35
use oxc_syntax::class::{ClassId, ElementId, ElementKind};
4-
use rustc_hash::FxHashMap;
56

67
use crate::node::AstNodeId;
78

crates/oxc_semantic/src/jsdoc/builder.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
use std::collections::BTreeMap;
22

3+
use rustc_hash::FxHashSet;
4+
35
use oxc_ast::{AstKind, Comment, Trivias};
46
use oxc_span::{GetSpan, Span};
5-
use rustc_hash::FxHashSet;
67

7-
use super::parser::JSDoc;
88
use crate::jsdoc::JSDocFinder;
99

10+
use super::parser::JSDoc;
11+
1012
pub struct JSDocBuilder<'a> {
1113
source_text: &'a str,
1214
trivias: Trivias,

crates/oxc_semantic/src/jsdoc/finder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use std::collections::BTreeMap;
22

33
use oxc_span::{GetSpan, Span};
44

5-
use super::parser::JSDoc;
65
use crate::AstNode;
76

7+
use super::parser::JSDoc;
8+
89
#[derive(Debug, Default)]
910
pub struct JSDocFinder<'a> {
1011
/// JSDocs by Span

crates/oxc_semantic/src/jsdoc/parser/jsdoc_tag.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use oxc_span::Span;
22

3+
use crate::jsdoc::parser::utils;
4+
35
use super::jsdoc_parts::{
46
JSDocCommentPart, JSDocTagKindPart, JSDocTagTypeNamePart, JSDocTagTypePart,
57
};
6-
use crate::jsdoc::parser::utils;
78

89
// Initially, I attempted to parse into specific structures such as:
910
// - `@param {type} name comment`: `JSDocParameterTag { type, name, comment }`

crates/oxc_semantic/src/lib.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
//! ```rust
55
#![doc = include_str!("../examples/simple.rs")]
66
//! ```
7+
8+
use std::sync::Arc;
9+
10+
use oxc_ast::{ast::IdentifierReference, AstKind, Trivias};
11+
use oxc_cfg::ControlFlowGraph;
12+
use oxc_span::{GetSpan, SourceType, Span};
13+
pub use oxc_syntax::{
14+
module_record::ModuleRecord,
15+
scope::{ScopeFlags, ScopeId},
16+
symbol::{SymbolFlags, SymbolId},
17+
};
18+
19+
pub mod dot;
20+
pub mod post_transform_checker;
21+
722
mod binder;
823
mod builder;
924
mod checker;
@@ -19,29 +34,15 @@ mod scope;
1934
mod symbol;
2035
mod unresolved_stack;
2136

22-
pub mod dot;
23-
pub mod post_transform_checker;
24-
25-
use std::sync::Arc;
26-
27-
pub use builder::{SemanticBuilder, SemanticBuilderReturn};
28-
use class::ClassTable;
29-
pub use jsdoc::{JSDoc, JSDocFinder, JSDocTag};
30-
pub use node::{AstNode, AstNodeId, AstNodes};
31-
use oxc_ast::{ast::IdentifierReference, AstKind, Trivias};
32-
use oxc_cfg::ControlFlowGraph;
33-
use oxc_span::{GetSpan, SourceType, Span};
34-
pub use oxc_syntax::{
35-
module_record::ModuleRecord,
36-
scope::{ScopeFlags, ScopeId},
37-
symbol::{SymbolFlags, SymbolId},
38-
};
39-
4037
pub use crate::{
38+
builder::{SemanticBuilder, SemanticBuilderReturn},
39+
jsdoc::{JSDoc, JSDocFinder, JSDocTag},
40+
node::{AstNode, AstNodeId, AstNodes},
4141
reference::{Reference, ReferenceFlags, ReferenceId},
4242
scope::ScopeTree,
4343
symbol::{IsGlobalReference, SymbolTable},
4444
};
45+
use class::ClassTable;
4546

4647
/// Semantic analysis of a JavaScript/TypeScript program.
4748
///

crates/oxc_semantic/src/post_transform_checker.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ use std::{
9292
};
9393

9494
use indexmap::IndexMap;
95+
use rustc_hash::FxHasher;
96+
9597
use oxc_allocator::{Allocator, CloneIn};
9698
#[allow(clippy::wildcard_imports)]
9799
use oxc_ast::{ast::*, visit::walk, Visit};
@@ -102,7 +104,6 @@ use oxc_syntax::{
102104
scope::{ScopeFlags, ScopeId},
103105
symbol::SymbolId,
104106
};
105-
use rustc_hash::FxHasher;
106107

107108
use crate::{ScopeTree, SemanticBuilder, SymbolTable};
108109

crates/oxc_semantic/src/reference.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]`
22
#![allow(non_snake_case)]
33

4-
pub use oxc_syntax::reference::{ReferenceFlags, ReferenceId};
54
#[cfg(feature = "serialize")]
65
use serde::Serialize;
76
#[cfg(feature = "serialize")]
87
use tsify::Tsify;
98

9+
pub use oxc_syntax::reference::{ReferenceFlags, ReferenceId};
10+
1011
use crate::{symbol::SymbolId, AstNodeId};
1112

1213
/// Describes where and how a Symbol is used in the AST.

crates/oxc_semantic/src/scope.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::hash::BuildHasherDefault;
22

33
use indexmap::IndexMap;
4+
use rustc_hash::{FxHashMap, FxHasher};
5+
46
use oxc_index::IndexVec;
57
use oxc_span::CompactStr;
68
use oxc_syntax::reference::ReferenceId;
79
pub use oxc_syntax::scope::{ScopeFlags, ScopeId};
8-
use rustc_hash::{FxHashMap, FxHasher};
910

1011
use crate::{symbol::SymbolId, AstNodeId};
1112

crates/oxc_semantic/src/symbol.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#![allow(non_snake_case)] // Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]`
22

3+
#[cfg(feature = "serialize")]
4+
use serde::Serialize;
5+
#[cfg(feature = "serialize")]
6+
use tsify::Tsify;
7+
38
use oxc_ast::ast::{Expression, IdentifierReference};
49
use oxc_index::IndexVec;
510
use oxc_span::{CompactStr, Span};
611
pub use oxc_syntax::{
712
scope::ScopeId,
813
symbol::{RedeclarationId, SymbolFlags, SymbolId},
914
};
10-
#[cfg(feature = "serialize")]
11-
use serde::Serialize;
12-
#[cfg(feature = "serialize")]
13-
use tsify::Tsify;
1415

1516
use crate::{
1617
node::AstNodeId,

crates/oxc_semantic/src/unresolved_stack.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use assert_unchecked::assert_unchecked;
2+
use rustc_hash::FxHashMap;
3+
24
use oxc_span::Atom;
35
use oxc_syntax::reference::ReferenceId;
4-
use rustc_hash::FxHashMap;
56

67
/// The difference with Scope's `UnresolvedReferences` is that this type uses Atom as the key. its clone is very cheap!
78
type TempUnresolvedReferences<'a> = FxHashMap<Atom<'a>, Vec<ReferenceId>>;

0 commit comments

Comments
 (0)