Skip to content

Commit 720bfc8

Browse files
author
Paolo Tranquilli
committed
Rust: tweak/define more toString implementations
1 parent dce29db commit 720bfc8

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

rust/ql/.generated.list

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/.gitattributes

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ module Impl {
2020
* ```
2121
*/
2222
class MethodCallExpr extends Generated::MethodCallExpr {
23-
override string toString() { result = "... ." + this.getNameRef().toString() + "(...)" }
23+
override string toString() {
24+
exists(string base, string separator |
25+
base = this.getReceiver().toAbbreviatedString() and
26+
(if base = "..." then separator = " ." else separator = ".") and
27+
result = base + separator + this.getNameRef().toString() + "(...)"
28+
)
29+
}
2430
}
2531
}

rust/ql/lib/codeql/rust/elements/internal/StructImpl.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
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 `Struct`.
43
*
@@ -12,11 +11,14 @@ private import codeql.rust.elements.internal.generated.Struct
1211
* be referenced directly.
1312
*/
1413
module Impl {
14+
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1515
/**
1616
* A Struct. For example:
1717
* ```rust
1818
* todo!()
1919
* ```
2020
*/
21-
class Struct extends Generated::Struct { }
21+
class Struct extends Generated::Struct {
22+
override string toString() { result = "struct " + this.getName().getText() }
23+
}
2224
}

rust/ql/lib/codeql/rust/elements/internal/VariantImpl.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
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 `Variant`.
43
*
@@ -12,11 +11,14 @@ private import codeql.rust.elements.internal.generated.Variant
1211
* be referenced directly.
1312
*/
1413
module Impl {
14+
// the following QLdoc is generated: if you need to edit it, do it in the schema file
1515
/**
1616
* A Variant. For example:
1717
* ```rust
1818
* todo!()
1919
* ```
2020
*/
21-
class Variant extends Generated::Variant { }
21+
class Variant extends Generated::Variant {
22+
override string toString() { result = this.getName().getText() }
23+
}
2224
}

0 commit comments

Comments
 (0)