Skip to content

Commit

Permalink
refactor(span)!: export ContentEq trait from root of oxc_span crate
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Feb 3, 2025
1 parent 07c66df commit 64c913b
Show file tree
Hide file tree
Showing 30 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast/comment.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![warn(missing_docs)]
use oxc_allocator::CloneIn;
use oxc_ast_macros::ast;
use oxc_span::{cmp::ContentEq, Span};
use oxc_span::{ContentEq, Span};

/// Indicates a line or block comment.
#[ast]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::cell::Cell;
use oxc_allocator::{Box, CloneIn, GetAddress, Vec};
use oxc_ast_macros::ast;
use oxc_estree::ESTree;
use oxc_span::{cmp::ContentEq, Atom, GetSpan, GetSpanMut, SourceType, Span};
use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, SourceType, Span};
use oxc_syntax::{
operator::{
AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator,
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use oxc_allocator::{Box, CloneIn, GetAddress, Vec};
use oxc_ast_macros::ast;
use oxc_estree::ESTree;
use oxc_span::{cmp::ContentEq, Atom, GetSpan, GetSpanMut, Span};
use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, Span};

use super::{inherit_variants, js::*, literal::*, ts::*};

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use oxc_allocator::{Box, CloneIn};
use oxc_ast_macros::ast;
use oxc_estree::ESTree;
use oxc_regular_expression::ast::Pattern;
use oxc_span::{cmp::ContentEq, Atom, GetSpan, GetSpanMut, Span};
use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, Span};
use oxc_syntax::number::{BigintBase, NumberBase};

/// Boolean literal
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::cell::Cell;
use oxc_allocator::{Box, CloneIn, GetAddress, Vec};
use oxc_ast_macros::ast;
use oxc_estree::ESTree;
use oxc_span::{cmp::ContentEq, Atom, GetSpan, GetSpanMut, Span};
use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, Span};
use oxc_syntax::scope::ScopeId;

use super::{inherit_variants, js::*, literal::*};
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast_impl/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{borrow::Cow, fmt};

use oxc_allocator::CloneIn;
use oxc_regular_expression::ast::Pattern;
use oxc_span::cmp::ContentEq;
use oxc_span::ContentEq;

use crate::ast::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/generated/derive_content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![allow(clippy::match_same_arms)]

use oxc_span::cmp::ContentEq;
use oxc_span::ContentEq;

