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
4 changes: 2 additions & 2 deletions apps/oxlint/src-js/generated/type_ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

// Mapping from node type name to node type ID
export const NODE_TYPE_IDS_MAP = new Map([
// Leaf nodes
["DebuggerStatement", 0],
["EmptyStatement", 1],
["Literal", 2],
Expand Down Expand Up @@ -31,7 +30,6 @@ export const NODE_TYPE_IDS_MAP = new Map([
["TSUndefinedKeyword", 24],
["TSUnknownKeyword", 25],
["TSVoidKeyword", 26],
// Non-leaf nodes
["AccessorProperty", 27],
["ArrayExpression", 28],
["ArrayPattern", 29],
Expand Down Expand Up @@ -173,5 +171,7 @@ export const NODE_TYPE_IDS_MAP = new Map([
]);

export const NODE_TYPES_COUNT = 165;

export const LEAF_NODE_TYPES_COUNT = 27;

export const FUNCTION_NODE_TYPE_IDS = [30, 55, 56];
3 changes: 1 addition & 2 deletions napi/parser/src-js/generated/visit/type_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

// Mapping from node type name to node type ID
export const NODE_TYPE_IDS_MAP = new Map([
// Leaf nodes
["DebuggerStatement", 0],
["EmptyStatement", 1],
["Literal", 2],
Expand Down Expand Up @@ -31,7 +30,6 @@ export const NODE_TYPE_IDS_MAP = new Map([
["TSUndefinedKeyword", 24],
["TSUnknownKeyword", 25],
["TSVoidKeyword", 26],
// Non-leaf nodes
["AccessorProperty", 27],
["ArrayExpression", 28],
["ArrayPattern", 29],
Expand Down Expand Up @@ -173,4 +171,5 @@ export const NODE_TYPE_IDS_MAP = new Map([
]);

export const NODE_TYPES_COUNT = 165;

export const LEAF_NODE_TYPES_COUNT = 27;
16 changes: 10 additions & 6 deletions tasks/ast_tools/src/generators/estree_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,19 +413,23 @@ fn generate(codegen: &Codegen) -> Codes {
");

let nodes_count = nodes.len();
function_node_ids.sort_unstable();

#[rustfmt::skip]
write_it!(type_ids_map, "]);

export const NODE_TYPES_COUNT = {nodes_count};
export const LEAF_NODE_TYPES_COUNT = {leaf_nodes_count};");
export const LEAF_NODE_TYPES_COUNT = {leaf_nodes_count};

function_node_ids.sort_unstable();
#[rustfmt::skip]
let type_ids_map_oxlint = format!("
{type_ids_map}
/* IF LINTER */
export const FUNCTION_NODE_TYPE_IDS = {function_node_ids:?};
/* END_IF */
");

// Create 2 type ID map variants for parser and oxlint, by setting `LINTER` const,
// and running through minifier to shake out irrelevant code
let [type_ids_map_parser, type_ids_map_oxlint] = generate_variants!(&type_ids_map, ["LINTER"]);

// Versions of `visitor.d.ts` for parser and Oxlint import ESTree types from different places.
// Oxlint version also allows any arbitrary properties (selectors).
#[rustfmt::skip]
Expand Down Expand Up @@ -486,7 +490,7 @@ fn generate(codegen: &Codegen) -> Codes {
walk_dts_parser,
walk_dts_oxlint,
visitor_keys,
type_ids_map_parser: type_ids_map,
type_ids_map_parser,
type_ids_map_oxlint,
visitor_type_parser,
visitor_type_oxlint,
Expand Down
Loading