mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: Implement toString for struct fields and visibility
This commit is contained in:
1
rust/ql/.generated.list
generated
1
rust/ql/.generated.list
generated
@@ -434,7 +434,6 @@ lib/codeql/rust/elements/internal/VariantConstructor.qll 0297d4a9a9b32448d6d6063
|
||||
lib/codeql/rust/elements/internal/VariantListConstructor.qll c841fb345eb46ea3978a0ed7a689f8955efc9178044b140b74d98a6bcd0c926a c9e52d112abdba2b60013fa01a944c8770766bf7368f9878e6b13daaa4eed446
|
||||
lib/codeql/rust/elements/internal/VariantListImpl.qll 4ceeda617696eb547c707589ba26103cf4c5c3d889955531be24cbf224e79dff 4258196c126fd2fad0e18068cb3d570a67034a8b26e2f13f8223d7f1a246d1a4
|
||||
lib/codeql/rust/elements/internal/VisibilityConstructor.qll 1fd30663d87945f08d15cfaca54f586a658f26b7a98ea45ac73a35d36d4f65d0 6ddaf11742cc8fbbe03af2aa578394041ae077911e62d2fa6c885ae0543ba53a
|
||||
lib/codeql/rust/elements/internal/VisibilityImpl.qll 85c1e75d6a7f9246cfef5c261e2aea40891c016724de49b3d6632623ccc30dcf 278be4648a8aefb0d926480c4d98e1605196ad64d1e4dbad42aa58499e6d485d
|
||||
lib/codeql/rust/elements/internal/WhereClauseConstructor.qll 6d6f0f0376cf45fac37ea0c7c4345d08718d2a3d6d913e591de1de9e640317c9 ff690f3d4391e5f1fae6e9014365810105e8befe9d6b52a82625994319af9ffd
|
||||
lib/codeql/rust/elements/internal/WhereClauseImpl.qll 006e330df395183d15896e5f81128e24b8274d849fe45afb5040444e4b764226 ed5e8317b5f33104e5c322588dc400755c8852bbb77ef835177b13af7480fd43
|
||||
lib/codeql/rust/elements/internal/WherePredConstructor.qll f331c37085792a01159e8c218e9ef827e80e99b7c3d5978b6489808f05bd11f8 179cad3e4c5aaaf27755891694ef3569322fcf34c5290e6af49e5b5e3f8aa732
|
||||
|
||||
1
rust/ql/.gitattributes
generated
vendored
1
rust/ql/.gitattributes
generated
vendored
@@ -436,7 +436,6 @@
|
||||
/lib/codeql/rust/elements/internal/VariantListConstructor.qll linguist-generated
|
||||
/lib/codeql/rust/elements/internal/VariantListImpl.qll linguist-generated
|
||||
/lib/codeql/rust/elements/internal/VisibilityConstructor.qll linguist-generated
|
||||
/lib/codeql/rust/elements/internal/VisibilityImpl.qll linguist-generated
|
||||
/lib/codeql/rust/elements/internal/WhereClauseConstructor.qll linguist-generated
|
||||
/lib/codeql/rust/elements/internal/WhereClauseImpl.qll linguist-generated
|
||||
/lib/codeql/rust/elements/internal/WherePredConstructor.qll linguist-generated
|
||||
|
||||
@@ -29,5 +29,17 @@ module Impl {
|
||||
|
||||
/** Holds if this record field is named `name` and belongs to the struct `s`. */
|
||||
predicate isStructField(Struct s, string name) { this = s.getStructField(name) }
|
||||
|
||||
override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) }
|
||||
|
||||
private string toStringPart(int index) {
|
||||
index = 0 and result = this.getVisibility().toAbbreviatedString() + " "
|
||||
or
|
||||
index = 1 and result = this.getName().getText()
|
||||
or
|
||||
index = 2 and result = ": "
|
||||
or
|
||||
index = 3 and result = this.getTypeRepr().toAbbreviatedString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 `Visibility`.
|
||||
*
|
||||
@@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.Visibility
|
||||
* be referenced directly.
|
||||
*/
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* A visibility modifier.
|
||||
*
|
||||
@@ -21,5 +21,13 @@ module Impl {
|
||||
* //^^^
|
||||
* ```
|
||||
*/
|
||||
class Visibility extends Generated::Visibility { }
|
||||
class Visibility extends Generated::Visibility {
|
||||
override string toStringImpl() { result = this.toAbbreviatedString() }
|
||||
|
||||
override string toAbbreviatedString() {
|
||||
result = "pub(" + this.getPath().toAbbreviatedString() + ")"
|
||||
or
|
||||
not this.hasPath() and result = "pub"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user