@@ -83,17 +83,19 @@ class Target extends EventEmitter {
83
83
/**
84
84
* Get the names of all the variables of the given type that are in scope for this target.
85
85
* For targets that are not the stage, this includes any target-specific
86
- * variables as well as any stage variables.
86
+ * variables as well as any stage variables unless the skipStage flag is true .
87
87
* For the stage, this is all stage variables.
88
88
* @param {string } type The variable type to search for; defaults to Variable.SCALAR_TYPE
89
+ * @param {?bool } skipStage Optional flag to skip the stage.
89
90
* @return {Array<string> } A list of variable names
90
91
*/
91
- getAllVariableNamesInScopeByType ( type ) {
92
+ getAllVariableNamesInScopeByType ( type , skipStage ) {
92
93
if ( typeof type !== 'string' ) type = Variable . SCALAR_TYPE ;
94
+ skipStage = skipStage || false ;
93
95
const targetVariables = Object . values ( this . variables )
94
96
. filter ( v => v . type === type )
95
97
. map ( variable => variable . name ) ;
96
- if ( this . isStage || ! this . runtime ) {
98
+ if ( skipStage || this . isStage || ! this . runtime ) {
97
99
return targetVariables ;
98
100
}
99
101
const stage = this . runtime . getTargetForStage ( ) ;
@@ -194,11 +196,13 @@ class Target extends EventEmitter {
194
196
* was not found.
195
197
* @param {string } name Name of the variable.
196
198
* @param {string } type Type of the variable. Defaults to Variable.SCALAR_TYPE.
199
+ * @param {?bool } skipStage Optional flag to skip checking the stage
197
200
* @return {?Variable } Variable object if found, or null if not.
198
201
*/
199
- lookupVariableByNameAndType ( name , type ) {
202
+ lookupVariableByNameAndType ( name , type , skipStage ) {
200
203
if ( typeof name !== 'string' ) return ;
201
204
if ( typeof type !== 'string' ) type = Variable . SCALAR_TYPE ;
205
+ skipStage = skipStage || false ;
202
206
203
207
for ( const varId in this . variables ) {
204
208
const currVar = this . variables [ varId ] ;
@@ -207,7 +211,7 @@ class Target extends EventEmitter {
207
211
}
208
212
}
209
213
210
- if ( this . runtime && ! this . isStage ) {
214
+ if ( ! skipStage && this . runtime && ! this . isStage ) {
211
215
const stage = this . runtime . getTargetForStage ( ) ;
212
216
if ( stage ) {
213
217
for ( const varId in stage . variables ) {
0 commit comments