@@ -73,7 +73,11 @@ block.prototype.consumeChild = function(ast) {
7373
7474 // handle class definition
7575 if ( ast . kind === 'doc' ) {
76- this . _lastDoc = item ;
76+ if ( this . getRepository ( ) . options . scanDocs ) {
77+ this . _lastDoc = item ;
78+ } else {
79+ this . _lastDoc = null ;
80+ }
7781 } else {
7882
7983 // attach last doc node to current node
@@ -121,42 +125,54 @@ block.prototype.consumeChild = function(ast) {
121125
122126 // consume IF nodes
123127 else if ( ast . kind === 'if' ) {
124- // IF BODY
125- if ( ast . body ) {
126- this . blocks . push (
127- ptr . create ( 'block' , this , ast . body )
128- ) ;
129- }
130- // ELSE STATEMENT
131- if ( ast . alternate ) {
132- this . blocks . push (
133- ptr . create ( 'block' , this , ast . alternate )
134- ) ;
128+ if ( this . getRepository ( ) . options . scanExpr ) {
129+
130+ // IF BODY
131+ if ( ast . body ) {
132+ this . blocks . push (
133+ ptr . create ( 'block' , this , ast . body )
134+ ) ;
135+ }
136+ // ELSE STATEMENT
137+ if ( ast . alternate ) {
138+ this . blocks . push (
139+ ptr . create ( 'block' , this , ast . alternate )
140+ ) ;
141+ }
142+ } else {
143+ // inner scan only (ignore blocks)
144+ if ( ast . body ) this . scanForChilds ( ast . body ) ;
145+ if ( ast . alternate ) this . scanForChilds ( ast . alternate ) ;
135146 }
136147 }
137148
138149 // try nodes
139150 else if ( ast . kind === 'try' ) {
140151
141- // BODY
142- this . blocks . push (
143- ptr . create ( 'block' , this , ast . body )
144- ) ;
145-
146- // CATCH
147- if ( Array . isArray ( ast . catches ) ) {
148- ast . catches . forEach ( function ( item ) {
149- this . blocks . push (
150- ptr . create ( 'block' , this , item . body )
151- ) ;
152- } . bind ( this ) ) ;
153- }
154-
155- // FINALLY
156- if ( ast . allways ) {
152+ if ( this . getRepository ( ) . options . scanExpr ) {
153+ // BODY
157154 this . blocks . push (
158- ptr . create ( 'block' , this , ast . allways )
155+ ptr . create ( 'block' , this , ast . body )
159156 ) ;
157+ // CATCH
158+ if ( Array . isArray ( ast . catches ) ) {
159+ ast . catches . forEach ( function ( item ) {
160+ this . blocks . push (
161+ ptr . create ( 'block' , this , item . body )
162+ ) ;
163+ } . bind ( this ) ) ;
164+ }
165+ // FINALLY
166+ if ( ast . allways ) {
167+ this . blocks . push (
168+ ptr . create ( 'block' , this , ast . allways )
169+ ) ;
170+ }
171+ } else {
172+ // inner scan only (ignore blocks)
173+ this . scanForChilds ( ast . body ) ;
174+ if ( Array . isArray ( ast . catches ) ) this . scanForChilds ( ast . catches ) ;
175+ if ( ast . allways ) this . scanForChilds ( ast . allways ) ;
160176 }
161177 }
162178
@@ -170,7 +186,11 @@ block.prototype.consumeChild = function(ast) {
170186 }
171187
172188 // variables (by assignment)
173- else if ( ast . kind === 'assign' && ast . left . kind === 'variable' ) {
189+ else if (
190+ ast . kind === 'assign' &&
191+ ast . left . kind === 'variable' &&
192+ this . getRepository ( ) . options . scanVars
193+ ) {
174194 this . variables . push (
175195 ptr . create ( 'variable' , this , ast )
176196 ) ;
0 commit comments