mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Improve downgrade script.
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
class Expression extends @expr {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class TypeOrRef extends @type_or_ref {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
from Expression e, int k, int kind, TypeOrRef t
|
||||
where
|
||||
expressions(e, k, t) and
|
||||
if k = 138 then kind = 106 else kind = k
|
||||
select e, kind, t
|
||||
@@ -0,0 +1,39 @@
|
||||
class Expr extends @expr {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class TypeOrRef extends @type_or_ref {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class InterpolatedStringInsertExpr extends Expr, @interpolated_string_insert_expr { }
|
||||
|
||||
private predicate remove_expr(Expr e) {
|
||||
exists(InterpolatedStringInsertExpr ie |
|
||||
e = ie
|
||||
or
|
||||
// Alignment
|
||||
expr_parent(e, 1, ie)
|
||||
or
|
||||
// Format
|
||||
expr_parent(e, 2, ie)
|
||||
)
|
||||
}
|
||||
|
||||
query predicate new_expressions(Expr e, int kind, TypeOrRef t) {
|
||||
expressions(e, kind, t) and
|
||||
// Remove the syntheetic intert expression and previously un-extracted children
|
||||
not remove_expr(e)
|
||||
}
|
||||
|
||||
query predicate new_expr_parent(Expr e, int child, Expr parent) {
|
||||
expr_parent(e, child, parent) and
|
||||
not remove_expr(e) and
|
||||
not remove_expr(parent)
|
||||
or
|
||||
// Use the string interpolation as parent instead of the synthetic insert expression
|
||||
exists(InterpolatedStringInsertExpr ie |
|
||||
expr_parent(e, 0, ie) and
|
||||
expr_parent(ie, child, parent)
|
||||
)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
description: Remove `interpolated_string_insert_expr` kind.
|
||||
compatibility: partial
|
||||
expressions.rel: run expressions.qlo
|
||||
compatibility: backwards
|
||||
expressions.rel: run string_interpol_insert.qlo new_expressions
|
||||
expr_parent.rel: run string_interpol_insert.qlo new_expr_parent
|
||||
|
||||
Reference in New Issue
Block a user