@@ -60,8 +60,9 @@ module.exports = {
6060 * @param {node } item
6161 * @returns {String|false|undefined }
6262 */
63- _declName : function ( item ) {
64- return item [ 0 ] === 'declaration' && item [ 1 ] [ 1 ] [ 1 ] ;
63+ _getDeclName : function ( node ) {
64+ if ( node [ 0 ] !== 'declaration' ) return ;
65+ return node [ 1 ] [ 1 ] [ 1 ] ;
6566 } ,
6667
6768 /**
@@ -71,10 +72,13 @@ module.exports = {
7172 * @param {node } item
7273 * @returns {String|false|undefined }
7374 */
74- _valName : function ( item ) {
75- return item [ 0 ] === 'declaration' && item [ 2 ] && item [ 2 ] [ 2 ] &&
76- ( ( item [ 2 ] [ 2 ] [ 0 ] === 'funktion' && item [ 2 ] [ 2 ] [ 1 ] [ 0 ] === 'ident' && item [ 2 ] [ 2 ] [ 1 ] [ 1 ] ) ||
77- ( item [ 2 ] [ 2 ] [ 0 ] === 'ident' && item [ 2 ] [ 2 ] [ 1 ] ) ) ;
75+ _getValName : function ( node ) {
76+ if ( node [ 0 ] !== 'declaration' || ! node [ 2 ] || ! node [ 2 ] [ 2 ] )
77+ return ;
78+ if ( node [ 2 ] [ 2 ] [ 0 ] === 'ident' )
79+ return node [ 2 ] [ 2 ] [ 1 ] ;
80+ if ( node [ 2 ] [ 2 ] [ 0 ] === 'funktion' )
81+ return node [ 2 ] [ 2 ] [ 1 ] [ 1 ] ;
7882 } ,
7983
8084 /**
@@ -140,18 +144,18 @@ module.exports = {
140144 var _this = this ;
141145
142146 // Gathering Info
143- this . _walk ( node , this . _declName , function ( info , i ) {
147+ this . _walk ( node , this . _getDeclName , function ( info , i ) {
144148 _this . _updateDict ( info , dict , node [ i - 1 ] [ 1 ] ) ;
145149 } ) ;
146- this . _walk ( node , this . _valName , function ( info , i ) {
150+ this . _walk ( node , this . _getValName , function ( info , i ) {
147151 _this . _updateDict ( info , dict , node [ i ] [ 2 ] [ 1 ] [ 1 ] ) ;
148152 } ) ;
149153
150154 // Update nodes
151- this . _walk ( node , this . _declName , function ( info , i ) {
155+ this . _walk ( node , this . _getDeclName , function ( info , i ) {
152156 node [ i - 1 ] [ 1 ] = _this . _updateIndent ( info , dict , node [ i - 1 ] [ 1 ] ) ;
153157 } ) ;
154- this . _walk ( node , this . _valName , function ( info , i ) {
158+ this . _walk ( node , this . _getValName , function ( info , i ) {
155159 node [ i ] [ 2 ] [ 1 ] [ 1 ] = _this . _updateIndent ( info , dict , node [ i ] [ 2 ] [ 1 ] [ 1 ] ) ;
156160 } ) ;
157161 }
0 commit comments