sync fixes
[app.jsdoc] / JSDOC / SymbolSet.js
index bd05255..377e391 100644 (file)
@@ -1,22 +1,29 @@
-//<script type="text/javascript">
-
  
 XObject         = imports.XObject.XObject;
 DocComment      = imports.DocComment.DocComment;
-// circular references..
-///Options         = imports.BuildDocs.Options;
-//Parser          = imports.Parser.Parser;
-//Symbol          = imports.Symbol.Symbol;
-
 
+/**
+ * The point of this class is to store and manage all the symbols
+ *
+ * @scope JSDOC
+ * @class ScopeSet
+ * 
+ *
+ */ 
 
 SymbolSet = XObject.define(
-    function(opts) {
+    function(cfg) {
+        XObject.extend(this, cfg || {});
         this.init();
     },
     Object,
     {
-        
+        /**
+         * @type {Object}
+         * Key:value map of alias=>sybmol.
+         */
         _index : false,
         
         
@@ -44,11 +51,20 @@ SymbolSet = XObject.define(
             
             
             if (this.hasSymbol(symbol.alias)) {
-                SymbolSet.parser.LOG.warn("Overwriting symbol documentation for: "+symbol.alias + ".");
+                SymbolSet.LOG.warn("Overwriting symbol documentation for: "+symbol.alias + ".");
             }
             this._index[symbol.alias] = symbol;
         },
-
+        
+        
+        listPrint : function ()
+        {
+            for(var i in this._index) {
+                print(i);
+            }
+            
+        },
+        
         getSymbol : function(alias) {
             
             if (this.hasSymbol(alias)) return this._index[alias];
@@ -75,6 +91,7 @@ SymbolSet = XObject.define(
 
 
         deleteSymbol : function(alias) {
+            //print("DELETE: " + alias);
             if (!this.hasSymbol(alias)) return;
             delete this._index[alias];
         },
@@ -95,8 +112,13 @@ SymbolSet = XObject.define(
             this.resolveMemberOf();
             this.resolveAugments();
         },
-
-        resolveBorrows : function() {
+        /**
+         * Resolve borrows -
+         *  = it reads 'inherits' loops thorugh it.. not sure yet what it does..
+         *
+         */
+        resolveBorrows : function()
+        {
             for (p in this._index) {
                 var symbol = this._index[p];
                 
@@ -108,14 +130,14 @@ SymbolSet = XObject.define(
                 for (var i = 0; i < borrows.length; i++) {
                     var borrowed = this.getSymbol(borrows[i].alias);
                     if (!borrowed) {
-                        SymbolSet.parser.LOG.warn("Can't borrow undocumented "+borrows[i].alias+".");
+                        SymbolSet.LOG.warn("Can't borrow undocumented "+borrows[i].alias+".");
                         continue;
                     }
                     
                     var borrowAsName = borrows[i].as;
                     var borrowAsAlias = borrowAsName;
                     if (!borrowAsName) {
-                        SymbolSet.parser.LOG.warn("Malformed @borrow, 'as' is required.");
+                        SymbolSet.LOG.warn("Malformed @borrow, 'as' is required.");
                         continue;
                     }
                     
@@ -139,24 +161,31 @@ SymbolSet = XObject.define(
                 }
             }
         },
-
-        resolveMemberOf : function() {
+        /**
+         * puts all the properties, cfg, ??events and methods into the owning class.
+         *
+         *
+         */
+        resolveMemberOf : function()
+        {
             for (var p in this._index) {
                 var symbol = this.getSymbol(p);
                 
-                if (symbol.is("FILE") || symbol.is("GLOBAL")) continue;
+                if (symbol.is("FILE") || symbol.is("GLOBAL")) {
+                    continue;
+                }
                 
                 // the memberOf value was provided in the @memberOf tag
-                else if (symbol.memberOf) {
+                if (symbol.memberOf) {
                     var parts = symbol.alias.match(new RegExp("^("+symbol.memberOf+"[.#-])(.+)$"));
                     
                     // like foo.bar is a memberOf foo
                     if (parts) {
                         symbol.memberOf = parts[1];
                         symbol.name = parts[2];
-                    }
-                    // like bar is a memberOf foo
-                    else {
+                   
+                        // like bar is a memberOf foo
+                     } else {
                         var joiner = symbol.memberOf.charAt(symbol.memberOf.length-1);
                         if (!/[.#-]/.test(joiner)) symbol.memberOf += ".";
                         
@@ -185,7 +214,7 @@ SymbolSet = XObject.define(
                             symbol.isInner = false;
                             break;
                             
-                        case '-' :
+                        case '-' :  // WTF is this about???
                             symbol.isStatic = false;
                             symbol.isInner = true;
                             break;
@@ -202,37 +231,66 @@ SymbolSet = XObject.define(
                 if (symbol.memberOf.match(/[.#-]$/)) {
                     symbol.memberOf = symbol.memberOf.substr(0, symbol.memberOf.length-1);
                 }
+                
                 //print("looking for memberOf: " + symbol.memberOf + " FOR " + symbol.alias);
                 // add to parent's methods or properties list
                 if (symbol.memberOf) {
+                    
                     var container = this.getSymbol(symbol.memberOf);
                     if (!container) {
                         if (SymbolSet.isBuiltin(symbol.memberOf)) {
                             container = imports.ScopeNamer.ScopeNamer.addBuiltin(symbol.memberOf);
                         }
                         else {
-                           // print("symbol NOT a BUILT IN - createing a container");
+                            print("symbol NOT a BUILT IN - createing a container " + symbol.memberOf);
                             // Eg. Ext.y.z (missing y)
                             // we need to add in the missing symbol...
-                            container = new imports.Symbol.Symbol(symbol.memberOf, [], "OBJECT", new DocComment(""));
+                            container = new imports.Symbol.Symbol(symbol.memberOf, [], "OBJECT",
+                                                            new DocComment("@namespace " + symbol.memberOf));
                             container.isNamespace = true;
                             this.addSymbol( container );
-                           // print(container.toSource());
+                            if (container.addMember(symbol)) {
+                                //print("DELETE (added to container..): " + container.alias + ' => ' + symbol.alias);
+                                this.deleteSymbol(symbol.alias);
+                            }
+                            // print(container.toSource());
                             //container = this.getSymbol(symbol.memberOf);
                             // fake container ... so dont ad symbols to it..
                             continue;
-                            container = false;
+                            //container = false;
                             //LOG.warn("Can't document "+symbol.name +" as a member of undocumented symbol "+symbol.memberOf+".");
                             //LOG.warn("We only have the following symbols: \n" + 
                             //    this.keys.toSource());
                         }
                     }
                     
-                    if (container && !container.isNamespace) container.addMember(symbol);
+                    //if (container && !container.isNamespace) {
+                    if (container && !SymbolSet.isBuiltin(symbol.alias)) {
+                        if (container.alias == '_global_' && symbol.is('OBJECT')) {
+                            continue;
+                        }
+                        if (container.addMember(symbol)) {
+                            //print("DELETE (added to container..): " + container.alias + ' => ' + symbol.alias);
+                            this.deleteSymbol(symbol.alias);
+                        }
+                    }
+                    continue;
                 }
+                
+                // not a member of.. let's log them...
+                print("NOT able to resolve memberOf: "  + symbol.alias);
+                
+                
             }
         },
 
+
+        /**
+         * sort out inhertied stuff...
+         * a) calls buildAugmentsList to find out what this class extends.
+         * b) adds to symbol.inheritsFrom.
+         * c) calls sybmol.inherit / symbol.addConfig to each of the child props..
+         */
         resolveAugments : function() {
             // does this sort out multiple extends???
             for (var p in this._index) {
@@ -240,6 +298,8 @@ SymbolSet = XObject.define(
                 this.buildAugmentsList(symbol); /// build heirachy of inheritance...
                 if (symbol.alias == "_global_" || symbol.is("FILE")) continue;
                 
+                //print(JSON.stringify(symbol.augments, null, 4));
+                
                 var augments = symbol.augments;
                 for(var ii = 0, il = augments.length; ii < il; ii++) {
                     var contributer = this.getSymbol(augments[ii]);
@@ -253,25 +313,26 @@ SymbolSet = XObject.define(
                         //    imports.BuildDocs.Options.LOG.warn("Can't resolve augments: Circular reference: "+symbol.alias+" inherits from "+contributer.alias+" more than once.");
                         //}
                         //else {
-                            var cmethods = contributer.methods;
-                            var cproperties = contributer.properties;
-                            var cfgs = contributer.cfgs;
-                            for (var ci = 0, cl = cmethods.length; ci < cl; ci++) {   
-                                symbol.inherit(cmethods[ci]);
-                            }
-                            for (var ci = 0, cl = cproperties.length; ci < cl; ci++) {
-                                symbol.inherit(cproperties[ci]);
-                            }
-                            for (var ci in cfgs) {
-                                symbol.addConfig(cfgs[ci]);
-                            }
-                            
+                        
+                        var cmethods = contributer.methods;
+                        var cproperties = contributer.properties;
+                        var cfgs = contributer.cfgs;
+                        for (var ci = 0, cl = cmethods.length; ci < cl; ci++) {   
+                            symbol.inherit(cmethods[ci]);
+                        }
+                        for (var ci = 0, cl = cproperties.length; ci < cl; ci++) {
+                            symbol.inherit(cproperties[ci]);
+                        }
+                        for (var ci in cfgs) {
+                            symbol.addConfig(cfgs[ci]);
+                        }
+                        
                                 
                         //}
                     }
                     else {
                         
-                        SymbolSet.parser.LOG.warn("Can't augment contributer: '"+augments[ii]+"', not found. FOR: " + symbol.alias);
+                        SymbolSet.LOG.warn("Can't augment contributer: '"+augments[ii]+"', not found. FOR: " + symbol.alias);
                         
                         //LOG.warn("We only have the following symbols: \n" + 
                           //      this.keys().toSource().split(",").join(",    \n"));
@@ -330,11 +391,16 @@ SymbolSet = XObject.define(
 })
 
 SymbolSet.isBuiltin = function(name) {
-    return (SymbolSet.isBuiltin.coreObjects.indexOf(name) > -1);
+    return (SymbolSet.isBuiltin_coreObjects.indexOf(name) > -1);
 }
-SymbolSet.isBuiltin .coreObjects = [
-    '_global_', 'Array', 'Boolean', 'Date', 'Function', 
+// private
+SymbolSet.isBuiltin_coreObjects = [
+    
+  //   '_global_',
+    'Array', 'Boolean', 'Date', 'Function', 
     'Math', 'Number', 'Object', 'RegExp', 'String'
 ];
-
-SymbolSet.parser = false;  // reference to parser ??? might not be needed..
\ No newline at end of file
+/**
+ * reference to parser ??? might not be needed..
+ */
+SymbolSet.LOG = false;  
\ No newline at end of file