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