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