Skip to content

Rust: AST support for variables #17606

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 5 commits into from
Oct 1, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions rust/ql/.generated.list

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

2 changes: 0 additions & 2 deletions rust/ql/.gitattributes

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

9 changes: 9 additions & 0 deletions rust/ql/lib/codeql/rust/elements/Variable.qll
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This module provides classes related to variables.
*/

private import internal.VariableImpl

final class Variable = Impl::Variable;

final class VariableAccess = Impl::VariableAccess;
11 changes: 9 additions & 2 deletions rust/ql/lib/codeql/rust/elements/internal/CommentImpl.qll
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// generated by codegen, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `Comment`.
*
Expand All @@ -12,12 +11,20 @@ private import codeql.rust.elements.internal.generated.Comment
* be referenced directly.
*/
module Impl {
// the following QLdoc is generated: if you need to edit it, do it in the schema file
/**
* A comment. For example:
* ```rust
* // this is a comment
* /// This is a doc comment
* ```
*/
class Comment extends Generated::Comment { }
class Comment extends Generated::Comment {
/**
* Gets the text of this comment, excluding the comment marker.
*/
string getCommentText() {
exists(string s | s = this.getText() | result = s.regexpCapture("///?\\s*(.*)", 1))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Rust also has block comments starting with /* or /** .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but I skipped that for now, as it is not needed for inline test expectations.

}
}
6 changes: 4 additions & 2 deletions rust/ql/lib/codeql/rust/elements/internal/IdentPatImpl.qll
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// generated by codegen, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `IdentPat`.
*
Expand All @@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.IdentPat
* be referenced directly.
*/
module Impl {
// the following QLdoc is generated: if you need to edit it, do it in the schema file
/**
* A binding pattern. For example:
* ```rust
Expand All @@ -27,5 +27,7 @@ module Impl {
* };
* ```
*/
class IdentPat extends Generated::IdentPat { }
class IdentPat extends Generated::IdentPat {
override string toString() { result = this.getName().getText() }
}
}
Loading
Loading