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