JSDOC/ScopeNamer.js
[app.jsdoc] / JSDOC / ScopeNamer.js
index 8627736..56759a7 100644 (file)
@@ -8,7 +8,7 @@ Symbol = imports.Symbol.Symbol;
 /**
  * @class ScopeNamer
  * @extends Collapse
- * @namespace JSDOC
+ * @scope JSDOC
  * The point of this class is to iterate through the Collapsed tree
  * and add the property 'scopedName' to the tokens.
  *
@@ -88,21 +88,23 @@ ScopeNamer = XObject.define(
         this.args = this.args ? this.args.slice(0)  : [];
         Symbol.srcFile = this.filename;
         this.createJSDOC = true;
-        
+        this.global = '_global_';
        // console.dump(ar);
         
     }, 
     imports.JSDOC.Collapse.Collapse, 
     {
+        
+        global : false,
         /**
          * Call debugging
          * add/remove ';' after return to configure at present..
          * @param {String} str String to output
          */
         debugCall : function(str)  {
+            
+            if (this.filename.match(/Scope\.js/)) return print(str);
             return;
-            if (!this.filename.match(/BuildDocs\.js/)) return;
-            return   print(str);
         }, 
         
         collapseTop : true,
@@ -144,7 +146,12 @@ ScopeNamer = XObject.define(
                         st[0].jsdoc &&
                         st[0].jsdoc.getTag('scope').length
                    ) {
+                    //print(st[0].jsdoc.getTag('scope'));
                     scope = st[0].jsdoc.getTag('scope');
+                    // might be an array..
+                    if (typeof(scope) != 'String') {
+                        scope = scope[0].desc;
+                    }
                 }
                 
                 
@@ -160,7 +167,7 @@ ScopeNamer = XObject.define(
         {
             this.tokens = stmt;
             this.rewind();
-            this.debugCall("walkStatement :" + scope + '@' + this.tokens[0].line );
+            this.debugCall("walkStatement :" + JSON.stringify(scope)+ '@' + this.tokens[0].line );
              
             var name;
             var sn;
@@ -242,7 +249,23 @@ ScopeNamer = XObject.define(
                     // only register names of objects if 
                     var name = this.lookTok(-2).data;
                     name = !isGlobal && isVar ? false : name;
+                    
                     name = !isGlobal && name && !name.match(/^this\./) ? false : name;
+                    if (!isGlobal && name && name.match(/^this\./) ) { 
+                        // see if scope ends in prototype..
+                        print("SCOPE:" + JSON.stringify(scope));
+                        if (
+                            (scope.split('.').pop() == 'prototype') &&
+                            (name.split('.').length == 2)
+                        ){
+                            name = name.split('.').pop();
+                        } else {
+                            name = false;
+                        }
+                        
+                    }  else {
+                        name = false;
+                    }
                     //print(JSON.stringify(token,null,4));
                     this.walkObject(scope, name, token.props, jd);
                     continue;
@@ -269,7 +292,7 @@ ScopeNamer = XObject.define(
         
         walkFunctionDef : function (inscope, name, args, stmts, jsdocTok)
         {
-            this.debugCall("wallkFuncDef: " + inscope + '@' + this.look(0).line );
+            this.debugCall("wallkFuncDef: " + inscope + '#' + name + '@' + this.look(0).line );
             var scope = name.length ? (inscope + '.' + name) : inscope;
             if (name.length) { 
                 var symbol = new Symbol( scope , args || [] , "FUNCTION" ,  jsdocTok.jsdoc);
@@ -300,7 +323,12 @@ ScopeNamer = XObject.define(
                 case 'XObject.extend':
                 case 'Roo.apply':
                     //print(JSON.stringify(items,null,4));
-                    scope = items[0][0].data;
+                    // SHOULD WE ADD SCOPE HERE???
+                    var topscope = scope.split('.').pop();
+                    
+                    scope = (topscope == items[0][0].data) ?
+                        items[0][0].data :
+                        scope + '.' + items[0][0].data;
                     // 2nd arg is a object def
                     if (items[1][0].data != '{') {
                         return;