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