mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-08 09:30:27 +00:00
Remove customizable reference enum names (#15647)
The AST generator creates a reference enum for each syntax group — an enum where each variant contains a reference to the relevant syntax node. Previously you could customize the name of the reference enum for a group — primarily because there was an existing `ExpressionRef` type that wouldn't have lined up with the auto-derived name `ExprRef`. This follow-up PR is a simple search/replace to switch over to the auto-derived name, so that we can remove this customization point.
This commit is contained in:
parent
fa546b20a6
commit
ef85c682bd
11 changed files with 223 additions and 231 deletions
|
@ -68,7 +68,6 @@ class Group:
|
|||
name: str
|
||||
nodes: list[Node]
|
||||
owned_enum_ty: str
|
||||
ref_enum_ty: str
|
||||
|
||||
add_suffix_to_is_methods: bool
|
||||
anynode_is_label: str
|
||||
|
@ -77,7 +76,7 @@ class Group:
|
|||
def __init__(self, group_name: str, group: dict[str, Any]) -> None:
|
||||
self.name = group_name
|
||||
self.owned_enum_ty = group_name
|
||||
self.ref_enum_ty = group.get("ref_enum_ty", group_name + "Ref")
|
||||
self.ref_enum_ty = group_name + "Ref"
|
||||
self.add_suffix_to_is_methods = group.get("add_suffix_to_is_methods", False)
|
||||
self.anynode_is_label = group.get("anynode_is_label", to_snake_case(group_name))
|
||||
self.rustdoc = group.get("rustdoc")
|
||||
|
@ -223,7 +222,6 @@ def write_ref_enum(out: list[str], ast: Ast) -> None:
|
|||
- `impl Ranged for TypeParamRef<'_>`
|
||||
- `fn TypeParamRef::is_type_var() -> bool`
|
||||
|
||||
The name of the enum can be customized via the `ref_enum_ty` group option.
|
||||
The name of each variant can be customized via the `variant` node option. If
|
||||
the `add_suffix_to_is_methods` group option is true, then the `is_type_var`
|
||||
method will be named `is_type_var_type_param`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue