JSDOC/Symbol.js
[gnome.introspection-doc-generator] / JSDOC / Symbol.js
1 //<script type="text/javascript">
2
3 XObject         = imports.XObject.XObject;
4
5 SymbolSet       = imports.SymbolSet.SymbolSet;
6 //Parser          = imports.Parser.Parser;
7 DocComment      = imports.DocComment.DocComment;
8 DocTag          = imports.DocTag.DocTag;
9 /**
10         Create a new Symbol.
11         @class Represents a symbol in the source code.
12  */
13 Symbol = XObject.define(
14     function() {
15         this.init();
16         if (arguments.length) this.populate.apply(this, arguments);
17         
18     },
19     Object,
20     {
21         
22         
23         name : "",
24         defaultValue : "",
25         params : [],
26         $args : [], // original arguments used when constructing.
27         addOn : "",
28         alias : "",
29         augments : [], // Doctag[]
30         author : "",
31         classDesc : "",
32         comment : {},
33         deprecated : "",
34         desc : "",
35         //events : false,
36         example : "",
37         exceptions : [],  // Doctag[]
38         inherits : [],  // Doctag[]
39         //inheritsFrom : [],
40         isa : "OBJECT", // OBJECT//FUNCTION
41         isEvent : false,
42         isConstant : false,
43         isIgnored : false,
44         isInner : false,
45         isNamespace : false,
46         isPrivate : false,
47         isStatic : false,
48         memberOf : "",
49         methods : [], // Symbol[]
50         _name : "",
51         _params : [], //Doctag[]
52         properties : [], //Doctag[]
53         requires : [],  //Doctag[]
54         returns : [], //Doctag[]
55         see : [], //Doctag[]
56         since : "",
57         srcFile : {},
58         type : "",
59         version : "",
60         childClasses : [],
61         cfgs : {},
62         
63         
64             
65         
66         toObject : function()
67         {
68             
69             function array2object(a)
70             {
71                 
72                 var r = [];
73                 a.forEach(function(e) {
74                     r.push(e.toObject());
75                 });
76                 return r;
77             }
78             
79             var ret = { };
80             for (var i in this) {
81                 if (Symbol.hide.indexOf(i) > -1) {
82                     continue;
83                 }
84                 switch (typeof(this[i])) {
85                     case 'function':
86                         continue;
87                     case 'object':
88                         switch(i) {
89                             //arrays..
90                             case 'params' : 
91                             case 'augments' :                             
92                             case 'exceptions' :  
93                             case 'inherits' :
94                             case 'methods' :
95                             case '_params': 
96                             case 'properties': 
97                             case 'requires':
98                             case 'returns':
99                             case 'see':
100                                 ret[i] = array2object(this[i],true); 
101                                 continue;
102                                 
103                             //objects..
104                             
105                             case 'comment' :
106                                 print(JSON.stringify(this[i]));
107                                 ret[i] = this[i].toObject();
108                                 continue;
109                                 
110                             default:
111                                 print("object? :" + i);
112                                 Seed.quit();
113                         }
114                         
115                         
116                     case 'string':
117                     case 'number':
118                         ret[i] = this[i]; continue;
119                     default:
120                         print("unknown type:" + typeof(this[i]));
121                         Seed.quit();
122                    }
123             }
124             return ret;
125             
126         },
127         
128         init : function() 
129         {
130             // only initialize arrays / objects..
131             this.params = [];
132             this.$args = [];
133             
134             //this.events = [];
135             this.exceptions = [];
136             this.inherits = [];
137             //this.inheritsFrom = [];
138             this.isa = "OBJECT"; // OBJECT//FUNCTION
139             this.methods = [];
140             this._params = [];
141             this.properties = [];
142             this.requires = [];
143             this.returns = [];
144             this.see = [];
145             this.srcFile = {};
146             this.childClasses = [];
147             this.cfgs = {};
148             
149             this.comment = new DocComment();
150             this.comment.isUserComment =  false;
151             
152                
153         },
154
155         serialize : function() {
156             var keys = [];
157             for (var p in this) {
158                 keys.push (p);
159             }
160             keys = keys.sort();
161             
162             var out = "";
163             for (var i in keys) {
164                 if (typeof this[keys[i]] == "function") continue;
165                 out += "     " +keys[i]+" => "+
166                     (   
167                         (typeof(this[keys[i]]) != "object") ?  
168                             this[keys[i]] :
169                             "[" +typeof(this[keys[i]])+"]"
170                     ) + 
171                     ",\n";
172             }
173             return "\n{\n" + out + "}\n";
174         },
175
176         clone : function() {
177             var clone = new Symbol();
178             clone.populate.apply(clone, this.$args); // repopulate using the original arguments
179             clone.srcFile = this.srcFile; // not the current srcFile, the one when the original was made
180             return clone;
181         },
182
183
184
185
186         //__defineSetter__("name",
187         setName  : function(n) { 
188                 n = n.replace(/^_global_[.#-]/, ""); 
189                 n = n.replace(/\.prototype\.?/g, '#'); 
190                  n = n.replace(/#$/g, ''); 
191                 this._name = n;
192                 this.name = n; // real!
193             },
194         //);
195         //__defineGetter__("name",
196         getName : function() { return this._name; },
197         //);
198         //__defineSetter__("params", 
199         setParams  :function(v) {
200                 for (var i = 0, l = v.length; i < l; i++) {
201                     if (v[i].constructor != DocTag) { // may be a generic object parsed from signature, like {type:..., name:...}
202                         var ty = v[i].hasOwnProperty('type') ? v[i].type : '';
203                         this._params[i] = new DocTag(
204                             "param"+((ty)?" {"+ty+"}":"")+" "+v[i].name);
205                     }
206                     else {
207                         this._params[i] = v[i];
208                     }
209                 }
210                 this.params = this._params;
211             },
212         //);
213
214
215         //__defineGetter__("params",
216         getParams : function() { return this._params; },
217         //);
218
219         populate : function(
220                 /** String */ name,
221                 /** Object[] */ params,
222                 /** String */ isa,
223                 /** DocComment */ comment
224         ) {
225             this.$args = arguments;
226             //println("Symbol created: " + isa + ":" + name);
227             this.setName(name);
228             this.alias = this.getName();
229             this.setParams(params);
230             this.isa = (isa == "VIRTUAL")? "OBJECT":isa;
231             this.comment = comment || new DocComment("");
232             this.srcFile = Symbol.srcFile;
233             
234            
235             
236             if (this.is("FILE") && !this.alias) this.alias = this.srcFile;
237
238             this.setTags();
239             
240             //if (typeof PluginManager != "undefined") {
241             //    PluginManager.run("onSymbol", this);
242             //}
243         },
244
245         setTags : function() {
246             // @author
247             var authors = this.comment.getTag("author");
248             if (authors.length) {
249                 this.author = authors.map(function($){return $.desc;}).join(", ");
250             }
251             
252             /*~t
253                 assert("testing Symbol");
254                 
255                 requires("../lib/JSDOC/DocComment.js");
256                 requires("../frame/String.js");
257                 requires("../lib/JSDOC/DocTag.js");
258
259                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@author Joe Smith*"+"/"));
260                 assertEqual(sym.author, "Joe Smith", "@author tag, author is found.");
261             */
262             // @desc
263             var mth = this.comment.getTag("method");
264             if (mth.length) {
265                 this.isa = "FUNCTION";
266             }
267             // @desc
268             var descs = this.comment.getTag("desc");
269             if (descs.length) {
270                 this.desc = descs.map(function($){return $.desc;}).join("\n"); // multiple descriptions are concatenated into one
271             }
272             
273             /*~t
274                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@desc This is a description.*"+"/"));
275                 assertEqual(sym.desc, "This is a description.", "@desc tag, description is found.");
276             */
277             
278             // @overview
279             if (this.is("FILE")) {
280                 if (!this.alias) this.alias = this.srcFile;
281                 
282                 var overviews = this.comment.getTag("overview");
283                 if (overviews.length) {
284                     this.desc = [this.desc].concat(overviews.map(function($){return $.desc;})).join("\n");
285                 }
286             }
287             
288             /*~t
289                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@overview This is an overview.*"+"/"));
290                 assertEqual(sym.desc, "\nThis is an overview.", "@overview tag, description is found.");
291             */
292             
293             // @since
294             var sinces = this.comment.getTag("since");
295             if (sinces.length) {
296                 this.since = sinces.map(function($){return $.desc;}).join(", ");
297             }
298             
299             /*~t
300                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@since 1.01*"+"/"));
301                 assertEqual(sym.since, "1.01", "@since tag, description is found.");
302             */
303             
304             // @constant
305             if (this.comment.getTag("constant").length) {
306                 this.isConstant = true;
307                 this.isa = 'OBJECT';
308             }
309             
310             /*~t
311                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@constant*"+"/"));
312                 assertEqual(sym.isConstant, true, "@constant tag, isConstant set.");
313             */
314             
315             // @version
316             var versions = this.comment.getTag("version");
317             if (versions.length) {
318                 this.version = versions.map(function($){return $.desc;}).join(", ");
319             }
320             
321             /*~t
322                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@version 2.0x*"+"/"));
323                 assertEqual(sym.version, "2.0x", "@version tag, version is found.");
324             */
325             
326             // @deprecated
327             var deprecateds = this.comment.getTag("deprecated");
328             if (deprecateds.length) {
329                 this.deprecated = deprecateds.map(function($){return $.desc;}).join("\n");
330             }
331             
332             /*~t
333                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@deprecated Use other method.*"+"/"));
334                 assertEqual(sym.deprecated, "Use other method.", "@deprecated tag, desc is found.");
335             */
336             
337             // @example
338             var examples = this.comment.getTag("example");
339             if (examples.length) {
340                 this.example = examples[0];
341             }
342             
343             /*~t
344                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@example This\n  is an example.*"+"/"));
345                 assertEqual(sym.example, "This\n  is an example.", "@deprecated tag, desc is found.");
346             */
347             
348             // @see
349             var sees = this.comment.getTag("see");
350             if (sees.length) {
351                 var thisSee = this.see;
352                 sees.map(function($){thisSee.push($.desc);});
353             }
354             
355             /*~t
356                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@see The other thing.*"+"/"));
357                 assertEqual(sym.see, "The other thing.", "@see tag, desc is found.");
358             */
359             
360             // @class
361             var classes = this.comment.getTag("class");
362             if (classes.length) {
363                 this.isa = "CONSTRUCTOR";
364                 this.classDesc = classes[0].desc; // desc can't apply to the constructor as there is none.
365                 if (!this.classDesc) {
366                     this.classDesc = this.desc;
367                    }
368                 
369                 
370             }
371             
372             /*~t
373                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@class This describes the class.*"+"/"));
374                 assertEqual(sym.isa, "CONSTRUCTOR", "@class tag, makes symbol a constructor.");
375                 assertEqual(sym.classDesc, "This describes the class.", "@class tag, class description is found.");
376             */
377             
378             // @namespace
379             var namespaces = this.comment.getTag("namespace");
380             if (namespaces.length) {
381                 this.classDesc = namespaces[0].desc+"\n"+this.desc; // desc can't apply to the constructor as there is none.
382                 this.isNamespace = true;
383             }
384             
385             /*~t
386                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@namespace This describes the namespace.*"+"/"));
387                 assertEqual(sym.classDesc, "This describes the namespace.\n", "@namespace tag, class description is found.");
388             */
389             
390             // @param
391             var params = this.comment.getTag("param");
392             if (params.length) {
393                 // user-defined params overwrite those with same name defined by the parser
394                 var thisParams = this.getParams();
395
396                 if (thisParams.length == 0) { // none exist yet, so just bung all these user-defined params straight in
397                     this.setParams(params);
398                 }
399                 else { // need to overlay these user-defined params on to existing parser-defined params
400                     for (var i = 0, l = params.length; i < l; i++) {
401                         if (thisParams[i]) {
402                             if (params[i].type) thisParams[i].type = params[i].type;
403                             thisParams[i].name = params[i].name;
404                             thisParams[i].desc = params[i].desc;
405                             thisParams[i].isOptional = params[i].isOptional;
406                             thisParams[i].defaultValue = params[i].defaultValue;
407                         }
408                         else thisParams[i] = params[i];
409                     }
410                 }
411             }
412             
413             /*~t
414                 var sym = new Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new DocComment("/**Description.*"+"/"));
415                 assertEqual(sym.params.length, 1, "parser defined param is found.");
416                 
417                 sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**Description.\n@param {array} pages*"+"/"));
418                 assertEqual(sym.params.length, 1, "user defined param is found.");
419                 assertEqual(sym.params[0].type, "array", "user defined param type is found.");
420                 assertEqual(sym.params[0].name, "pages", "user defined param name is found.");
421                 
422                 sym = new Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new DocComment("/**Description.\n@param {string} uid*"+"/"));
423                 assertEqual(sym.params.length, 1, "user defined param overwrites parser defined param.");
424                 assertEqual(sym.params[0].type, "string", "user defined param type overwrites parser defined param type.");
425                 assertEqual(sym.params[0].name, "uid", "user defined param name overwrites parser defined param name.");
426             
427                 sym = new Symbol("foo", [{type: "array", name: "pages"}, {type: "number", name: "count"}], "FUNCTION", new DocComment("/**Description.\n@param {string} uid*"+"/"));
428                 assertEqual(sym.params.length, 2, "user defined params  overlay parser defined params.");
429                 assertEqual(sym.params[1].type, "number", "user defined param type overlays parser defined param type.");
430                 assertEqual(sym.params[1].name, "count", "user defined param name overlays parser defined param name.");
431
432                 sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**Description.\n@param {array} pages The pages description.*"+"/"));
433                 assertEqual(sym.params.length, 1, "user defined param with description is found.");
434                 assertEqual(sym.params[0].desc, "The pages description.", "user defined param description is found.");
435             */
436             
437             // @constructor
438             if (this.comment.getTag("constructor").length) {
439                 this.isa = "CONSTRUCTOR";
440             }
441             
442             /*~t
443                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@constructor*"+"/"));
444                 assertEqual(sym.isa, "CONSTRUCTOR", "@constructor tag, makes symbol a constructor.");
445             */
446             
447             // @static
448             if (this.comment.getTag("static").length) {
449                 this.isStatic = true;
450                 if (this.isa == "CONSTRUCTOR") {
451                     this.isNamespace = true;
452                 }
453             }
454             
455                 // @static
456             if (this.comment.getTag("singleton").length) {
457                 this.isStatic = true;
458                 //if (this.isa == "CONSTRUCTOR") {
459                 //      this.isNamespace = true;
460                 //}
461             }
462             
463             
464             
465             /*~t
466                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@static\n@constructor*"+"/"));
467                 assertEqual(sym.isStatic, true, "@static tag, makes isStatic true.");
468                 assertEqual(sym.isNamespace, true, "@static and @constructor tag, makes isNamespace true.");
469             */
470             
471             // @inner
472             if (this.comment.getTag("inner").length) {
473                 this.isInner = true;
474                 this.isStatic = false;
475             }
476             
477             /*~t
478                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@inner*"+"/"));
479                 assertEqual(sym.isStatic, false, "@inner tag, makes isStatic false.");
480                 assertEqual(sym.isInner, true, "@inner makes isInner true.");
481             */
482             
483             // @field
484             if (this.comment.getTag("field").length) {
485                 this.isa = "OBJECT";
486             }
487             
488             /*~t
489                 var sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**@field*"+"/"));
490                 assertEqual(sym.isa, "OBJECT", "@field tag, makes symbol an object.");
491             */
492             
493             // @function
494             if (this.comment.getTag("function").length) {
495                 this.isa = "FUNCTION";
496             }
497             
498             // @param
499             if (this.comment.getTag("param").length && this.isa == "OBJECT" ) {
500                 // change a property to a function..
501                 this.isa = "FUNCTION";
502             }
503             
504             
505             /*~t
506                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@function*"+"/"));
507                 assertEqual(sym.isa, "FUNCTION", "@function tag, makes symbol a function.");
508             */
509             
510             // @event
511             var events = this.comment.getTag("event");
512             if (events.length) {
513                 this.isa = "FUNCTION";
514                 this.isEvent = true;
515             }
516             
517             /*~t
518                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@event*"+"/"));
519                 assertEqual(sym.isa, "FUNCTION", "@event tag, makes symbol a function.");
520                 assertEqual(sym.isEvent, true, "@event makes isEvent true.");
521             */
522             
523             // @name
524             var names = this.comment.getTag("name");
525             if (names.length) {
526                 this.setName(names[0].desc);
527             }
528             
529             /*~t
530                 // todo
531             */
532             
533             // @property
534             var properties = this.comment.getTag("property");
535             if (properties.length) {
536                 thisProperties = this.properties;
537                 for (var i = 0; i < properties.length; i++) {
538                     var property = new Symbol(this.alias+"#"+properties[i].name, [], "OBJECT", new DocComment("/**"+properties[i].desc+"\n@name "+properties[i].name+"\n@memberOf "+this.alias+"#*/"));
539                     // TODO: shouldn't the following happen in the addProperty method of Symbol?
540                     property.name = properties[i].name;
541                     property.memberOf = this.alias;
542                     if (properties[i].type) property.type = properties[i].type;
543                     if (properties[i].defaultValue) property.defaultValue = properties[i].defaultValue;
544                     this.addProperty(property);
545                     imports.Parser.Parser.addSymbol(property);
546                 }
547             }
548             
549             // config..
550             var conf = this.comment.getTag("cfg");
551             if (conf.length) {
552                 for (var i = 0; i < conf.length; i++) {
553                     this.addConfig(conf[i]);
554                 }
555             }
556             
557             /*~t
558                 // todo
559             */
560
561             // @return
562             var returns = this.comment.getTag("return");
563             if (returns.length) { // there can be many return tags in a single doclet
564                 this.returns = returns;
565                 this.type = returns.map(function($){return $.type}).join(", ");
566             }
567             
568             /*~t
569                 // todo
570             */
571             
572             // @exception
573             this.exceptions = this.comment.getTag("throws");
574             
575             /*~t
576                 // todo
577             */
578             
579             // @requires
580             var requires = this.comment.getTag("requires");
581             if (requires.length) {
582                 this.requires = requires.map(function($){return $.desc});
583             }
584             
585             /*~t
586                 // todo
587             */
588             
589             // @type
590             var types = this.comment.getTag("type");
591             if (types.length) {
592                 this.type = types[0].desc; //multiple type tags are ignored
593             }
594             
595             /*~t
596                 // todo
597             */
598             
599             // @private
600             if (this.comment.getTag("private").length || this.isInner) {
601                 this.isPrivate = true;
602             }
603             
604             // @ignore
605             if (this.comment.getTag("ignore").length) {
606                 this.isIgnored = true;
607             }
608             
609             /*~t
610                 // todo
611             */
612             
613             // @inherits ... as ...
614             var inherits = this.comment.getTag("inherits");
615             if (inherits.length) {
616                 for (var i = 0; i < inherits.length; i++) {
617                     if (/^\s*([a-z$0-9_.#-]+)(?:\s+as\s+([a-z$0-9_.#]+))?/i.test(inherits[i].desc)) {
618                         var inAlias = RegExp.$1;
619                         var inAs = RegExp.$2 || inAlias;
620
621                         if (inAlias) inAlias = inAlias.replace(/\.prototype\.?/g, "#");
622                         
623                         if (inAs) {
624                             inAs = inAs.replace(/\.prototype\.?/g, "#");
625                             inAs = inAs.replace(/^this\.?/, "#");
626                         }
627
628                         if (inAs.indexOf(inAlias) != 0) { //not a full namepath
629                             var joiner = ".";
630                             if (this.alias.charAt(this.alias.length-1) == "#" || inAs.charAt(0) == "#") {
631                                 joiner = "";
632                             }
633                             inAs = this.alias + joiner + inAs;
634                         }
635                     }
636                     this.inherits.push({alias: inAlias, as: inAs});
637                 }
638             }
639             
640             /*~t
641                 // todo
642             */
643
644             // @augments
645             this.augments = this.comment.getTag("augments");
646             
647             //@extends - Ext
648             if (this.comment.getTag("extends")) {   
649                 this.augments = this.comment.getTag("extends");
650             }
651             
652             
653             // @default
654             var defaults = this.comment.getTag("default");
655             if (defaults.length) {
656                 if (this.is("OBJECT")) {
657                     this.defaultValue = defaults[0].desc;
658                 }
659             }
660             
661             /*~t
662                 // todo
663             */
664             
665             // @memberOf
666             var memberOfs = this.comment.getTag("memberOf");
667             if (memberOfs.length) {
668                 this.memberOf = memberOfs[0].desc;
669                 this.memberOf = this.memberOf.replace(/\.prototype\.?/g, "#");
670             }
671
672             /*~t
673                 // todo
674             */
675             
676             // @public
677             if (this.comment.getTag("public").length) {
678                 this.isPrivate = false;
679             }
680             
681             /*~t
682                 // todo
683             */
684         },
685
686         is : function(what) {
687             return this.isa === what;
688         },
689
690         isBuiltin : function() {
691             return SymbolSet.isBuiltin(this.alias);
692         },
693
694         setType : function(/**String*/comment, /**Boolean*/overwrite) {
695             if (!overwrite && this.type) return;
696             var typeComment = DocComment.unwrapComment(comment);
697             this.type = typeComment;
698         },
699
700         inherit : function(symbol) {
701             if (!this.hasMember(symbol.name) && !symbol.isInner) {
702                 if (symbol.is("FUNCTION"))
703                     this.methods.push(symbol);
704                 else if (symbol.is("OBJECT"))
705                     this.properties.push(symbol);
706             }
707         },
708
709         hasMember : function(name) {
710             return (this.hasMethod(name) || this.hasProperty(name));
711         },
712
713         addMember : function(symbol) {
714             //println("ADDMEMBER: " + this.name +  " ++ " + symbol.name);
715             
716             if (symbol.comment.getTag("cfg").length == 1) { 
717                 symbol.comment.getTag("cfg")[0].memberOf = this.alias;
718                 this.addConfig(symbol.comment.getTag("cfg")[0]);
719                 return;
720             }
721             
722             if (symbol.is("FUNCTION")) { this.addMethod(symbol); }
723             else if (symbol.is("OBJECT")) { this.addProperty(symbol); }
724         },
725
726         hasMethod : function(name) {
727             var thisMethods = this.methods;
728             for (var i = 0, l = thisMethods.length; i < l; i++) {
729                 if (thisMethods[i].name == name) return true;
730                 if (thisMethods[i].alias == name) return true;
731             }
732             return false;
733         },
734
735         addMethod : function(symbol) {
736             var methodAlias = symbol.alias;
737             var thisMethods = this.methods;
738             for (var i = 0, l = thisMethods.length; i < l; i++) {
739                 if (thisMethods[i].alias == methodAlias) {
740                     thisMethods[i] = symbol; // overwriting previous method
741                     return;
742                 }
743             }
744             thisMethods.push(symbol); // new method with this alias
745         },
746
747         hasProperty : function(name) {
748             var thisProperties = this.properties;
749             for (var i = 0, l = thisProperties.length; i < l; i++) {
750                 if (thisProperties[i].name == name) return true;
751                 if (thisProperties[i].alias == name) return true;
752             }
753             return false;
754         },
755
756         addProperty : function(symbol) {
757             var propertyAlias = symbol.alias;
758             var thisProperties = this.properties;
759             for (var i = 0, l = thisProperties.length; i < l; i++) {
760                 if (thisProperties[i].alias == propertyAlias) {
761                     thisProperties[i] = symbol; // overwriting previous property
762                     return;
763                 }
764             }
765
766             thisProperties.push(symbol); // new property with this alias
767         },
768         
769         addDocTag : function(docTag)
770         {
771             this.comment.tags.push(docTag);
772             if (docTag.title == 'cfg') {
773                 this.addConfig(docTag);
774             }
775             
776         },
777         
778         addConfig : function(docTag)
779         {
780             if (typeof(docTag['memberOf']) == 'undefined') {
781                 // remove prototype data...
782                 //var a = this.alias.split('#')[0];
783                 //docTag.memberOf = a;
784                 docTag.memberOf = this.alias;
785             }
786             if (typeof(this.cfgs[docTag.name]) == 'undefined') {
787                 this.cfgs[docTag.name] = docTag;
788             }
789             
790         },
791         configToArray: function()
792         {
793             var r = [];
794             for(var ci in this.cfgs) {
795                 // dont show hidden!!
796                 if (this.cfgs[ci].desc.match(/@hide/)) {
797                     continue;
798                 }
799                 r.push(this.cfgs[ci]); 
800                
801             }
802             return r;
803         }
804 });
805
806 /**
807  * Elements that are not serialized
808  * 
809  */
810 Symbol.hide = [ 
811     '$args' // not needed AFAIK
812 ]
813
814 Symbol.srcFile = ""; //running reference to the current file being parsed
815
816
817 Symbol.fromDump = function(t)
818 {
819     var ns = new Symbol();
820     for (var i in t) {
821         if (typeof(ns[i]) == "undefined") {
822             println("ERR:no default for Symbol:"+ i);
823         }
824         ns[i] = t[i];
825     }
826     return ns;
827 }