use crate::ast::comment::*;
use crate::ast::js::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast_macros/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn abs_trait(
} else if ident == "GetAddress" {
(quote!(::oxc_allocator::GetAddress), TokenStream::default())
} else if ident == "ContentEq" {
(quote!(::oxc_span::cmp::ContentEq), TokenStream::default())
(quote!(::oxc_span::ContentEq), TokenStream::default())
} else if ident == "ESTree" {
(quote!(::oxc_estree::ESTree), TokenStream::default())
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_dupe_else_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use oxc_ast::{
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{cmp::ContentEq, GetSpan, Span};
use oxc_span::{ContentEq, GetSpan, Span};
use oxc_syntax::operator::LogicalOperator;

use crate::{context::LintContext, rule::Rule, AstNode};
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_duplicate_case.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use oxc_ast::ast::Expression;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{cmp::ContentEq, GetSpan, Span};
use oxc_span::{ContentEq, GetSpan, Span};

use crate::{context::LintContext, rule::Rule, AstNode};

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_extend_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use oxc_ast::{
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{cmp::ContentEq, CompactStr, GetSpan};
use oxc_span::{CompactStr, ContentEq, GetSpan};

use crate::{context::LintContext, rule::Rule, AstNode};

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_self_compare.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{cmp::ContentEq, GetSpan, Span};
use oxc_span::{ContentEq, GetSpan, Span};

use crate::{context::LintContext, rule::Rule, AstNode};

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_useless_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use oxc_ast::{
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::cmp::ContentEq;
use oxc_span::ContentEq;
use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/prefer_spread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use oxc_ast::{
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{cmp::ContentEq, Span};
use oxc_span::{ContentEq, Span};

use crate::{ast_util::is_method_call, context::LintContext, rule::Rule, AstNode};

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/utils/unicorn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use oxc_ast::{
AstKind,
};
use oxc_semantic::AstNode;
use oxc_span::cmp::ContentEq;
use oxc_span::ContentEq;
use oxc_syntax::operator::LogicalOperator;

pub use self::boolean::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_minifier/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<'a> Ctx<'a, '_> {
/// If two expressions are equal.
/// Special case `undefined` == `void 0`
pub fn expr_eq(self, a: &Expression<'a>, b: &Expression<'a>) -> bool {
use oxc_span::cmp::ContentEq;
use oxc_span::ContentEq;
a.content_eq(b) || (self.is_expression_undefined(a) && self.is_expression_undefined(b))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use oxc_ast::{ast::*, NONE};
use oxc_span::{cmp::ContentEq, GetSpan};
use oxc_span::{ContentEq, GetSpan};
use oxc_syntax::es_target::ESTarget;

use crate::ctx::Ctx;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_minifier/src/peephole/minimize_conditions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use oxc_ast::ast::*;
use oxc_ecmascript::{constant_evaluation::ValueType, ToInt32};
use oxc_span::{cmp::ContentEq, GetSpan};
use oxc_span::{ContentEq, GetSpan};
use oxc_syntax::es_target::ESTarget;

use crate::ctx::Ctx;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_minifier/src/peephole/minimize_statements.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use oxc_allocator::Vec;
use oxc_ast::{ast::*, Visit};
use oxc_ecmascript::side_effects::MayHaveSideEffects;
use oxc_span::{cmp::ContentEq, GetSpan};
use oxc_span::{ContentEq, GetSpan};
use oxc_traverse::Ancestor;

use crate::{ctx::Ctx, keep_var::KeepVar};
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_regular_expression/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use oxc_allocator::{Box, CloneIn, GetAddress, Vec};
use oxc_ast_macros::ast;
use oxc_estree::ESTree;
use oxc_span::{cmp::ContentEq, Atom, GetSpan, Span};
use oxc_span::{Atom, ContentEq, GetSpan, Span};

/// The root of the `PatternParser` result.
#[ast]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![allow(clippy::match_same_arms)]

use oxc_span::cmp::ContentEq;
use oxc_span::ContentEq;

use crate::ast::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_span/src/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use oxc_allocator::{Allocator, CloneIn, FromIn};
#[cfg(feature = "serialize")]
use serde::Serialize;

use crate::{cmp::ContentEq, CompactStr};
use crate::{CompactStr, ContentEq};

/// An inlinable string for oxc_allocator.
///
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#![warn(missing_docs)]

mod atom;
mod cmp;
mod compact_str;
mod source_type;
mod span;

pub mod cmp;

pub use crate::{
atom::Atom,
cmp::ContentEq,
compact_str::{CompactStr, MAX_INLINE_LEN as ATOM_MAX_INLINE_LEN},
source_type::{
Language, LanguageVariant, ModuleKind, SourceType, UnknownExtension, VALID_EXTENSIONS,
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_span/src/source_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use oxc_allocator::{Allocator, CloneIn};
use oxc_ast_macros::ast;
use oxc_estree::ESTree;

use crate::cmp::ContentEq;
use crate::ContentEq;

mod error;
pub use error::UnknownExtension;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_span/src/span/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use super::PointerAlign;
/// ## Comparison
/// [`Span`] has a normal implementation of [`PartialEq`]. If you want to compare two
/// AST nodes without considering their locations (e.g. to see if they have the
/// same content), use [`ContentEq`](crate::cmp::ContentEq) instead.
/// same content), use [`ContentEq`](crate::ContentEq) instead.
///
/// ## Implementation Notes
/// See the [`text-size`](https://docs.rs/text-size) crate for details.
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_syntax/src/generated/derive_content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![allow(clippy::match_same_arms)]

use oxc_span::cmp::ContentEq;
use oxc_span::ContentEq;

use crate::number::*;
use crate::operator::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_syntax/src/number.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(missing_docs)] // fixme
use oxc_allocator::CloneIn;
use oxc_ast_macros::ast;
use oxc_span::cmp::ContentEq;
use oxc_span::ContentEq;

#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_syntax/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use oxc_allocator::CloneIn;
use oxc_ast_macros::ast;
use oxc_estree::ESTree;
use oxc_span::cmp::ContentEq;
use oxc_span::ContentEq;

use crate::precedence::{GetPrecedence, Precedence};

Expand Down
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/derives/content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Derive for DeriveContentEq {
#![allow(clippy::match_same_arms)]

///@@line_break
use oxc_span::cmp::ContentEq;
use oxc_span::ContentEq;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tasks/coverage/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use oxc::{
parser::{ParseOptions, ParserReturn},
regular_expression::{LiteralParser, Options},
semantic::{Semantic, SemanticBuilderReturn},
span::{cmp::ContentEq, SourceType, Span},
span::{ContentEq, SourceType, Span},
transformer::{TransformOptions, TransformerReturn},
CompilerInterface,
};
Expand Down

0 comments on commit 64c913b

Please sign in to comment.