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