|
| 1 | +class KeyPathComponent extends @key_path_component { |
| 2 | + string toString() { none() } |
| 3 | +} |
| 4 | + |
| 5 | +class Element extends @element { |
| 6 | + string toString() { none() } |
| 7 | +} |
| 8 | + |
| 9 | +class ArgumentOrNone extends @argument_or_none { |
| 10 | + string toString() { none() } |
| 11 | +} |
| 12 | + |
| 13 | +class TypeOrNone extends @type_or_none { |
| 14 | + string toString() { none() } |
| 15 | +} |
| 16 | + |
| 17 | +class ValueDeclOrNone extends @value_decl_or_none { |
| 18 | + string toString() { none() } |
| 19 | +} |
| 20 | + |
| 21 | +predicate isKeyPathComponentWithNewKind(KeyPathComponent id) { |
| 22 | + key_path_components(id, 3, _) or key_path_components(id, 4, _) |
| 23 | +} |
| 24 | + |
| 25 | +query predicate new_key_path_components(KeyPathComponent id, int kind, TypeOrNone component_type) { |
| 26 | + exists(int old_kind | |
| 27 | + key_path_components(id, old_kind, component_type) and |
| 28 | + not isKeyPathComponentWithNewKind(id) and |
| 29 | + if old_kind < 5 then kind = old_kind else kind = old_kind - 2 |
| 30 | + ) |
| 31 | +} |
| 32 | + |
| 33 | +query predicate new_key_path_component_subscript_arguments( |
| 34 | + KeyPathComponent id, int index, ArgumentOrNone subscript_argument |
| 35 | +) { |
| 36 | + key_path_component_subscript_arguments(id, index, subscript_argument) and |
| 37 | + not isKeyPathComponentWithNewKind(id) |
| 38 | +} |
| 39 | + |
| 40 | +query predicate new_key_path_component_tuple_indices(KeyPathComponent id, int tuple_index) { |
| 41 | + key_path_component_tuple_indices(id, tuple_index) and |
| 42 | + not isKeyPathComponentWithNewKind(id) |
| 43 | +} |
| 44 | + |
| 45 | +query predicate new_key_path_component_decl_refs(KeyPathComponent id, ValueDeclOrNone decl_ref) { |
| 46 | + key_path_component_decl_refs(id, decl_ref) and |
| 47 | + not isKeyPathComponentWithNewKind(id) |
| 48 | +} |
| 49 | + |
| 50 | +query predicate new_unspecified_elements(Element id, string property, string error) { |
| 51 | + unspecified_elements(id, property, error) |
| 52 | + or |
| 53 | + isKeyPathComponentWithNewKind(id) and |
| 54 | + property = "" and |
| 55 | + error = |
| 56 | + "UnresolvedApply and Apply KeyPathComponents removed during database downgrade. Please update your CodeQL." |
| 57 | +} |
0 commit comments