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
Copy file name to clipboardExpand all lines: misc/codegen/templates/ql_parent.mustache
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ private module Impl {
28
28
{{! for single and optional properties it adds 1 (regardless of whether the optional property exists) }}
29
29
{{! for repeated it adds 1 + the maximum index (which works for repeated optional as well) }}
30
30
and
31
-
n{{singular}} = n{{prev_child}} + 1{{#is_repeated}}+ max(int i | i = -1 or exists(e.getImmediate{{singular}}(i)) | i){{/is_repeated}}
31
+
n{{singular}} = n{{prev_child}} + 1{{#is_repeated}}+ max(int i | i = -1 or exists(e.get{{#type_is_hideable}}Immediate{{/type_is_hideable}}{{singular}}(i)) | i){{/is_repeated}}
32
32
{{/is_child}}
33
33
{{/properties}} and (
34
34
none()
@@ -40,10 +40,10 @@ private module Impl {
40
40
{{#is_child}}
41
41
or
42
42
{{#is_repeated}}
43
-
result = e.getImmediate{{singular}}(index - n{{prev_child}}) and partialPredicateCall = "{{singular}}(" + (index - n{{prev_child}}).toString() + ")"
43
+
result = e.get{{#type_is_hideable}}Immediate{{/type_is_hideable}}{{singular}}(index - n{{prev_child}}) and partialPredicateCall = "{{singular}}(" + (index - n{{prev_child}}).toString() + ")"
44
44
{{/is_repeated}}
45
45
{{^is_repeated}}
46
-
index = n{{prev_child}} and result = e.getImmediate{{singular}}() and partialPredicateCall = "{{singular}}()"
46
+
index = n{{prev_child}} and result = e.get{{#type_is_hideable}}Immediate{{/type_is_hideable}}{{singular}}() and partialPredicateCall = "{{singular}}()"
47
47
{{/is_repeated}}
48
48
{{/is_child}}
49
49
{{/properties}}
@@ -64,6 +64,10 @@ none()
64
64
{{/final}}
65
65
{{/classes}}
66
66
}
67
+
68
+
Element resolve(Element e) {
69
+
{{#classes}}{{#hideable_root}}if e instanceof {{name}} then result = e.({{name}}).resolve() else {{/hideable_root}}{{/classes}}result = e
70
+
}
67
71
}
68
72
69
73
/**
@@ -87,5 +91,5 @@ exists(string partialAccessor | result = Impl::getImmediateChild(e, index, parti
87
91
* Gets the child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. `accessor` is bound the member predicate call resulting in the given child.
88
92
*/
89
93
Element getChildAndAccessor(Element e, int index, string accessor) {
90
-
exists(string partialAccessor | result = Impl::getImmediateChild(e, index, partialAccessor).resolve() and accessor = "get" + partialAccessor)
94
+
exists(string partialAccessor | result = Impl::resolve(Impl::getImmediateChild(e, index, partialAccessor)) and accessor = "get" + partialAccessor)
0 commit comments