-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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/Swift: Make all public AST classes final
#17444
Conversation
4be55f4
to
5c3eb4b
Compare
b3b0660
to
8a5ee7f
Compare
e360f96
to
3481141
Compare
final
final
3481141
to
0da1611
Compare
*/ | ||
|
||
private import AvailabilityInfoImpl | ||
import codeql.swift.elements.AstNode |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.swift.elements.AvailabilitySpec
private import KeyPathComponentImpl | ||
import codeql.swift.elements.expr.Argument | ||
import codeql.swift.elements.AstNode | ||
import codeql.swift.elements.type.Type |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.swift.elements.decl.ValueDecl
result instanceof UnknownLocation | ||
} | ||
private import LocatableImpl | ||
import codeql.swift.elements.Element |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.swift.elements.Location
} | ||
} | ||
private import LocationImpl | ||
import codeql.swift.elements.Element |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.swift.elements.File
0da1611
to
1605ed7
Compare
private import codeql.rust.generated.ElementListExpr | ||
private import ElementListExprImpl | ||
import codeql.rust.elements.ArrayExpr | ||
import codeql.rust.elements.Expr |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.ArrayExpr
*/ | ||
|
||
private import codeql.rust.generated.MatchArm | ||
private import MatchArmImpl | ||
import codeql.rust.elements.AstNode |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.Expr
Redundant import, the module is already imported inside
codeql.rust.elements.Pat
*/ | ||
|
||
private import codeql.rust.generated.MatchExpr | ||
private import MatchExprImpl | ||
import codeql.rust.elements.Expr |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.MatchArm
*/ | ||
|
||
private import codeql.rust.generated.RecordExpr | ||
private import RecordExprImpl | ||
import codeql.rust.elements.Expr |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.RecordExprFieldList
*/ | ||
|
||
private import codeql.rust.generated.RecordExprField | ||
private import RecordExprFieldImpl | ||
import codeql.rust.elements.AstNode |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.Expr
*/ | ||
|
||
private import codeql.rust.generated.RecordPat | ||
private import RecordPatImpl | ||
import codeql.rust.elements.Pat |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.RecordPatField
*/ | ||
|
||
private import codeql.rust.generated.RecordPatField | ||
private import RecordPatFieldImpl | ||
import codeql.rust.elements.AstNode |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.Pat
private import codeql.rust.generated.RepeatExpr | ||
private import RepeatExprImpl | ||
import codeql.rust.elements.ArrayExpr | ||
import codeql.rust.elements.Expr |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.ArrayExpr
6b91a2e
to
ec9377f
Compare
``` find . -maxdepth 5 -type f -not -name "*Constructor.qll" -print | sed 's/.qll//g' | xargs -I '{}' mv '{}'.qll '{}'Impl.qll ```
ec9377f
to
575023f
Compare
Pre-commit: bump up `autopep8` check version and fix formatting
meta-review comment: a |
Thanks; actually it should be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this, thanks for the hard work!
I think we should move all stubs to a separate directory (impl
or internal
), but I saw on slack you agree with this for a follow-up PR, so I'm perfectly happy with that.
@@ -1,4 +1,4 @@ | |||
# configuration file for Swift code generation default options | |||
# configuration file for Rust code generation default options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well spotted! 😅
ah, that pesky autopep again 😅 Ah, forgot to mention, the Doc coverage failure is pretty normal, because the baseline situation (with uncovered defs) gets lost in the renames. I'm ok with ignoring it. |
Co-authored-by: Paolo Tranquilli <[email protected]>
917729d
to
964e97c
Compare
Yes, it was also my impression that this was because of the renamed files. |
You've checked in a merge artifact Also why is no change note required for Swift - are we confident users can't or have been told they shouldn't be overriding these classes? |
Yes, sorry, thanks for noticing.
I'll add a change note. |
This PR changes the code generator used by Rust and Swift so that all public classes are
final
. Commit-by-commit review is strongly recommended.Before this PR
An entry such as
Expr
inschema.py
would give rise to two classes:generated/Expr.qll
elements/Expr.qll
Any customizations needed on
Expr
, such as the addition of new predicates or overriding of existing predicates, would be done inelements/Expr.qll
and this would also be the public version ofExpr
.After this PR
We want to avoid unintended predicate dispatch, i.e. make the public
Expr
classfinal
. However, we cannot simply make theExpr
class inelements/Expr.qll
final
, because other customization classes may want to extend it. This PR therefore adds an additional layer:generated/Expr.qll
elements/ExprImpl.qll
elements/Expr.qll
Now the exposed
Expr
class isfinal
, and all customizations are done inelements/ExprImpl.qll
.