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