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