1- // generated by codegen, remove this comment if you wish to edit this file
21/**
32 * This module provides a hand-modifiable wrapper around the generated class `Static`.
43 *
54 * INTERNAL: Do not use.
65 */
76
87private import codeql.rust.elements.internal.generated.Static
8+ private import codeql.rust.elements.internal.AstNodeImpl:: Impl as AstNodeImpl
9+ private import codeql.rust.elements.internal.PathExprImpl:: Impl as PathExprImpl
10+ private import codeql.rust.elements.internal.VariableImpl:: Impl as VariableImpl
11+ private import codeql.rust.internal.PathResolution
912
1013/**
1114 * INTERNAL: This module contains the customizable definition of `Static` and should not
1215 * be referenced directly.
1316 */
1417module Impl {
18+ // the following QLdoc is generated: if you need to edit it, do it in the schema file
1519 /**
1620 * A static item declaration.
1721 *
@@ -20,5 +24,43 @@ module Impl {
2024 * static X: i32 = 42;
2125 * ```
2226 */
23- class Static extends Generated:: Static { }
27+ class Static extends Generated:: Static {
28+ /** Gets an access to this static item. */
29+ StaticAccess getAnAccess ( ) { this = result .getStatic ( ) }
30+
31+ override string toStringImpl ( ) { result = "static " + this .getName ( ) .getText ( ) }
32+ }
33+
34+ /**
35+ * A static access.
36+ *
37+ * For example:
38+ * ```rust
39+ * static X: i32 = 42;
40+ *
41+ * fn main() {
42+ * println!("{}", X);
43+ * }
44+ * ```
45+ */
46+ class StaticAccess extends AstNodeImpl:: AstNode , PathExprImpl:: PathExpr {
47+ private Static s ;
48+
49+ StaticAccess ( ) { s = resolvePath ( this .getPath ( ) ) }
50+
51+ /** Gets the static being accessed. */
52+ Static getStatic ( ) { result = s }
53+
54+ override string getAPrimaryQlClass ( ) { result = "StaticAccess" }
55+ }
56+
57+ /** A static write access. */
58+ class StaticWriteAccess extends StaticAccess {
59+ StaticWriteAccess ( ) { VariableImpl:: assignmentOperationDescendant ( _, this ) }
60+ }
61+
62+ /** A static read access. */
63+ class StaticReadAccess extends StaticAccess {
64+ StaticReadAccess ( ) { not this instanceof StaticWriteAccess }
65+ }
2466}
0 commit comments