Skip to content

Rename #[visited_node] attr to #[ast] #4282

@overlookmotel

Description

@overlookmotel

At present we only have #[visited_node] attrs on types which are visited.

We will also need to add an attribute to all types which are part of AST but are not visited, for:

Currently:

#[visited_node]
enum Expression<'a> { /* ... */ }

I propose:

#[ast(visit)]
enum Expression<'a> { /* ... */ }

or:

#[ast]
#[visit]
enum Expression<'a> { /* ... */ }

Types which are part of AST, but which are not visited would omit the visit part e.g.:

#[ast]
pub enum FunctionType { /* ... */ }

Bikeshedding

We could call the attr something other than #[ast]. I considered #[ast_node] but:

  1. That name will be familiar to some from SWC, and I don't think we should use it because these attrs do something very different - they're no-op markers for codegen, rather than macros generating a huge amount of trait impls and other code.
  2. Some of these types (e.g. FunctionType) are not AST nodes per se.

The common factor between all these types is that they're part of the AST, so #[ast] seems descriptive.

But I'm not at all set on that name, if someone has a better suggestion.

cc @Boshen @rzvxa.

Metadata

Metadata

Assignees

Labels

A-astArea - AST

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions