JSDOC/ScopeParser.vala
[gnome.introspection-doc-generator] / JSDOC / ScopeParser.vala
index 05d7be7..a59024a 100644 (file)
@@ -264,7 +264,7 @@ namespace JSDOC {
                            if (this.mode == ScopeParserMode.BUILDING_SYMBOL_TREE) {
                                var identifier = scope.getIdentifier(token.data,token) ;
                                
-                               if (identifier == false) {
+                               if (identifier == null) {
                                    scope.declareIdentifier(token.data, token);
                                } else {
                                    token.identifier = identifier;
@@ -472,9 +472,9 @@ namespace JSDOC {
                            //println("GOT IDENT: <B>" + symbol + "</B><BR/>");
                                 
                                //println("GOT IDENT (2): <B>" + symbol + "</B><BR/>");
-                           identifier = this.getIdentifier(symbol, scope, token);
+                           var identifier = this.getIdentifier(symbol, scope, token);
                            
-                           if (identifier == false) {
+                           if (identifier == null) {
 // BUG!find out where builtin is defined...
                                if (symbol.length <= 3 &&  Scope.builtin.indexOf(symbol) < 0) {
                                    // Here, we found an undeclared and un-namespaced symbol that is
@@ -515,12 +515,13 @@ namespace JSDOC {
                                    //print("MATCH!?");
                                    var _t = this;
                                    
-                                   
-                                   token.prefix.replace(/eval:var:([a-z_]+)/ig, function(m, a) {
-                                       //print("GOT: " + a);
-                                       var hi = _t.getIdentifier(a, scope, token);
-                                      // println("PROTECT "+a+" from munge" + (hi ? "FOUND" : "MISSING"));
-                                       if (hi) {
+                                   var regex = new GLib.Regex ("eval:var:([a-z_]+)",GLib.RegexCompileFlags.CASELESS );
+                                   regex.replace_eval (token.prefix, token.prefix.length, 0, 0, (match_info, result) => {
+                                               var a =  match_info.fetch(0);
+                                       var hi = this.getIdentifier(a, scope, token);
+                                              // println("PROTECT "+a+" from munge" + (hi ? "FOUND" : "MISSING"));
+                                       if (hi.length > 0) {
                                          //  print("PROTECT "+a+" from munge");
                                            //print(JSON.stringify(hi,null,4));
                                            hi.toMunge = false;
@@ -727,7 +728,7 @@ namespace JSDOC {
 
                            var identifier = this.getIdentifier(symbol, scope, token);
                            //println("<B>??</B>");
-                           if (identifier == false) {
+                           if (identifier == null) {
 
                                if (symbol.length <= 3 &&  Scope.builtin.indexOf(symbol) < 0) {
                                    // Here, we found an undeclared and un-namespaced symbol that is
@@ -954,18 +955,20 @@ namespace JSDOC {
 
            //assert scope.getParentScope() == globalScope;
            scope.preventMunging();
-       },
+       }
        
-       string getIdentifier(symbol, scope, token) {
-           var identifier;
+       Token? getIdentifier(string symbol, Scope in_scope, Token token) 
+       {
+           Token identifier;
+           var scope = in_scope;
            while (scope != null) {
                identifier = scope.getIdentifier(symbol, token);
                //println("ScopeParser.getIdentgetUsedSymbols("+symbol+")=" + scope.getUsedSymbols().join(','));
-               if (identifier) {
+               if (identifier != null) {
                    return identifier;
                }
                scope = scope.parent;
            }
-           return "";
+           return null;
        }
-};
+}