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