Skip to content
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
476 changes: 308 additions & 168 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ multiple_crate_versions = "allow"

[workspace.dependencies]
# External oxc crates from crates.io
oxc_allocator = "0.110"
oxc_ast = "0.110"
oxc_ast_visit = "0.110"
oxc_diagnostics = "0.110"
oxc_napi = "0.110"
oxc_parser = "0.110"
oxc_semantic = "0.110"
oxc_span = "0.110"
oxc_allocator = "0.116"
oxc_ast = "0.116"
oxc_ast_visit = "0.116"
oxc_diagnostics = "0.116"
oxc_napi = "0.116"
oxc_parser = "0.116"
oxc_semantic = "0.116"
oxc_span = "0.116"
oxc_sourcemap = "6.0.1"

# Internal
Expand Down
16 changes: 8 additions & 8 deletions crates/oxc_angular_compiler/src/class_metadata/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn build_decorator_metadata_array<'a>(
let type_expr = match &decorator.expression {
Expression::CallExpression(call) => match &call.callee {
Expression::Identifier(id) => Some(OutputExpression::ReadVar(Box::new_in(
ReadVarExpr { name: id.name, source_span: None },
ReadVarExpr { name: id.name.into(), source_span: None },
allocator,
))),
Expression::StaticMemberExpression(member) => {
Expand All @@ -42,7 +42,7 @@ pub fn build_decorator_metadata_array<'a>(
OutputExpression::ReadProp(Box::new_in(
ReadPropExpr {
receiver: Box::new_in(receiver, allocator),
name: member.property.name,
name: member.property.name.into(),
optional: false,
source_span: None,
},
Expand All @@ -53,7 +53,7 @@ pub fn build_decorator_metadata_array<'a>(
_ => None,
},
Expression::Identifier(id) => Some(OutputExpression::ReadVar(Box::new_in(
ReadVarExpr { name: id.name, source_span: None },
ReadVarExpr { name: id.name.into(), source_span: None },
allocator,
))),
_ => None,
Expand Down Expand Up @@ -370,8 +370,8 @@ fn extract_param_type_name<'a>(param: &FormalParameter<'a>) -> Option<Atom<'a>>
let type_annotation = param.type_annotation.as_ref()?;
match &type_annotation.type_annotation {
TSType::TSTypeReference(type_ref) => match &type_ref.type_name {
TSTypeName::IdentifierReference(id) => Some(id.name),
TSTypeName::QualifiedName(qualified) => Some(qualified.right.name),
TSTypeName::IdentifierReference(id) => Some(id.name.into()),
TSTypeName::QualifiedName(qualified) => Some(qualified.right.name.into()),
TSTypeName::ThisExpression(_) => None,
},
_ => None,
Expand All @@ -394,12 +394,12 @@ fn extract_param_type_expression<'a>(
// Handle simple type references like SomeService
match &type_ref.type_name {
TSTypeName::IdentifierReference(id) => Some(OutputExpression::ReadVar(
Box::new_in(ReadVarExpr { name: id.name, source_span: None }, allocator),
Box::new_in(ReadVarExpr { name: id.name.into(), source_span: None }, allocator),
)),
TSTypeName::QualifiedName(qualified) => {
// Handle qualified names like ns.SomeType
Some(OutputExpression::ReadVar(Box::new_in(
ReadVarExpr { name: qualified.right.name, source_span: None },
ReadVarExpr { name: qualified.right.name.into(), source_span: None },
allocator,
)))
}
Expand Down Expand Up @@ -446,7 +446,7 @@ fn get_decorator_name<'a>(decorator: &Decorator<'a>) -> Option<&'a str> {
/// Get property key name as an Atom.
fn get_property_key_name<'a>(key: &PropertyKey<'a>) -> Option<Atom<'a>> {
match key {
PropertyKey::StaticIdentifier(id) => Some(id.name),
PropertyKey::StaticIdentifier(id) => Some(id.name.into()),
PropertyKey::StringLiteral(lit) => Some(lit.value),
_ => None,
}
Expand Down
25 changes: 13 additions & 12 deletions crates/oxc_angular_compiler/src/component/decorator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn extract_component_metadata<'a>(
import_map: &ImportMap<'a>,
) -> Option<ComponentMetadata<'a>> {
// Get the class name
let class_name = class.id.as_ref()?.name.clone();
let class_name: Atom<'a> = class.id.as_ref()?.name.clone().into();
let class_span = class.span;

// Find the @Component decorator
Expand Down Expand Up @@ -336,7 +336,7 @@ fn is_component_call(callee: &Expression<'_>) -> bool {
/// Get the name of a property key as a string.
fn get_property_key_name<'a>(key: &PropertyKey<'a>) -> Option<Atom<'a>> {
match key {
PropertyKey::StaticIdentifier(id) => Some(id.name.clone()),
PropertyKey::StaticIdentifier(id) => Some(id.name.clone().into()),
PropertyKey::StringLiteral(lit) => Some(lit.value.clone()),
_ => None,
}
Expand Down Expand Up @@ -405,7 +405,7 @@ fn extract_identifier_array<'a>(
for element in &arr.elements {
match element {
ArrayExpressionElement::Identifier(id) => {
result.push(id.name.clone());
result.push(id.name.clone().into());
}
// Handle spread elements, etc. - for now just collect identifiers
_ => {}
Expand Down Expand Up @@ -562,9 +562,10 @@ fn extract_single_host_directive<'a>(
match element {
// Simple identifier: TooltipDirective
ArrayExpressionElement::Identifier(id) => {
let mut meta = HostDirectiveMetadata::new(allocator, id.name.clone());
let name: Atom<'a> = id.name.clone().into();
let mut meta = HostDirectiveMetadata::new(allocator, name.clone());
// Look up the source module from the import map
if let Some(import_info) = import_map.get(&id.name) {
if let Some(import_info) = import_map.get(&name) {
meta.source_module = Some(import_info.source_module.clone());
}
Some(meta)
Expand Down Expand Up @@ -645,7 +646,7 @@ fn extract_single_host_directive<'a>(
fn extract_directive_reference<'a>(expr: &Expression<'a>) -> (Option<Atom<'a>>, bool) {
match expr {
// Simple identifier: ColorDirective
Expression::Identifier(id) => (Some(id.name.clone()), false),
Expression::Identifier(id) => (Some(id.name.clone().into()), false),

// ForwardRef call: forwardRef(() => ColorDirective)
Expression::CallExpression(call) => {
Expand Down Expand Up @@ -692,7 +693,7 @@ fn extract_forward_ref_directive_name<'a>(arg: Option<&Argument<'a>>) -> Option<
body.statements.first()
{
if let Expression::Identifier(id) = &stmt.expression {
return Some(id.name.clone());
return Some(id.name.clone().into());
}
}
None
Expand Down Expand Up @@ -967,11 +968,11 @@ fn extract_param_dependency<'a>(
fn get_decorator_name<'a>(expr: &'a Expression<'a>) -> Option<Atom<'a>> {
match expr {
// @Optional
Expression::Identifier(id) => Some(id.name.clone()),
Expression::Identifier(id) => Some(id.name.clone().into()),
// @Optional()
Expression::CallExpression(call) => {
if let Expression::Identifier(id) = &call.callee {
Some(id.name.clone())
Some(id.name.clone().into())
} else {
None
}
Expand All @@ -983,12 +984,12 @@ fn get_decorator_name<'a>(expr: &'a Expression<'a>) -> Option<Atom<'a>> {
/// Extract the injection token from an @Inject decorator argument.
fn extract_inject_token<'a>(arg: &'a Argument<'a>) -> Option<Atom<'a>> {
match arg {
Argument::Identifier(id) => Some(id.name.clone()),
Argument::Identifier(id) => Some(id.name.clone().into()),
_ => {
// For other expressions, try to get the expression form
let expr = arg.to_expression();
match expr {
Expression::Identifier(id) => Some(id.name.clone()),
Expression::Identifier(id) => Some(id.name.clone().into()),
_ => None,
}
}
Expand All @@ -1005,7 +1006,7 @@ fn extract_param_token<'a>(param: &'a oxc_ast::ast::FormalParameter<'a>) -> Opti
if let oxc_ast::ast::TSType::TSTypeReference(type_ref) = ts_type {
// Get the type name
let type_name = match &type_ref.type_name {
oxc_ast::ast::TSTypeName::IdentifierReference(id) => Some(id.name.clone()),
oxc_ast::ast::TSTypeName::IdentifierReference(id) => Some(id.name.clone().into()),
oxc_ast::ast::TSTypeName::QualifiedName(_)
| oxc_ast::ast::TSTypeName::ThisExpression(_) => {
// Qualified names like Namespace.Type or 'this' type - not valid injection tokens
Expand Down
20 changes: 10 additions & 10 deletions crates/oxc_angular_compiler/src/component/import_elision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ impl<'a> ImportElisionAnalyzer<'a> {
ImportDeclarationSpecifier::ImportSpecifier(spec) => {
// Explicit type-only specifiers (import { type X }) are always elided
if spec.import_kind.is_type() {
type_only_specifiers.insert(spec.local.name.clone());
type_only_specifiers.insert(spec.local.name.clone().into());
continue;
}

let name = &spec.local.name;
let name: Atom<'a> = spec.local.name.clone().into();

// Check if this import has only type references
if Self::is_type_only_import(&spec.local, semantic) {
Expand All @@ -108,7 +108,7 @@ impl<'a> ImportElisionAnalyzer<'a> {
}
}
ImportDeclarationSpecifier::ImportDefaultSpecifier(spec) => {
let name = &spec.local.name;
let name: Atom<'a> = spec.local.name.clone().into();

if Self::is_type_only_import(&spec.local, semantic) {
type_only_specifiers.insert(name.clone());
Expand All @@ -119,7 +119,7 @@ impl<'a> ImportElisionAnalyzer<'a> {
// e.g., `import * as moment from 'moment'` where `moment` is only
// used in type annotations like `moment.Moment`.
if Self::is_type_only_import(&spec.local, semantic) {
type_only_specifiers.insert(spec.local.name.clone());
type_only_specifiers.insert(spec.local.name.clone().into());
}
}
}
Expand Down Expand Up @@ -273,12 +273,12 @@ impl<'a> ImportElisionAnalyzer<'a> {
fn collect_idents_from_expression(expr: &'a Expression<'a>, result: &mut FxHashSet<Atom<'a>>) {
match expr {
Expression::Identifier(id) => {
result.insert(id.name.clone());
result.insert(id.name.clone().into());
}
Expression::StaticMemberExpression(member) => {
// For `RecipientType.To`, collect `RecipientType`
if let Expression::Identifier(id) = &member.object {
result.insert(id.name.clone());
result.insert(id.name.clone().into());
}
}
_ => {}
Expand Down Expand Up @@ -638,7 +638,7 @@ impl<'a> ImportElisionAnalyzer<'a> {
}

/// Check if a specifier name should be elided (removed).
pub fn should_elide(&self, name: &Atom<'a>) -> bool {
pub fn should_elide(&self, name: &str) -> bool {
self.type_only_specifiers.contains(name)
}

Expand Down Expand Up @@ -702,14 +702,14 @@ impl<'a> ImportElisionAnalyzer<'a> {
let local_name = &spec.local.name;

// Skip if already marked as type-only by semantic analysis
if analyzer.type_only_specifiers.contains(local_name) {
if analyzer.type_only_specifiers.contains(local_name.as_str()) {
continue;
}

// Check cross-file: is the export type-only in the source file?
let imported_name = spec.imported.name().as_str();
if cross_file_analyzer.is_type_only_import(source, imported_name, file_path) {
analyzer.type_only_specifiers.insert(local_name.clone());
analyzer.type_only_specifiers.insert(local_name.clone().into());
}
}
}
Expand Down Expand Up @@ -769,7 +769,7 @@ pub fn filter_imports<'a>(
ImportDeclarationSpecifier::ImportDefaultSpecifier(s) => &s.local.name,
ImportDeclarationSpecifier::ImportNamespaceSpecifier(s) => &s.local.name,
};
!analyzer.should_elide(name)
!analyzer.should_elide(name.as_str())
});

if removed.is_empty() && !kept.is_empty() {
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_angular_compiler/src/component/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ pub fn build_import_map<'a>(
// or aliased: `import { AuthService as Auth } from "module"`
// We use the local name as the key
// Named imports CAN be reused with bare name
let local_name = spec.local.name.clone();
let local_name: Atom<'a> = spec.local.name.clone().into();

// Type-only if the declaration is `import type { ... }` or the specifier
// is `import { type X }` (inline type specifier)
Expand All @@ -471,7 +471,7 @@ pub fn build_import_map<'a>(
ImportDeclarationSpecifier::ImportDefaultSpecifier(spec) => {
// Default import: `import DefaultService from "module"`
// Default imports CAN be reused with bare name
let local_name = spec.local.name.clone();
let local_name: Atom<'a> = spec.local.name.clone().into();

// Check if we have a resolved path for this identifier
let source_module = resolved_imports
Expand All @@ -491,7 +491,7 @@ pub fn build_import_map<'a>(
ImportDeclarationSpecifier::ImportNamespaceSpecifier(spec) => {
// Namespace import: `import * as core from "module"`
// Namespace imports CANNOT be reused with bare name for individual symbols
let local_name = spec.local.name.clone();
let local_name: Atom<'a> = spec.local.name.clone().into();

// Check if we have a resolved path for this identifier
let source_module = resolved_imports
Expand Down
16 changes: 8 additions & 8 deletions crates/oxc_angular_compiler/src/directive/decorator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn extract_directive_metadata<'a>(
implicit_standalone: bool,
) -> Option<R3DirectiveMetadata<'a>> {
// Get the class name
let class_name = class.id.as_ref()?.name.clone();
let class_name: Atom<'a> = class.id.as_ref()?.name.clone().into();

// Find the @Directive decorator
let directive_decorator = find_directive_decorator(&class.decorators)?;
Expand Down Expand Up @@ -357,11 +357,11 @@ fn extract_param_dependency<'a>(
fn get_decorator_name_from_expr<'a>(expr: &'a Expression<'a>) -> Option<Atom<'a>> {
match expr {
// @Optional
Expression::Identifier(id) => Some(id.name.clone()),
Expression::Identifier(id) => Some(id.name.clone().into()),
// @Optional()
Expression::CallExpression(call) => {
if let Expression::Identifier(id) = &call.callee {
Some(id.name.clone())
Some(id.name.clone().into())
} else {
None
}
Expand All @@ -388,7 +388,7 @@ fn extract_param_token<'a>(
if let oxc_ast::ast::TSType::TSTypeReference(type_ref) = ts_type {
// Get the type name
let type_name = match &type_ref.type_name {
oxc_ast::ast::TSTypeName::IdentifierReference(id) => id.name.clone(),
oxc_ast::ast::TSTypeName::IdentifierReference(id) => id.name.clone().into(),
oxc_ast::ast::TSTypeName::QualifiedName(_)
| oxc_ast::ast::TSTypeName::ThisExpression(_) => {
// Qualified names like Namespace.Type or 'this' type - not valid injection tokens
Expand Down Expand Up @@ -435,7 +435,7 @@ fn has_ng_on_changes_method(class: &Class<'_>) -> bool {
/// Get the name of a property key as a string.
fn get_property_key_name<'a>(key: &PropertyKey<'a>) -> Option<Atom<'a>> {
match key {
PropertyKey::StaticIdentifier(id) => Some(id.name.clone()),
PropertyKey::StaticIdentifier(id) => Some(id.name.clone().into()),
PropertyKey::StringLiteral(lit) => Some(lit.value.clone()),
_ => None,
}
Expand Down Expand Up @@ -549,7 +549,7 @@ fn extract_single_host_directive<'a>(
match element {
// Simple identifier: TooltipDirective
ArrayExpressionElement::Identifier(id) => Some(R3HostDirectiveMetadata {
directive: OutputAstBuilder::variable(allocator, id.name.clone()),
directive: OutputAstBuilder::variable(allocator, id.name.clone().into()),
is_forward_reference: false,
inputs: Vec::new_in(allocator),
outputs: Vec::new_in(allocator),
Expand Down Expand Up @@ -623,7 +623,7 @@ fn extract_directive_reference<'a>(
match expr {
// Simple identifier: ColorDirective
Expression::Identifier(id) => {
(Some(OutputAstBuilder::variable(allocator, id.name.clone())), false)
(Some(OutputAstBuilder::variable(allocator, id.name.clone().into())), false)
}

// ForwardRef call: forwardRef(() => ColorDirective)
Expand Down Expand Up @@ -663,7 +663,7 @@ fn extract_forward_ref_directive_name<'a>(arg: Option<&Argument<'a>>) -> Option<
body.statements.first()
{
if let Expression::Identifier(id) = &stmt.expression {
return Some(id.name.clone());
return Some(id.name.clone().into());
}
}
None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn find_decorator_by_name<'a>(
/// Handles both identifier keys and string literal keys.
fn get_property_key_name<'a>(key: &PropertyKey<'a>) -> Option<Atom<'a>> {
match key {
PropertyKey::StaticIdentifier(id) => Some(id.name.clone()),
PropertyKey::StaticIdentifier(id) => Some(id.name.clone().into()),
PropertyKey::StringLiteral(lit) => Some(lit.value.clone()),
_ => None,
}
Expand Down
Loading
Loading