JSDOC/TokenReader.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         toJSON : function()
67         {
68             
69            
70             var ret = { '*object' : 'Symbol' };
71             for (var i in this) {
72                 if (Symbol.hide.indexOf(i) > -1) {
73                     continue;
74                 }
75                 switch (typeof(this[i])) {
76                     case 'function':
77                         continue;
78                     case 'object':
79                         switch(i) {
80                             //arrays..
81                             case 'params' : 
82                             case 'augments' :                             
83                             case 'exceptions' :  
84                             case 'inherits' :
85                             case 'methods' :
86                             case '_params': 
87                             case 'properties': 
88                             case 'requires':
89                             case 'returns':
90                             case 'see':
91                             case 'cfgs': // key val of doctags..
92                             case 'comment' :
93                                 ret[i] = this[i]
94                                 continue; 
95                             
96                             //skip
97                             case 'inheritsFrom':
98                             case 'childClasses':
99                                 continue;
100             
101                             default:
102                                 print("object? :" + i);
103                                 Seed.quit();
104                         }
105                         
106                         
107                     case 'string':
108                     case 'number':
109                     case 'boolean':
110                         ret[i] = this[i]; continue;
111                     default:
112                         
113                         print("unknown type:" + typeof(this[i]));
114                         print(JSON.stringify(this));
115                         Seed.quit();
116                    }
117             }
118             return ret;
119             
120         },
121         
122         init : function() 
123         {
124             // only initialize arrays / objects..
125             this.params = [];
126             this.$args = [];
127             
128             //this.events = [];
129             this.exceptions = [];
130             this.inherits = [];
131             //
132             this.isa = "OBJECT"; // OBJECT//FUNCTION
133             this.methods = [];
134             this._params = [];
135             this.properties = [];
136             this.requires = [];
137             this.returns = [];
138             this.see = [];
139             this.srcFile = {};
140             
141             
142             this.cfgs = {};
143             // derived later?
144             this.inheritsFrom = [];
145             this.childClasses = [];
146             
147             this.comment = new DocComment();
148             this.comment.isUserComment =  false;
149             
150                
151         },
152
153         serialize : function() {
154             var keys = [];
155             for (var p in this) {
156                 keys.push (p);
157             }
158             keys = keys.sort();
159             
160             var out = "";
161             for (var i in keys) {
162                 if (typeof this[keys[i]] == "function") continue;
163                 out += "     " +keys[i]+" => "+
164                     (   
165                         (typeof(this[keys[i]]) != "object") ?  
166                             this[keys[i]] :
167                             "[" +typeof(this[keys[i]])+"]"
168                     ) + 
169                     ",\n";
170             }
171             return "\n{\n" + out + "}\n";
172         },
173
174         clone : function() {
175             var clone = new Symbol();
176             clone.populate.apply(clone, this.$args); // repopulate using the original arguments
177             clone.srcFile = this.srcFile; // not the current srcFile, the one when the original was made
178             return clone;
179         },
180
181
182
183
184         //__defineSetter__("name",
185         setName  : function(n) { 
186                 n = n.replace(/^_global_[.#-]/, ""); 
187                 n = n.replace(/\.prototype\.?/g, '#'); 
188                  n = n.replace(/#$/g, ''); 
189                 this._name = n;
190                 this.name = n; // real!
191             },
192         //);
193         //__defineGetter__("name",
194         getName : function() { return this._name; },
195         //);
196         //__defineSetter__("params", 
197         setParams  :function(v) {
198                 for (var i = 0, l = v.length; i < l; i++) {
199                     if (v[i].constructor != DocTag) { // may be a generic object parsed from signature, like {type:..., name:...}
200                         var ty = v[i].hasOwnProperty('type') ? v[i].type : '';
201                         this._params[i] = new DocTag(
202                             "param"+((ty)?" {"+ty+"}":"")+" "+v[i].name);
203                     }
204                     else {
205                         this._params[i] = v[i];
206                     }
207                 }
208                 this.params = this._params;
209             },
210         //);
211
212
213         //__defineGetter__("params",
214         getParams : function() { return this._params; },
215         //);
216
217         populate : function(
218                 /** String */ name,
219                 /** Object[] */ params,
220                 /** String */ isa,
221                 /** DocComment */ comment
222         ) {
223             this.$args = arguments;
224             //println("Symbol created: " + isa + ":" + name);
225             this.setName(name);
226             this.alias = this.getName();
227             this.setParams(params);
228             this.isa = (isa == "VIRTUAL")? "OBJECT":isa;
229             this.comment = comment || new DocComment("");
230             this.srcFile = Symbol.srcFile;
231             
232            
233             
234             if (this.is("FILE") && !this.alias) this.alias = this.srcFile;
235
236             this.setTags();
237             
238             //if (typeof PluginManager != "undefined") {
239             //    PluginManager.run("onSymbol", this);
240             //}
241         },
242
243         setTags : function() {
244             // @author
245             var authors = this.comment.getTag("author");
246             if (authors.length) {
247                 this.author = authors.map(function($){return $.desc;}).join(", ");
248             }
249             
250             /*~t
251                 assert("testing Symbol");
252                 
253                 requires("../lib/JSDOC/DocComment.js");
254                 requires("../frame/String.js");
255                 requires("../lib/JSDOC/DocTag.js");
256
257                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@author Joe Smith*"+"/"));
258                 assertEqual(sym.author, "Joe Smith", "@author tag, author is found.");
259             */
260             // @desc
261             var mth = this.comment.getTag("method");
262             if (mth.length) {
263                 this.isa = "FUNCTION";
264             }
265             // @desc
266             var descs = this.comment.getTag("desc");
267             if (descs.length) {
268                 this.desc = descs.map(function($){return $.desc;}).join("\n"); // multiple descriptions are concatenated into one
269             }
270             
271             /*~t
272                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@desc This is a description.*"+"/"));
273                 assertEqual(sym.desc, "This is a description.", "@desc tag, description is found.");
274             */
275             
276             // @overview
277             if (this.is("FILE")) {
278                 if (!this.alias) this.alias = this.srcFile;
279                 
280                 var overviews = this.comment.getTag("overview");
281                 if (overviews.length) {
282                     this.desc = [this.desc].concat(overviews.map(function($){return $.desc;})).join("\n");
283                 }
284             }
285             
286             /*~t
287                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@overview This is an overview.*"+"/"));
288                 assertEqual(sym.desc, "\nThis is an overview.", "@overview tag, description is found.");
289             */
290             
291             // @since
292             var sinces = this.comment.getTag("since");
293             if (sinces.length) {
294                 this.since = sinces.map(function($){return $.desc;}).join(", ");
295             }
296             
297             /*~t
298                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@since 1.01*"+"/"));
299                 assertEqual(sym.since, "1.01", "@since tag, description is found.");
300             */
301             
302             // @constant
303             if (this.comment.getTag("constant").length) {
304                 this.isConstant = true;
305                 this.isa = 'OBJECT';
306             }
307             
308             /*~t
309                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@constant*"+"/"));
310                 assertEqual(sym.isConstant, true, "@constant tag, isConstant set.");
311             */
312             
313             // @version
314             var versions = this.comment.getTag("version");
315             if (versions.length) {
316                 this.version = versions.map(function($){return $.desc;}).join(", ");
317             }
318             
319             /*~t
320                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@version 2.0x*"+"/"));
321                 assertEqual(sym.version, "2.0x", "@version tag, version is found.");
322             */
323             
324             // @deprecated
325             var deprecateds = this.comment.getTag("deprecated");
326             if (deprecateds.length) {
327                 this.deprecated = deprecateds.map(function($){return $.desc;}).join("\n");
328             }
329             
330             /*~t
331                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@deprecated Use other method.*"+"/"));
332                 assertEqual(sym.deprecated, "Use other method.", "@deprecated tag, desc is found.");
333             */
334             
335             // @example
336             var examples = this.comment.getTag("example");
337             if (examples.length) {
338                 this.example = examples[0];
339             }
340             
341             /*~t
342                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@example This\n  is an example.*"+"/"));
343                 assertEqual(sym.example, "This\n  is an example.", "@deprecated tag, desc is found.");
344             */
345             
346             // @see
347             var sees = this.comment.getTag("see");
348             if (sees.length) {
349                 var thisSee = this.see;
350                 sees.map(function($){thisSee.push($.desc);});
351             }
352             
353             /*~t
354                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@see The other thing.*"+"/"));
355                 assertEqual(sym.see, "The other thing.", "@see tag, desc is found.");
356             */
357             
358             // @class
359             var classes = this.comment.getTag("class");
360             if (classes.length) {
361                 //print(JSON.stringify(this,null,4));
362                 this.isa = "CONSTRUCTOR";
363                 this.classDesc = classes[0].desc; // desc can't apply to the constructor as there is none.
364                 if (!this.classDesc) {
365                     this.classDesc = this.desc;
366                    }
367                 
368                 
369             }
370             
371             /*~t
372                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@class This describes the class.*"+"/"));
373                 assertEqual(sym.isa, "CONSTRUCTOR", "@class tag, makes symbol a constructor.");
374                 assertEqual(sym.classDesc, "This describes the class.", "@class tag, class description is found.");
375             */
376             
377             // @namespace
378             var namespaces = this.comment.getTag("namespace");
379             if (namespaces.length) {
380                 this.classDesc = namespaces[0].desc+"\n"+this.desc; // desc can't apply to the constructor as there is none.
381                 this.isNamespace = true;
382             }
383             
384             /*~t
385                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@namespace This describes the namespace.*"+"/"));
386                 assertEqual(sym.classDesc, "This describes the namespace.\n", "@namespace tag, class description is found.");
387             */
388             
389             // @param
390             var params = this.comment.getTag("param");
391             if (params.length) {
392                 // user-defined params overwrite those with same name defined by the parser
393                 var thisParams = this.getParams();
394
395                 if (thisParams.length == 0) { // none exist yet, so just bung all these user-defined params straight in
396                     this.setParams(params);
397                 }
398                 else { // need to overlay these user-defined params on to existing parser-defined params
399                     for (var i = 0, l = params.length; i < l; i++) {
400                         if (thisParams[i]) {
401                             if (params[i].type) thisParams[i].type = params[i].type;
402                             thisParams[i].name = params[i].name;
403                             thisParams[i].desc = params[i].desc;
404                             thisParams[i].isOptional = params[i].isOptional;
405                             thisParams[i].defaultValue = params[i].defaultValue;
406                         }
407                         else thisParams[i] = params[i];
408                     }
409                 }
410             }
411             
412             /*~t
413                 var sym = new Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new DocComment("/**Description.*"+"/"));
414                 assertEqual(sym.params.length, 1, "parser defined param is found.");
415                 
416                 sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**Description.\n@param {array} pages*"+"/"));
417                 assertEqual(sym.params.length, 1, "user defined param is found.");
418                 assertEqual(sym.params[0].type, "array", "user defined param type is found.");
419                 assertEqual(sym.params[0].name, "pages", "user defined param name is found.");
420                 
421                 sym = new Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new DocComment("/**Description.\n@param {string} uid*"+"/"));
422                 assertEqual(sym.params.length, 1, "user defined param overwrites parser defined param.");
423                 assertEqual(sym.params[0].type, "string", "user defined param type overwrites parser defined param type.");
424                 assertEqual(sym.params[0].name, "uid", "user defined param name overwrites parser defined param name.");
425             
426                 sym = new Symbol("foo", [{type: "array", name: "pages"}, {type: "number", name: "count"}], "FUNCTION", new DocComment("/**Description.\n@param {string} uid*"+"/"));
427                 assertEqual(sym.params.length, 2, "user defined params  overlay parser defined params.");
428                 assertEqual(sym.params[1].type, "number", "user defined param type overlays parser defined param type.");
429                 assertEqual(sym.params[1].name, "count", "user defined param name overlays parser defined param name.");
430
431                 sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**Description.\n@param {array} pages The pages description.*"+"/"));
432                 assertEqual(sym.params.length, 1, "user defined param with description is found.");
433                 assertEqual(sym.params[0].desc, "The pages description.", "user defined param description is found.");
434             */
435             
436             // @constructor
437             if (this.comment.getTag("constructor").length) {
438                 this.isa = "CONSTRUCTOR";
439             }
440             
441             /*~t
442                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@constructor*"+"/"));
443                 assertEqual(sym.isa, "CONSTRUCTOR", "@constructor tag, makes symbol a constructor.");
444             */
445             
446             // @static
447             if (this.comment.getTag("static").length) {
448                 this.isStatic = true;
449                 if (this.isa == "CONSTRUCTOR") {
450                     this.isNamespace = true;
451                 }
452             }
453             
454                 // @static
455             if (this.comment.getTag("singleton").length) {
456                 this.isStatic = true;
457                 //print('------------- got singleton ---------------' + this.isa);
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                 this.name = this.name.split('.').pop();
671                 this.name = this.name.split('#').pop();
672                 this.name = this.memberOf + this.name;
673                 this._name = this.name
674                 this.alias = this.name;
675             }
676
677             /*~t
678                 // todo
679             */
680             
681             // @public
682             if (this.comment.getTag("public").length) {
683                 this.isPrivate = false;
684             }
685             
686             /*~t
687                 // todo
688             */
689         },
690
691         is : function(what) {
692             return this.isa === what;
693         },
694
695         isBuiltin : function() {
696             return SymbolSet.isBuiltin(this.alias);
697         },
698
699         setType : function(/**String*/comment, /**Boolean*/overwrite) {
700             if (!overwrite && this.type) return;
701             var typeComment = DocComment.unwrapComment(comment);
702             this.type = typeComment;
703         },
704
705         inherit : function(symbol) {
706             if (!this.hasMember(symbol.name) && !symbol.isInner) {
707                 if (symbol.is("FUNCTION"))
708                     this.methods.push(symbol);
709                 else if (symbol.is("OBJECT"))
710                     this.properties.push(symbol);
711             }
712         },
713
714         hasMember : function(name) {
715             return (this.hasMethod(name) || this.hasProperty(name));
716         },
717
718         addMember : function(symbol) {
719             //println("ADDMEMBER: " + this.name +  " ++ " + symbol.name);
720             
721             if (symbol.comment.getTag("cfg").length == 1) { 
722                 symbol.comment.getTag("cfg")[0].memberOf = this.alias;
723                 this.addConfig(symbol.comment.getTag("cfg")[0]);
724                 return;
725             }
726             
727             if (symbol.is("FUNCTION")) { this.addMethod(symbol); }
728             else if (symbol.is("OBJECT")) { this.addProperty(symbol); }
729         },
730
731         hasMethod : function(name) {
732             var thisMethods = this.methods;
733             for (var i = 0, l = thisMethods.length; i < l; i++) {
734                 if (thisMethods[i].name == name) return true;
735                 if (thisMethods[i].alias == name) return true;
736             }
737             return false;
738         },
739
740         addMethod : function(symbol) {
741             var methodAlias = symbol.alias;
742             var thisMethods = this.methods;
743             for (var i = 0, l = thisMethods.length; i < l; i++) {
744                 if (thisMethods[i].alias == methodAlias) {
745                     thisMethods[i] = symbol; // overwriting previous method
746                     return;
747                 }
748             }
749             thisMethods.push(symbol); // new method with this alias
750         },
751
752         hasProperty : function(name) {
753             var thisProperties = this.properties;
754             for (var i = 0, l = thisProperties.length; i < l; i++) {
755                 if (thisProperties[i].name == name) return true;
756                 if (thisProperties[i].alias == name) return true;
757             }
758             return false;
759         },
760
761         addProperty : function(symbol) {
762             var propertyAlias = symbol.alias;
763             var thisProperties = this.properties;
764             for (var i = 0, l = thisProperties.length; i < l; i++) {
765                 if (thisProperties[i].alias == propertyAlias) {
766                     thisProperties[i] = symbol; // overwriting previous property
767                     return;
768                 }
769             }
770
771             thisProperties.push(symbol); // new property with this alias
772         },
773         
774         addDocTag : function(docTag)
775         {
776             this.comment.tags.push(docTag);
777             if (docTag.title == 'cfg') {
778                 this.addConfig(docTag);
779             }
780             
781         },
782         
783         addConfig : function(docTag)
784         {
785             if (typeof(docTag['memberOf']) == 'undefined') {
786                 // remove prototype data...
787                 //var a = this.alias.split('#')[0];
788                 //docTag.memberOf = a;
789                 docTag.memberOf = this.alias;
790             }
791             if (typeof(this.cfgs[docTag.name]) == 'undefined') {
792                 this.cfgs[docTag.name] = docTag;
793             }
794             
795         },
796         configToArray: function()
797         {
798             var r = [];
799             for(var ci in this.cfgs) {
800                 // dont show hidden!!
801                 if (this.cfgs[ci].desc.match(/@hide/)) {
802                     continue;
803                 }
804                 r.push(this.cfgs[ci]); 
805                
806             }
807             return r;
808         }
809 });
810
811 /**
812  * Elements that are not serialized
813  * 
814  */
815 Symbol.hide = [ 
816     '$args' // not needed AFAIK
817 ]
818
819 Symbol.srcFile = ""; //running reference to the current file being parsed
820
821
822 Symbol.fromDump = function(t)
823 {
824     var ns = new Symbol();
825     for (var i in t) {
826         if (typeof(ns[i]) == "undefined") {
827             println("ERR:no default for Symbol:"+ i);
828         }
829         ns[i] = t[i];
830     }
831     return ns;
832 }