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: PrintAst improvements #17689

Merged
merged 1 commit into from
Oct 9, 2024
Merged

Rust: PrintAst improvements #17689

merged 1 commit into from
Oct 9, 2024

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Oct 8, 2024

  • Turn PrintAst into a parameterized module, parameterizing over relevant nodes. This means that we no longer need to cache getOrder(PrintAstNode node), which could be really expensive to compute in full on some DBs.

  • getPrimaryQlClasses already concats all getAPrimaryQlClasses, so the extra concat in prettyPrint is not needed.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Oct 8, 2024
@hvitved hvitved marked this pull request as ready for review October 8, 2024 13:06
class PrintLocatable extends PrintAstNode, TPrintLocatable {
Locatable ast;
override predicate hasChild(PrintAstNode child, int index, string label) {
child = TPrintLocatable(any(Locatable c | c = getChildAndAccessor(ast, index, label)))

Check warning

Code scanning / CodeQL

Expression can be replaced with a cast Warning

The assignment to
c
in this any(..) can be replaced with an inline cast.
Copy link
Contributor

@aibaars aibaars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. I believe the printAst queries were mostly copied and slightly modified from swift. Might be interesting to see if things can be shared .

@hvitved hvitved merged commit 04d1c82 into github:main Oct 9, 2024
14 of 15 checks passed
@hvitved hvitved deleted the rust/print-ast branch October 9, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants