You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// we are defining this class mainly to leverage existing generation machinery
8
+
// when we generate getters in classes we use the db predicate with `this`. In order to reuse that we need a class here
9
+
// as well
10
+
private class ElementWithChildAccessor extends Element {
11
+
// why does this look more complicated than it should?
12
+
// * the none() simplifies generation, as we can append `or ...` without a special case for the first item
13
+
// * the `exists` and the `x` variables are there to reuse the same generation done in classes (where the variables
14
+
// are used to hide nodes via resolution)
15
+
Element getAnImmediateChild() {
16
+
none()
17
+
{{#classes}}
18
+
{{#properties}}
19
+
{{#is_child}}
20
+
or
21
+
exists({{type}} {{local_var}}{{#is_repeated}}, int index{{/is_repeated}} | {{tablename}}({{#tableparams}}{{^first}}, {{/first}}{{param}}{{/tableparams}}) and result = {{local_var}})
22
+
{{/is_child}}
23
+
{{/properties}}
24
+
{{/classes}}
25
+
}
26
+
}
27
+
28
+
/**
29
+
* Gets any of the "immediate" children of `e`. "Immediate" means not taking into account node resolution: for example
30
+
* if the AST child is the first of a series of conversions that would normally be hidden away, this will select the
31
+
* next conversion down the hidden AST tree instead of the corresponding fully uncoverted node at the bottom.
32
+
* This predicate is mainly intended to be used to test uniqueness of parents.
33
+
*/
34
+
cached
35
+
Element getAnImmediateChild(Element e) {
36
+
result = e.(ElementWithChildAccessor).getAnImmediateChild()
37
+
}
38
+
39
+
/**
40
+
* Gets the "immediate" parent of `e`. "Immediate" means not taking into account node resolution: for example
41
+
* if `e` has conversions, `getImmediateParent(e)` will give the bottom conversion in the hidden AST.
42
+
*/
43
+
Element getImmediateParent(Element e) {
44
+
result = unique(Element x | e = getAnImmediateChild(x) | x)
0 commit comments