Changed roojspacker/Symbol.valaroojspacker/SymbolSet.valaroojspacker/Walker.vala
authorAlan Knowles <alan@roojs.com>
Wed, 4 Aug 2021 04:27:18 +0000 (12:27 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 4 Aug 2021 04:27:18 +0000 (12:27 +0800)
roojspacker/Symbol.vala
roojspacker/SymbolSet.vala
roojspacker/Walker.vala

index c4f358d..23edafe 100644 (file)
@@ -461,14 +461,16 @@ namespace JSDOC {
             
             // @static
             if (this.comment.getTag(DocTagTitle.STATIC).size > 0) {
+               GLib.debug("set class %s to static (static)", this.alias);
                 this.isStatic = true;
                 if (this.isa == "CONSTRUCTOR") {
                     this.isNamespace = true;
                 }
             }
             
-                // @static
+            // @singleton - technically it's an arready instanticsed class - eg. Roo.Ajax == new Roo.util.Connection
             if (this.comment.getTag(DocTagTitle.SINGLETON).size > 0) {
+               GLib.debug("set class %s to static (singleton)", this.alias);
                 this.isStatic = true;
                 //print('------------- got singleton ---------------' + this.isa);
                 //if (this.isa == "CONSTRUCTOR") {
index 4082ee8..05b572e 100644 (file)
@@ -181,17 +181,20 @@ namespace JSDOC {
             foreach (var p in this.keys()) {
                 var symbol = this.getSymbol(p);
                 
-                if (symbol.is("FILE") || symbol.is("GLOBAL")) continue;
+                if (symbol.is("FILE") || symbol.is("GLOBAL")) {
+                       continue;
+               }
                 
                 // the memberOf value was provided in the @memberOf tag
-                else if (symbol.memberOf.length > 0) {
+                
+                GLib.debug("Resolve: %s memberOf=%s", symbol.alias, symbol.memberOf);
+                               if (symbol.memberOf.length > 0) {
                        var regex = new GLib.Regex("^("+symbol.memberOf+"[.#-])(.+)$");
                        GLib.MatchInfo minfo;
                     var parts = regex.match_full(symbol.alias, -1, 0, 0 , out minfo);
                     
                     // like foo.bar is a memberOf foo
                     if (parts) {                        
-                               
                         symbol.memberOf = minfo.fetch(1);
                         symbol.private_name = minfo.fetch(2);
                     }
@@ -202,9 +205,9 @@ namespace JSDOC {
                         
                         this.renameSymbol(p, symbol.memberOf + symbol.name);
                     }
-                }
+                } else {
                 // the memberOf must be calculated
-                else {
+                
                        GLib.MatchInfo minfo;                
                     var parts = /^(.*[.#-])([^.#-]+)$/.match_full(symbol.alias, -1, 0, 0 , out minfo);
 
@@ -215,7 +218,7 @@ namespace JSDOC {
                 }
 
                 // set isStatic, isInner
-                if (symbol.memberOf.length > 0) {
+                if (symbol.memberOf.length > 0 && !symbol.is("CONSTRUCTOR")) {
                     switch (symbol.memberOf[symbol.memberOf.length-1]) {
                         case '#' :
                             symbol.isStatic = false;
index e1e1fd6..a6e0bea 100644 (file)
@@ -149,6 +149,7 @@ namespace JSDOC {
                         // add it to the current scope????
                         
                         this.addSymbol("", true);
+                        GLib.debug("Call addSymbol EMPTY");
                         //print ( "Unconsumed Doc: " + token.toString())
                         //throw "Unconsumed Doc (TOKwhitespace): " + this.currentDoc.toSource();
                     }
@@ -193,7 +194,10 @@ namespace JSDOC {
                 if (this.currentDoc != null && (
                         token.data == ";" || 
                         token.data == "}")) {
+
+                    GLib.debug("Call addSymbol EMPTY");                        
                     this.addSymbol("", true);
+                    
                     //throw "Unconsumed Doc ("+ token.toString() +"): " + this.currentDoc.toSource();
                 }
                     
@@ -248,6 +252,7 @@ namespace JSDOC {
                         scopeName = token.data;
                         
                         if (this.currentDoc != null) {
+                               GLib.debug("Call addSymbol %s", scopeName);
                             this.addSymbol(scopeName,false,"OBJECT");
 
                         }
@@ -289,6 +294,7 @@ namespace JSDOC {
                         token = this.ts.lookTok(-2);
                         scopeName = token.data;
                         if (this.currentDoc != null) {
+                               GLib.debug("Call addSymbol %s", scopeName);
                             this.addSymbol(scopeName,false,"OBJECT");
 
                         }
@@ -344,6 +350,7 @@ namespace JSDOC {
                         
                                       
                         if (this.currentDoc != null) {
+                               GLib.debug("Call addSymbol %s", scopeName);
                             this.addSymbol(scopeName,false,"OBJECT");
                         }
                      
@@ -386,6 +393,7 @@ namespace JSDOC {
                         ) {
                         scopeName = token.data;
                         if (this.currentDoc != null) {
+                               GLib.debug("Call addSymbol %s", scopeName);
                             this.addSymbol(scopeName,false,"OBJECT");
                             
                         }
@@ -424,6 +432,7 @@ namespace JSDOC {
                         
                         // ident : function ()
                         // ident = function ()
+                        // this.ident = function()
                         var atype = "OBJECT";
                         
                         if (((this.ts.lookTok(1).data == ":" )|| (this.ts.lookTok(1).data == "=")) &&
@@ -435,11 +444,13 @@ namespace JSDOC {
                         }
                         
                         //print("ADD SYM:" + atype + ":" + token.toString() + this.ts.lookTok(1).toString() + this.ts.lookTok(2).toString());
-                        
-                        this.addSymbol(
-                            this.ts.lookTok(-1).data == "." ? token.data :    this.fixAlias(aliases,token.data),
-                            false,
-                            atype);
+                        var tname = this.ts.lookTok(-1).data == "." ? token.data :    this.fixAlias(aliases,token.data);
+
+                        if (/^this\./.match(tname)) {
+                               tname = tname.substring(5);
+                        }
+                        GLib.debug("Call addSymbol %s", tname);                        
+                        this.addSymbol( tname, false, atype);
                         
 
                         this.currentDoc = null;
@@ -461,6 +472,7 @@ namespace JSDOC {
                 
                 if (token.isType(TokenType.STRN))   { // THIS WILL NOT HAPPEN HERE?!!?
                     if (this.currentDoc != null) {
+                        GLib.debug("Call addSymbol %s", token.data.substring(1,token.data.length-1));
                         this.addSymbol(token.data.substring(1,token.data.length-1),false,"OBJECT");
                     }
                 }
@@ -469,6 +481,7 @@ namespace JSDOC {
                 
                 
                 if (token.isName(TokenName.FUNCTION)) {
+                       GLib.debug("Got Function");
                     //print("GOT FUNCTION");
                     // see if we have an unconsumed doc...
                     
@@ -487,13 +500,16 @@ namespace JSDOC {
                             (this.ts.lookTok(-1).data == "=") && 
                             (this.ts.lookTok(-2).isType(TokenType.NAME))
                         ) {
+
                         scopeName = this.ts.lookTok(-2).data;
+                       GLib.debug("Got %s = Function", scopeName);
                         this.ts.balance(TokenName.LEFT_PAREN);
                         token = this.ts.nextTok(); // should be {
                         //print("FOO=FUNCITON() {}" + this.ts.context() + "\n" + token.toString());
                         
                         
                         scopeName = this.fixAlias(aliases, scopeName);
+                         
                         var fnScope =  new Scope(this.braceNesting, scope, token.id, // was token.n?
                                        "$this$="+scopeName+".prototype|$private$|"+scopeName+".prototype",
                                        null
@@ -501,7 +517,7 @@ namespace JSDOC {
                         
                         this.indexedScopes.set(this.ts.cursor, fnScope);
                         //scope = fnScope;
-                        //this.scopesIn(fnScope);
+                        // this.scopesIn(fnScope);
                         this.parseScope(fnScope, aliases);
                         
                         
@@ -515,7 +531,7 @@ namespace JSDOC {
                         
                 
                 // foo = new function() {}
-                        // is this actually used much!?!?!
+                        // is this actually used much!?!?! -- 
                         //$private$
                         
                     if (
@@ -534,7 +550,7 @@ namespace JSDOC {
                         
                         this.indexedScopes.set(this.ts.cursor,  fnScope);
                         //scope = fnScope;
-                        //this.scopesIn(fnScope);
+                        // this.scopesIn(fnScope);
                         this.parseScope(fnScope, aliases);
                         
                         locBraceNest++;
@@ -573,7 +589,7 @@ namespace JSDOC {
 
                         this.indexedScopes.set(this.ts.cursor, fnScope);
                         //scope = fnScope;
-                        //this.scopesIn(fnScope);
+                        // this.scopesIn(fnScope);
                          this.parseScope(fnScope, aliases);
                         locBraceNest++;
                         //print(">>" +locBraceNest);
@@ -595,8 +611,8 @@ namespace JSDOC {
                                        ); 
 
                         this.indexedScopes.set(this.ts.cursor, fnScope);
-                        //scope = fnScope;
-                        //this.scopesIn(fnScope);
+                        // scope = fnScope;
+                        // this.scopesIn(fnScope);
                         this.parseScope(fnScope, aliases);
                         locBraceNest++;
                         //print(">>" +locBraceNest);
@@ -626,7 +642,7 @@ namespace JSDOC {
 
                         this.indexedScopes.set(this.ts.cursor, fnScope);
                         //scope = ;
-                        //this.scopesIn(fnScope);
+                        // this.scopesIn(fnScope);
                          this.parseScope(fnScope, aliases);
                         locBraceNest++;
                         //print(">>" +locBraceNest);
@@ -673,7 +689,7 @@ namespace JSDOC {
                             scope = fnScope;
                             // push the same scope onto the stack..
                             this.scopesIn(fnScope);
-                            //this.scopesIn(this.scopes[this.scopes.length-1]);
+                            // this.scopesIn(this.scopes[this.scopes.length-1]);
                             
                               
                             locBraceNest++;
@@ -721,6 +737,7 @@ namespace JSDOC {
                     
                      
                         if (this.currentDoc != null) {
+                                                        GLib.debug("Call addSymbol EMPTY");
                             this.addSymbol("", true);
 
                             //throw "Unconsumed Doc: (TOKrbrace)" + this.currentDoc.toSource();
@@ -738,9 +755,9 @@ namespace JSDOC {
                         //print("<<<<<< " + locBraceNest );
                         if (locBraceNest < 0) {
                            // print("POPED OF END OF SCOPE!");
-                            ///this.scopeOut();   
-                            //var ls = this.scopeOut();
-                            //ls.getUsedSymbols();
+                            // this.scopeOut();   
+                            // var ls = this.scopeOut();
+                            // ls.getUsedSymbols();
                             return;
                         }
                         continue;