-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add Expr, Stmt, Pat to schema.py #17390
Conversation
9e3cd27
to
eeaafcb
Compare
Looks amazing! 🎉 Having |
eeaafcb
to
679d81a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small naming nits and one probable typo, and some questions from my side, but this looks great as a starting point, thanks!
We should not forget when we do start extracting things to add some code snippets as examples to class docstrings. That helps us along the way, the QL writer then, and if we don't do it from the start we risk never really catching up
rust/schema.py
Outdated
# }, | ||
|
||
|
||
class Async(Block): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would maybe AsyncBlock
be more informative on the QL side?
class Call(Expr): | ||
callee: Expr | ||
args: list[Expr] | ||
is_assignee_expr: predicate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh, this is making me curious 🙂
# }, | ||
|
||
|
||
class Yeet(Expr): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the curious, this is an experimental feature that we're not probably going to really encounter https://doc.rust-lang.org/stable/unstable-book/language-features/yeet-expr.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should just remove it for now? Given that it's highly experimental and placeholder syntax that is going to change in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. I could remove the class and translate yeet
to MissingExpr
in the extractor.
class BinaryOp(Expr): | ||
lhs: Expr | ||
rhs: Expr | ||
op: optional[string] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of curiosity, do you know what does op: None
mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, I am equally curious. Just haven't found the time to run an example expression through the pretty_print function.
This PR adds classes for expressions, statements, and patterns to the schema. The code is most auto-generated by co-pilot. The definitions of the HIR datatypes can be found at https://github.com/rust-lang/rust-analyzer/blob/master/crates/hir-def/src/hir.rs#L169-L300