Skip to content

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

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

Merged
merged 12 commits into from
Dec 4, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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
21 changes: 11 additions & 10 deletions rust/ast-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ 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",
"ArrayExpr" => "ArrayExprInternal",
_ => type_name,
};
name.to_owned()
match type_name {
"BinExpr" => "BinaryExpr".to_owned(),
"ElseBranch" => "Expr".to_owned(),
"Fn" => "Function".to_owned(),
"Literal" => "LiteralExpr".to_owned(),
"ArrayExpr" => "ArrayExprInternal".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 @@ -35,6 +34,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