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