@@ -158,6 +158,17 @@ module Templating {
158
158
DataFlow:: SourceNode getAVariableUse ( string name ) {
159
159
result = this .getScope ( ) .getVariable ( name ) .getAnAccess ( ) .flow ( )
160
160
}
161
+
162
+ /** Gets a data flow node corresponding to a use of the given template variable within this top-level. */
163
+ DataFlow:: SourceNode getAnAccessPathUse ( string accessPath ) {
164
+ result = getAVariableUse ( accessPath )
165
+ or
166
+ exists ( string varName , string suffix |
167
+ accessPath = varName + "." + suffix and
168
+ suffix != "" and
169
+ result = AccessPath:: getAReferenceTo ( getAVariableUse ( varName ) , suffix )
170
+ )
171
+ }
161
172
}
162
173
163
174
/**
@@ -177,6 +188,11 @@ module Templating {
177
188
/** Gets a data flow node that refers to an object whose properties become variables in the template. */
178
189
DataFlow:: Node getTemplateParamsNode ( ) { result = range .getTemplateParamsNode ( ) }
179
190
191
+ /** Gets a data flow node that provides the value for the template variable at the given access path. */
192
+ DataFlow:: Node getTemplateParamForValue ( string accessPath ) {
193
+ result = range .getTemplateParamForValue ( accessPath )
194
+ }
195
+
180
196
/** Gets the template file instantiated here, if any. */
181
197
TemplateFile getTemplateFile ( ) {
182
198
result = this .getTemplateFileNode ( ) .( TemplateFileReference ) .getTemplateFile ( )
@@ -202,6 +218,9 @@ module Templating {
202
218
/** Gets a data flow node that refers to an object whose properties become variables in the template. */
203
219
abstract DataFlow:: Node getTemplateParamsNode ( ) ;
204
220
221
+ /** Gets a data flow node that provides the value for the template variable at the given access path. */
222
+ DataFlow:: Node getTemplateParamForValue ( string accessPath ) { none ( ) }
223
+
205
224
/**
206
225
* Gets the template syntax used by this template instantiation, if known.
207
226
*
@@ -224,6 +243,16 @@ module Templating {
224
243
.getAVariableUse ( name )
225
244
)
226
245
or
246
+ exists ( TemplateInstantiation inst , string accessPath |
247
+ result .getARhs ( ) = inst .getTemplateParamForValue ( accessPath ) and
248
+ succ =
249
+ inst .getTemplateFile ( )
250
+ .getAnImportedFile * ( )
251
+ .getAPlaceholder ( )
252
+ .getInnerTopLevel ( )
253
+ .getAnAccessPathUse ( accessPath )
254
+ )
255
+ or
227
256
exists ( string prop , DataFlow:: SourceNode prev |
228
257
result = getTemplateInput ( prev ) .getMember ( prop ) and
229
258
succ = prev .getAPropertyRead ( prop )
0 commit comments