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