Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust: rename TypeRef and *Type to *TypeRepr, ty to type_repr, and expand some abbreviations in generated docs #18174

Merged
merged 12 commits into from
Dec 4, 2024
  •  
  •  
  •  
1 change: 1 addition & 0 deletions misc/codegen/generators/qlgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class NoClasses(Error):
"int": "integer",
"var": "variable",
"ref": "reference",
"pat": "pattern",
}

abbreviations.update({f"{k}s": f"{v}s" for k, v in abbreviations.items()})
Expand Down
19 changes: 10 additions & 9 deletions rust/ast-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ fn project_root() -> PathBuf {
}

fn class_name(type_name: &str) -> String {
let name = match type_name {
"BinExpr" => "BinaryExpr",
"ElseBranch" => "Expr",
"Fn" => "Function",
"Literal" => "LiteralExpr",
"Type" => "TypeRef",
_ => type_name,
};
name.to_owned()
match type_name {
"BinExpr" => "BinaryExpr".to_owned(),
"ElseBranch" => "Expr".to_owned(),
"Fn" => "Function".to_owned(),
"Literal" => "LiteralExpr".to_owned(),
_ if type_name.ends_with("Type") => format!("{}Repr", type_name),
_ => type_name.to_owned(),
}
}

fn property_name(type_name: &str, field_name: &str) -> String {
Expand All @@ -34,6 +33,8 @@ fn property_name(type_name: &str, field_name: &str) -> String {
("Path", "segment") => "part",
(_, "then_branch") => "then",
(_, "else_branch") => "else_",
("ArrayType", "ty") => "element_type_repr",
(_, "ty") => "type_repr",
_ => field_name,
};
name.to_owned()
Expand Down
2 changes: 1 addition & 1 deletion rust/extractor/src/generated/.generated.list

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading