|
| 1 | +class Element extends @element { |
| 2 | + string toString() { none() } |
| 3 | +} |
| 4 | + |
| 5 | +class Location extends @location_default { |
| 6 | + string toString() { none() } |
| 7 | +} |
| 8 | + |
| 9 | +private predicate oldMetaHasExpr(Element meta) { meta_exprs(meta, _) } |
| 10 | + |
| 11 | +private predicate oldMetaHasPath(Element meta) { meta_paths(meta, _) } |
| 12 | + |
| 13 | +private predicate oldMetaHasTokenTree(Element meta) { meta_token_trees(meta, _) } |
| 14 | + |
| 15 | +private predicate oldMetaIsPath(Element meta) { |
| 16 | + oldMetaHasPath(meta) and not oldMetaHasExpr(meta) and not oldMetaHasTokenTree(meta) |
| 17 | +} |
| 18 | + |
| 19 | +private predicate oldMetaIsKeyValue(Element meta) { oldMetaHasPath(meta) and oldMetaHasExpr(meta) } |
| 20 | + |
| 21 | +private predicate oldMetaIsTokenTree(Element meta) { |
| 22 | + oldMetaHasPath(meta) and oldMetaHasTokenTree(meta) and not oldMetaHasExpr(meta) |
| 23 | +} |
| 24 | + |
| 25 | +private predicate oldMetaHasInnerShape(Element meta) { |
| 26 | + oldMetaIsPath(meta) or oldMetaIsKeyValue(meta) or oldMetaIsTokenTree(meta) |
| 27 | +} |
| 28 | + |
| 29 | +newtype TAddedElement = |
| 30 | + TFormatArgsArgName(Element arg, Element name) { format_args_arg_names(arg, name) } or |
| 31 | + TTryBlockModifier(Element block) { block_expr_is_try(block) } or |
| 32 | + TStructFieldDefaultConstArg(Element field, Element expr) { struct_field_defaults(field, expr) } or |
| 33 | + TVariantDiscriminantConstArg(Element variant, Element expr) { |
| 34 | + variant_discriminants(variant, expr) |
| 35 | + } or |
| 36 | + TUnsafePathMeta(Element meta) { meta_is_unsafe(meta) and oldMetaIsPath(meta) } or |
| 37 | + TUnsafeKeyValueMeta(Element meta) { meta_is_unsafe(meta) and oldMetaIsKeyValue(meta) } or |
| 38 | + TUnsafeTokenTreeMeta(Element meta) { meta_is_unsafe(meta) and oldMetaIsTokenTree(meta) } |
| 39 | + |
| 40 | +module Fresh = QlBuiltins::NewEntity<TAddedElement>; |
| 41 | + |
| 42 | +class TNewElement = @element or Fresh::EntityId; |
| 43 | + |
| 44 | +class NewElement extends TNewElement { |
| 45 | + string toString() { none() } |
| 46 | +} |
| 47 | + |
| 48 | +private predicate isFreshInnerMeta(NewElement id, Element oldMeta) { |
| 49 | + id = Fresh::map(TUnsafePathMeta(oldMeta)) or |
| 50 | + id = Fresh::map(TUnsafeKeyValueMeta(oldMeta)) or |
| 51 | + id = Fresh::map(TUnsafeTokenTreeMeta(oldMeta)) |
| 52 | +} |
| 53 | + |
| 54 | +query predicate new_format_args_arg_names(NewElement id) { |
| 55 | + id = Fresh::map(TFormatArgsArgName(_, _)) |
| 56 | +} |
| 57 | + |
| 58 | +query predicate new_format_args_arg_arg_names(Element id, NewElement arg_name) { |
| 59 | + arg_name = Fresh::map(TFormatArgsArgName(id, _)) |
| 60 | +} |
| 61 | + |
| 62 | +query predicate new_try_block_modifiers(NewElement id) { id = Fresh::map(TTryBlockModifier(_)) } |
| 63 | + |
| 64 | +query predicate new_try_block_modifier_is_try(NewElement id) { |
| 65 | + id = Fresh::map(TTryBlockModifier(_)) |
| 66 | +} |
| 67 | + |
| 68 | +query predicate new_block_expr_try_block_modifiers(Element id, NewElement try_block_modifier) { |
| 69 | + try_block_modifier = Fresh::map(TTryBlockModifier(id)) |
| 70 | +} |
| 71 | + |
| 72 | +query predicate new_const_args(NewElement id) { |
| 73 | + const_args(id) or |
| 74 | + id = Fresh::map(TStructFieldDefaultConstArg(_, _)) or |
| 75 | + id = Fresh::map(TVariantDiscriminantConstArg(_, _)) |
| 76 | +} |
| 77 | + |
| 78 | +query predicate new_const_arg_exprs(NewElement id, Element expr) { |
| 79 | + const_arg_exprs(id, expr) or |
| 80 | + id = Fresh::map(TStructFieldDefaultConstArg(_, expr)) or |
| 81 | + id = Fresh::map(TVariantDiscriminantConstArg(_, expr)) |
| 82 | +} |
| 83 | + |
| 84 | +query predicate new_struct_field_default_vals(Element id, NewElement default_val) { |
| 85 | + default_val = Fresh::map(TStructFieldDefaultConstArg(id, _)) |
| 86 | +} |
| 87 | + |
| 88 | +query predicate new_variant_const_args(Element id, NewElement const_arg) { |
| 89 | + const_arg = Fresh::map(TVariantDiscriminantConstArg(id, _)) |
| 90 | +} |
| 91 | + |
| 92 | +query predicate new_traits(Element id) { traits(id) or trait_aliases(id) } |
| 93 | + |
| 94 | +query predicate new_trait_attrs(Element id, int index, Element attr) { |
| 95 | + trait_attrs(id, index, attr) or trait_alias_attrs(id, index, attr) |
| 96 | +} |
| 97 | + |
| 98 | +query predicate new_trait_generic_param_lists(Element id, Element generic_param_list) { |
| 99 | + trait_generic_param_lists(id, generic_param_list) or |
| 100 | + trait_alias_generic_param_lists(id, generic_param_list) |
| 101 | +} |
| 102 | + |
| 103 | +query predicate new_trait_names(Element id, Element name) { |
| 104 | + trait_names(id, name) or trait_alias_names(id, name) |
| 105 | +} |
| 106 | + |
| 107 | +query predicate new_trait_type_bound_lists(Element id, Element type_bound_list) { |
| 108 | + trait_type_bound_lists(id, type_bound_list) or trait_alias_type_bound_lists(id, type_bound_list) |
| 109 | +} |
| 110 | + |
| 111 | +query predicate new_trait_visibilities(Element id, Element visibility) { |
| 112 | + trait_visibilities(id, visibility) or trait_alias_visibilities(id, visibility) |
| 113 | +} |
| 114 | + |
| 115 | +query predicate new_trait_where_clauses(Element id, Element where_clause) { |
| 116 | + trait_where_clauses(id, where_clause) or trait_alias_where_clauses(id, where_clause) |
| 117 | +} |
| 118 | + |
| 119 | +query predicate new_path_meta(NewElement id) { |
| 120 | + meta(id) and not meta_is_unsafe(id) and oldMetaIsPath(id) |
| 121 | + or |
| 122 | + id = Fresh::map(TUnsafePathMeta(_)) |
| 123 | +} |
| 124 | + |
| 125 | +query predicate new_path_meta_paths(NewElement id, Element path) { |
| 126 | + meta_paths(id, path) and not meta_is_unsafe(id) and oldMetaIsPath(id) |
| 127 | + or |
| 128 | + exists(Element oldMeta | id = Fresh::map(TUnsafePathMeta(oldMeta)) and meta_paths(oldMeta, path)) |
| 129 | +} |
| 130 | + |
| 131 | +query predicate new_key_value_meta(NewElement id) { |
| 132 | + meta(id) and not meta_is_unsafe(id) and oldMetaIsKeyValue(id) |
| 133 | + or |
| 134 | + id = Fresh::map(TUnsafeKeyValueMeta(_)) |
| 135 | +} |
| 136 | + |
| 137 | +query predicate new_key_value_meta_exprs(NewElement id, Element expr) { |
| 138 | + meta_exprs(id, expr) and not meta_is_unsafe(id) and oldMetaIsKeyValue(id) |
| 139 | + or |
| 140 | + exists(Element oldMeta | |
| 141 | + id = Fresh::map(TUnsafeKeyValueMeta(oldMeta)) and meta_exprs(oldMeta, expr) |
| 142 | + ) |
| 143 | +} |
| 144 | + |
| 145 | +query predicate new_key_value_meta_paths(NewElement id, Element path) { |
| 146 | + meta_paths(id, path) and not meta_is_unsafe(id) and oldMetaIsKeyValue(id) |
| 147 | + or |
| 148 | + exists(Element oldMeta | |
| 149 | + id = Fresh::map(TUnsafeKeyValueMeta(oldMeta)) and meta_paths(oldMeta, path) |
| 150 | + ) |
| 151 | +} |
| 152 | + |
| 153 | +query predicate new_token_tree_meta(NewElement id) { |
| 154 | + meta(id) and not meta_is_unsafe(id) and oldMetaIsTokenTree(id) |
| 155 | + or |
| 156 | + id = Fresh::map(TUnsafeTokenTreeMeta(_)) |
| 157 | +} |
| 158 | + |
| 159 | +query predicate new_token_tree_meta_paths(NewElement id, Element path) { |
| 160 | + meta_paths(id, path) and not meta_is_unsafe(id) and oldMetaIsTokenTree(id) |
| 161 | + or |
| 162 | + exists(Element oldMeta | |
| 163 | + id = Fresh::map(TUnsafeTokenTreeMeta(oldMeta)) and meta_paths(oldMeta, path) |
| 164 | + ) |
| 165 | +} |
| 166 | + |
| 167 | +query predicate new_token_tree_meta_token_trees(NewElement id, Element token_tree) { |
| 168 | + meta_token_trees(id, token_tree) and not meta_is_unsafe(id) and oldMetaIsTokenTree(id) |
| 169 | + or |
| 170 | + exists(Element oldMeta | |
| 171 | + id = Fresh::map(TUnsafeTokenTreeMeta(oldMeta)) and meta_token_trees(oldMeta, token_tree) |
| 172 | + ) |
| 173 | +} |
| 174 | + |
| 175 | +query predicate new_unsafe_meta(Element id) { meta_is_unsafe(id) } |
| 176 | + |
| 177 | +query predicate new_unsafe_meta_is_unsafe(Element id) { meta_is_unsafe(id) } |
| 178 | + |
| 179 | +query predicate new_unsafe_meta_meta(Element id, NewElement inner) { |
| 180 | + meta_is_unsafe(id) and oldMetaHasInnerShape(id) and isFreshInnerMeta(inner, id) |
| 181 | +} |
| 182 | + |
| 183 | +query predicate new_locatable_locations(NewElement id, Location location) { |
| 184 | + locatable_locations(id, location) |
| 185 | + or |
| 186 | + exists(Element arg, Element name | |
| 187 | + id = Fresh::map(TFormatArgsArgName(arg, name)) and locatable_locations(name, location) |
| 188 | + ) |
| 189 | + or |
| 190 | + exists(Element block | |
| 191 | + id = Fresh::map(TTryBlockModifier(block)) and locatable_locations(block, location) |
| 192 | + ) |
| 193 | + or |
| 194 | + exists(Element field, Element expr | |
| 195 | + id = Fresh::map(TStructFieldDefaultConstArg(field, expr)) and |
| 196 | + locatable_locations(expr, location) |
| 197 | + ) |
| 198 | + or |
| 199 | + exists(Element variant, Element expr | |
| 200 | + id = Fresh::map(TVariantDiscriminantConstArg(variant, expr)) and |
| 201 | + locatable_locations(expr, location) |
| 202 | + ) |
| 203 | + or |
| 204 | + exists(Element oldMeta | isFreshInnerMeta(id, oldMeta) and locatable_locations(oldMeta, location)) |
| 205 | +} |
0 commit comments