JSDOC/ScopeNamer.js
authorAlan Knowles <alan@roojs.com>
Wed, 9 Nov 2011 09:03:13 +0000 (17:03 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 9 Nov 2011 09:03:13 +0000 (17:03 +0800)
JSDOC/ScopeNamer.js

index c69c893..097464e 100644 (file)
@@ -151,6 +151,9 @@ ScopeNamer = XObject.define(
             var name;
             var sn;
             
+            var isGlobal = scope == '_global_';
+            
+            
             while (null != (token = this.next())) {
             
                 //'function' 
@@ -202,8 +205,16 @@ ScopeNamer = XObject.define(
                 if (token.data == '{' && this.lookTok(-1).data == '=' && this.lookTok(-2).is('NAME')) {
                     
                     // could be var x = ..
-                    var jd = this.lookTok(-2).jsdoc ? this.lookTok(-2) : this.lookTok(-3); 
-                    this.walkObject(scope, this.lookTok(-2).data, token.props, jd);
+                    var jd = this.lookTok(-2).jsdoc ? this.lookTok(-2) : this.lookTok(-3);
+                    
+                    var isVar = this.lookTok(-3).name == 'VAR';
+                    
+                    // only register names of objects if 
+                    var name = this.lookTok(-2).data;
+                    name = !isGlobal && isVar ? false : name;
+                    name = !isGlobal && !name.match(/^this\./) ? false : name;
+                    
+                    this.walkObject(scope, name, token.props, jd);
                     continue;
                 }