mirror of
https://github.com/github/codeql.git
synced 2026-04-24 00:05:14 +02:00
Autoformat upgrade/downgrade scripts
This commit is contained in:
@@ -1,8 +1,18 @@
|
||||
class Expr extends @expr { string toString() { result = "expr" } }
|
||||
class Expr extends @expr {
|
||||
string toString() { result = "expr" }
|
||||
}
|
||||
|
||||
class LocalVariableDeclExpr extends @localvariabledeclexpr, Expr { }
|
||||
|
||||
class InstanceOfExpr extends @instanceofexpr, Expr { }
|
||||
class Type extends @type { string toString() { result = "type" } }
|
||||
class ExprParent extends @exprparent { string toString() { result = "exprparent" } }
|
||||
|
||||
class Type extends @type {
|
||||
string toString() { result = "type" }
|
||||
}
|
||||
|
||||
class ExprParent extends @exprparent {
|
||||
string toString() { result = "exprparent" }
|
||||
}
|
||||
|
||||
// Initialisers of local variable declarations that occur as the 0th child of an instanceof expression should be reparented to be the 0th child of the instanceof itself,
|
||||
// while the LocalVariableDeclExpr, now without an initialiser, should become its 2nd child.
|
||||
@@ -12,20 +22,26 @@ class ExprParent extends @exprparent { string toString() { result = "exprparent"
|
||||
// \-2-> LocalVariableDeclExpr -name-> s
|
||||
//
|
||||
// Other children are unaffected.
|
||||
|
||||
ExprParent getParent(Expr e) { exprs(e, _, _, result, _) }
|
||||
|
||||
predicate hasNewParent(Expr e, ExprParent newParent, int newIndex) {
|
||||
if (getParent(e) instanceof LocalVariableDeclExpr and getParent(getParent(e)) instanceof InstanceOfExpr)
|
||||
then (newParent = getParent(getParent(e)) and newIndex = 0) // Initialiser moves to hang directly off the instanceof expression
|
||||
else (
|
||||
if (e instanceof LocalVariableDeclExpr and getParent(e) instanceof InstanceOfExpr)
|
||||
then (newParent = getParent(e) and newIndex = 2) // Variable declaration moves to be the instanceof expression's 2nd child
|
||||
else exprs(e, _, _, newParent, newIndex) // Other expressions unchanged
|
||||
if
|
||||
getParent(e) instanceof LocalVariableDeclExpr and
|
||||
getParent(getParent(e)) instanceof InstanceOfExpr
|
||||
then (
|
||||
newParent = getParent(getParent(e)) and newIndex = 0
|
||||
) else (
|
||||
// Initialiser moves to hang directly off the instanceof expression
|
||||
if e instanceof LocalVariableDeclExpr and getParent(e) instanceof InstanceOfExpr
|
||||
then newParent = getParent(e) and newIndex = 2
|
||||
else
|
||||
// Variable declaration moves to be the instanceof expression's 2nd child
|
||||
exprs(e, _, _, newParent, newIndex) // Other expressions unchanged
|
||||
)
|
||||
}
|
||||
|
||||
from Expr e, int kind, Type typeid, ExprParent parent, int index
|
||||
where exprs(e, kind, typeid, _, _) and
|
||||
hasNewParent(e, parent, index)
|
||||
where
|
||||
exprs(e, kind, typeid, _, _) and
|
||||
hasNewParent(e, parent, index)
|
||||
select e, kind, typeid, parent, index
|
||||
|
||||
Reference in New Issue
Block a user