Skip to content

refactor: port to oxc#798

Draft
nathanwhit wants to merge 58 commits into
dprint:mainfrom
nathanwhit:oxc-port
Draft

refactor: port to oxc#798
nathanwhit wants to merge 58 commits into
dprint:mainfrom
nathanwhit:oxc-port

Conversation

@nathanwhit
Copy link
Copy Markdown

@nathanwhit nathanwhit commented Jun 3, 2026

needs denoland/deno_ast#331

done by claude + codex

nathanwhit added 30 commits June 2, 2026 17:07
Begin the SWC->OXC port. Switch deno_ast to the oxc-port branch (path dep)
and bump the toolchain to 1.96.

- swc.rs: parse on parse_program + Allocator; rework diagnostics onto oxc
  ParseDiagnostic (block formatting on any diagnostic). SWC-message exact
  tests #[ignore]d pending oxc messages.
- format_text.rs: create the Allocator in format_text; thread 'a through
  format_parsed_source/inner_format/trace_file/generate.
- generation/oxc_helpers.rs: new foundation replacing the deno_ast::view
  layer (ProgramInfo, SourceRanged/PosExt/CommentExt/TokenExt, CommentsIterator,
  on-the-fly comment attachment, Node=AstKind).
- tokens.rs/comments.rs/context.rs: ported onto the foundation.
- generation/mod.rs: transitional - generate() is a stub so the crate stays
  green while the rest of the generation layer is rewritten.
- extensions.rs: BinaryOpExtensions onto oxc BinaryOperator (logical ops are a
  separate enum in oxc, so is_logical is always false here).
- helpers.rs: contains_line_or_multiline_comment via ProgramInfo comment
  lookups; is_text_valid_identifier via oxc_syntax identifier helpers.
- sorting/mod.rs: get_comparison_nodes onto AstKind::{ImportSpecifier,
  ExportSpecifier,ImportDeclaration,ExportNamedDeclaration,ExportAllDeclaration};
  aliasing detected via differing imported/local (local/exported) spans;
  type-only via import_kind/export_kind == ImportOrExportKind::Type.
- module_specifiers.rs unchanged (pure string logic).
Port comment/line helpers, JSX space-expr detection, is_test_library_call_expr
(callee is now an Expression; member access via StaticMemberExpression), and
is_expr_stmt_or_body_with_single_expr_stmt onto oxc. get_siblings_between (uses
view-only parent().children()/child_index()) is stubbed with todo!() pending a
rework that takes the parent's concrete child collection (JSX only).
- to_node.rs: expr_to_node (oxc from_expression), stmt_to_node, ts_type_to_node
  (Node<-Statement/TSType) - the recursion infra replacing the view layer's
  .into().
- generate_types.rs: RangedExtensions, TypeParamNode (parent via context),
  InnerRanged (BlockStatement/ObjectExpression/ObjectPattern), NodeExtensions::
  get_type_parameters, ParametersRanged on Function/Arrow/Call/New/TS-signatures,
  CallOrOptCallExpr as a newtype over &CallExpression.
- flatten_curried_arrows: oxc arrow body via get_expression(); =>/Kind::Arrow.
- flatten_assign_expr: AssignmentExpression (left is AssignmentTarget ->
  assign_target_to_node; operator == AssignmentOperator::Assign).
- flatten_binary_expr: BinaryLikeExpr/BinaryLikeOp unify oxc's split
  BinaryExpression/LogicalExpression for the flattening logic.
- flatten_member_like_expr: member split (Static/Computed/PrivateField),
  optional via .optional flag, ChainExpression, MetaProperty.
- add assign_target_to_node converter.

Entire support layer now compiles; only generate.rs (stub) remains.
…stKind

- imports -> oxc; generate() builds ProgramInfo + AstKind::Program (no with_view).
- gen_node_with_inner_gen: node.kind() checks -> matches!(AstKind), node.parent()
  -> context.current_node after pop.
- gen_node_inner dispatch rewritten over AstKind: Module/Script->Program,
  Bin->Binary/Logical (BinaryLikeExpr), member split, CallExpression+optional,
  ChainExpression, MethodDefinition/ObjectProperty fan-out, keyword types grouped.
- generate.rs still disabled in mod.rs (stub) until the ~270 gen_* fns are
  ported; crate stays green.
Port gen_private_name, gen_identifier, gen_ident_name, gen_binding_identifier
(lean - type/optional/definite relocate to BindingPattern/VariableDeclarator/
FormalParameter callers in oxc), and the literal fns (BooleanLiteral.value field,
RegExpLiteral via text_fast, oxc type renames). gen_string_literal JSX parent
check via context.parent(). Still disabled; ~260 gen_* fns remain.
…solidation), object lit, spread, rest params + computed-key handling
…-clause, import-attribute, export-assignment, namespace-export
nathanwhit added 28 commits June 2, 2026 17:07
…fer/intersection/lit/union/qualified/parenthesized/optional)
…fied/parenthesized + type-ann helpers to Node)
…dex/method/property) + type-lit + consistent-quotes
…t/attr/spread/member/namespaced/expr-container/text) + converters + ancestors_of
…has_ignore_comment/is_ignore_jsx_expr_container/jsx children comments)
…nts/interface-heritage; remove obsolete getter/setter sigs + gen_module/gen_script
…+ Program/TokenAndSpan sweep + JSX whitespace
…import + type-node union/intersection checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant