refactor: port to oxc#798
Draft
nathanwhit wants to merge 58 commits into
Draft
Conversation
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.
…hrow/while/do-while)
…mentPattern splice), gen_assign_pat
…rty consolidation)
…solidation), object lit, spread, rest params + computed-key handling
…y/update/yield/await/sequence/spread)
…portExpression ParametersRanged
… test library, call_expr_like)
…-clause, import-attribute, export-assignment, namespace-export
…fer/intersection/lit/union/qualified/parenthesized/optional)
…fied/parenthesized + type-ann helpers to Node)
…ator/predicate/query/reference/union)
…dex/method/property) + type-lit + consistent-quotes
…-type qualified name
…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
…on_with_expr_body
…+ Program/TokenAndSpan sweep + JSX whitespace
…, rest/jsx-text matches, token kind checks
…ling (NodeKind:: now 0)
…import + type-node union/intersection checks
…leading_comments (final wrapper view-isms)
…ic) + deno_ast token capture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
needs denoland/deno_ast#331
done by claude + codex