Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(semantic): import flags and ID types from oxc_syntax #7887

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/oxc_semantic/src/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use std::ptr;
use oxc_ast::{ast::*, AstKind};
use oxc_ecmascript::{BoundNames, IsSimpleParameterList};
use oxc_span::{GetSpan, SourceType};

use crate::{
use oxc_syntax::{
scope::{ScopeFlags, ScopeId},
symbol::SymbolFlags,
SemanticBuilder,
};

use crate::SemanticBuilder;

pub(crate) trait Binder<'a> {
#[allow(unused_variables)]
fn bind(&self, builder: &mut SemanticBuilder<'a>) {}
Expand Down
14 changes: 10 additions & 4 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ use oxc_cfg::{
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::{Atom, CompactStr, SourceType, Span};
use oxc_syntax::{
node::{NodeFlags, NodeId},
reference::{ReferenceFlags, ReferenceId},
scope::{ScopeFlags, ScopeId},
symbol::{SymbolFlags, SymbolId},
};
use rustc_hash::FxHashMap;

use crate::{
Expand All @@ -18,11 +24,11 @@ use crate::{
diagnostics::redeclaration,
jsdoc::JSDocBuilder,
label::UnusedLabels,
node::{AstNodes, NodeFlags, NodeId},
reference::{Reference, ReferenceFlags, ReferenceId},
scope::{Bindings, ScopeFlags, ScopeId, ScopeTree},
node::AstNodes,
reference::Reference,
scope::{Bindings, ScopeTree},
stats::Stats,
symbol::{SymbolFlags, SymbolId, SymbolTable},
symbol::SymbolTable,
unresolved_stack::UnresolvedReferencesStack,
JSDocFinder, Semantic,
};
Expand Down
3 changes: 2 additions & 1 deletion crates/oxc_semantic/src/checker/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ use oxc_span::{GetSpan, ModuleKind, Span};
use oxc_syntax::{
number::NumberBase,
operator::{AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator},
scope::ScopeFlags,
};
use phf::{phf_set, Set};
use rustc_hash::FxHashMap;

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

pub fn check_duplicate_class_elements(ctx: &SemanticBuilder<'_>) {
let classes = &ctx.class_table_builder.classes;
Expand Down
7 changes: 4 additions & 3 deletions crates/oxc_semantic/src/class/table.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use oxc_index::IndexVec;
use oxc_span::{CompactStr, Span};
use oxc_syntax::class::{ClassId, ElementId, ElementKind};
use oxc_syntax::{
class::{ClassId, ElementId, ElementKind},
node::NodeId,
};
use rustc_hash::FxHashMap;

use crate::node::NodeId;

#[derive(Debug)]
pub struct Element {
pub name: CompactStr,
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/label.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::NodeId;
use oxc_syntax::node::NodeId;

#[derive(Debug)]
pub struct LabeledScope<'a> {
Expand Down
7 changes: 4 additions & 3 deletions crates/oxc_semantic/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use oxc_ast::AstKind;
use oxc_cfg::BlockNodeId;
use oxc_index::IndexVec;
use oxc_span::GetSpan;
pub use oxc_syntax::node::{NodeFlags, NodeId};

use crate::scope::ScopeId;
use oxc_syntax::{
node::{NodeFlags, NodeId},
scope::ScopeId,
};

/// Semantic node contains all the semantic information about an ast node.
#[derive(Debug, Clone, Copy)]
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_semantic/src/reference.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
pub use oxc_syntax::reference::{ReferenceFlags, ReferenceId};
use oxc_syntax::{node::NodeId, reference::ReferenceFlags, symbol::SymbolId};
#[cfg(feature = "serialize")]
use serde::Serialize;
#[cfg(feature = "serialize")]
use tsify::Tsify;

use crate::{symbol::SymbolId, NodeId};

/// Describes where and how a Symbol is used in the AST.
///
/// References indicate how they are being used using [`ReferenceFlags`]. Refer
Expand Down
10 changes: 6 additions & 4 deletions crates/oxc_semantic/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ use std::mem;
use indexmap::IndexMap;
use oxc_index::IndexVec;
use oxc_span::CompactStr;
use oxc_syntax::reference::ReferenceId;
pub use oxc_syntax::scope::{ScopeFlags, ScopeId};
use oxc_syntax::{
node::NodeId,
reference::ReferenceId,
scope::{ScopeFlags, ScopeId},
symbol::SymbolId,
};
use rustc_hash::{FxBuildHasher, FxHashMap};

use crate::{symbol::SymbolId, NodeId};

type FxIndexMap<K, V> = IndexMap<K, V, FxBuildHasher>;

pub(crate) type Bindings = FxIndexMap<CompactStr, SymbolId>;
Expand Down
9 changes: 4 additions & 5 deletions crates/oxc_semantic/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::mem;
use oxc_ast::ast::{Expression, IdentifierReference};
use oxc_index::IndexVec;
use oxc_span::{CompactStr, Span};
pub use oxc_syntax::{
use oxc_syntax::{
node::NodeId,
reference::ReferenceId,
scope::ScopeId,
symbol::{RedeclarationId, SymbolFlags, SymbolId},
};
Expand All @@ -12,10 +14,7 @@ use serde::Serialize;
#[cfg(feature = "serialize")]
use tsify::Tsify;

use crate::{
node::NodeId,
reference::{Reference, ReferenceId},
};
use crate::reference::Reference;

#[cfg(feature = "serialize")]
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
Expand Down
Loading