JSDOC/Scope.js
[gnome.introspection-doc-generator] / JSDOC / ScopeParser.js
index 8054fb8..a7abc9c 100644 (file)
@@ -224,7 +224,7 @@ ScopeParser.prototype = {
         var isObjectLitAr = [ false ];
         var isInObjectLitAr;
         thisScope = scope;
-        if (thisScope) {
+        if (thisScope && thisScope.gid != this.scopes[this.scopes.length-1]) {
             this.scopes.push(scope);
         } else {
             thisScope = this.scopes[this.scopes.length-1]
@@ -426,7 +426,7 @@ ScopeParser.prototype = {
                 
                 case "STRN.DOUBLE_QUOTE": // used for object lit detection..
                 case "STRN.SINGLE_QUOTE":
-                    print('SCOPE-STRING:' + token.toString());
+                  //  print('SCOPE-STRING:' + token.toString());
                     //println("<i>"+token.data+"</i>");
 
                     if (this.ts.lookTok(-1).data == '{' && this.ts.lookTok(1).data == ':') {
@@ -456,27 +456,12 @@ ScopeParser.prototype = {
                     break;
                 
                 case "NAME.NAME":
-                    print('SCOPE-NAME:' + token.toString());
+                    //print('SCOPE-NAME:' + token.toString());
                     //print("DEAL WITH NAME:");
                     // got identifier..
                     
                     // look for  { ** : <- indicates obj literal.. ** this could occur with numbers ..
-                    if ((this.ts.lookTok(-1).data == "{") && (this.ts.lookTok(1).data == ":")) {
-                        isObjectLitAr.pop();
-                        isObjectLitAr.push(true);
-                        //print(">>>>>> OBJLIT REPUSH(true)");
-                        //println("<i>"+token.data+"</i>");
-                        break;
-                    }
-                   // print("DEAL WITH obj lit:");
-                    isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
-                    
-                    if (isInObjectLitAr && (this.ts.lookTok(1).data == ":") && (this.ts.lookTok(-1).data == ",")) {
-                        // skip, it's an object lit key..
-                        //println("<i>"+token.data+"</i>");
-                        break;
-                    }
-                    
+                     
                     
                     // skip anyting with "." before it..!!
                      
@@ -488,6 +473,9 @@ ScopeParser.prototype = {
                     //print("SYMBOL: " + token.toString());
                     
                     symbol = token.data;
+                    if (symbol == 'this') {
+                        break;
+                    }
                     if (this.mode == 'PASS2_SYMBOL_TREE') {
                         
                         //println("GOT IDENT: -2 : " + this.ts.lookT(-2).toString() + " <BR> ..... -1 :  " +  this.ts.lookT(-1).toString() + " <BR> "); 
@@ -523,7 +511,7 @@ ScopeParser.prototype = {
                     if (token.type != 'KEYW') {
                         break;
                     }
-                    print('SCOPE-KEYW:' + token.toString());
+                    //print('SCOPE-KEYW:' + token.toString());
                    // print("Check eval:");
                 
                     symbol = token.data;
@@ -568,7 +556,7 @@ ScopeParser.prototype = {
             //if (this.ts.nextT()) break;
             
         }
-        print("<<< EXIT SCOPE");
+        //print("<<< EXIT SCOPE");
         //print("<<<<<<<EXIT SCOPE ERR?" +this.scopes.length);
     },
 
@@ -616,19 +604,19 @@ ScopeParser.prototype = {
            */ 
            
            //this.dumpToken(token,  this.scopes, this.braceNesting );
-           print('EXP' +  token.toString());
+           //print('EXP' +  token.toString());
             
             
             //println("<i>"+token.data+"</i>");
             //this.log("EXP:" + token.data);
             switch (token.type) {
                 case 'PUNC':
-                    print("EXPR-PUNC:" + token.toString());
+                    //print("EXPR-PUNC:" + token.toString());
                     
                     switch(token.data) {
                          
                         case ';':
-                            print("<< EXIT EXPRESSION");
+                            //print("<< EXIT EXPRESSION");
                             break;
 
                         case ',':
@@ -639,7 +627,7 @@ ScopeParser.prototype = {
                         case '(': //Token.LP:
                         case '{': //Token.LC:
                         case '[': //Token.LB:
-                            print('SCOPE-CURLY/PAREN/BRACE:' + token.toString());
+                            //print('SCOPE-CURLY/PAREN/BRACE:' + token.toString());
                             //println("<i>"+token.data+"</i>");
                             var curTS = this.ts;
                             if (token.props) {
@@ -653,7 +641,7 @@ ScopeParser.prototype = {
                                     // key value..
                                     
                                     this.ts = new TokenStream(token.props[prop].val);
-                                    this.parseScope(currentScope);
+                                    this.parseScope(false);
                                     
                                 }
                                 this.ts = curTS;
@@ -683,7 +671,7 @@ ScopeParser.prototype = {
                         case ')': //Token.RP:
                         case ']': //Token.RB:
                         case '}': //Token.RB:
-                            print("<< EXIT EXPRESSION");
+                            //print("<< EXIT EXPRESSION");
                             return;
                            
  
@@ -697,8 +685,8 @@ ScopeParser.prototype = {
                     break;
                     
                 case 'STRN': // used for object lit detection..
-                    if (this.mode == 'BUILDING_SYMBOL_TREE')    
-                        print("EXPR-STR:" + JSON.stringify(token, null, 4));
+                    //if (this.mode == 'BUILDING_SYMBOL_TREE')    
+                        //print("EXPR-STR:" + JSON.stringify(token, null, 4));
                
                      
                     break;
@@ -708,9 +696,9 @@ ScopeParser.prototype = {
                 case 'NAME':
                     if (this.mode == 'BUILDING_SYMBOL_TREE') {
                         
-                        print("EXPR-NAME:" + JSON.stringify(token, null, 4));
+                        //print("EXPR-NAME:" + JSON.stringify(token, null, 4));
                     } else {
-                        print("EXPR-NAME:" + token.toString());
+                        //print("EXPR-NAME:" + token.toString());
                     }
                     symbol = token.data;
                     //print("in NAME = " + token.toString());
@@ -723,7 +711,9 @@ ScopeParser.prototype = {
                         //skip '.'
                         break;
                     }
-                    
+                    if (symbol == 'this') {
+                        break;
+                       }
                     
                     if (this.mode == 'PASS2_SYMBOL_TREE') {
 
@@ -741,7 +731,7 @@ ScopeParser.prototype = {
                                 //print("Found an undeclared symbol: " + symbol + ' (line:' + token.line + ')');
                                 //throw "OOPS";
                             } else {
-                                print("undeclared:" + token.toString())
+                                //print("undeclared:" + token.toString())
                             }
                             
                             
@@ -868,7 +858,7 @@ ScopeParser.prototype = {
 
         //assert token.getType() == Token.LP;
         if (this.mode == 'BUILDING_SYMBOL_TREE') {
-            fnScope = new Scope(this.braceNesting, currentScope, token.n, '');
+            fnScope = new Scope(1, currentScope, token.n, '');
             
             //println("STORING SCOPE" + this.ts.cursor);
             
@@ -915,6 +905,7 @@ ScopeParser.prototype = {
             _this.ts = new TokenStream(tar);
             _this.parseScope(fnScope);
             
+            
         });
         
         //print(JSON.stringify(this.ts,null,4));