Author: reebalazs
Date: Fri Dec 28 12:41:35 2007
New Revision: 50152

Modified:
   kukit/kukit.js/branch/ree-service-layer-and-refactoring/   (props changed)
   kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js
   kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js
   kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js
   
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js
Log:
Fix selectors parsing with commas in the middle
This caused a problem with value providers for getting the
event binder id, like xxx:click(kssAttr(blah, true))

Modified: 
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js
==============================================================================
--- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js  
(original)
+++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js  
Fri Dec 28 12:41:35 2007
@@ -651,7 +651,10 @@
         this.expectToken(context, kukit.kssp.comma);
     }
     this.result = [];
-    this.txt = '';
+    // MethodArgs now also must produce a txt, this is used in embedded
+    // parsing from KssSelectors.
+    // Just use the original text.
+    this.txt = this.cursor.text.slice(this.startpos, this.endpos);
 };
 
 /*
@@ -666,6 +669,8 @@
 kukit.kssp.KssSelectors = kukit.tk.mkParser('kssselectors', {
     "'": 'new kukit.kssp.StringInSelector(this.cursor, kukit.kssp.quote)',
     '"': 'new kukit.kssp.String2InSelector(this.cursor, kukit.kssp.dquote)',
+    // XXX Merging hint: next line is new.
+    "(": 'new kukit.kssp.MethodArgs(this.cursor, kukit.kssp.openParent)',
     ",": 'new kukit.kssp.comma(this.cursor)',
     "{": 'this.emitAndReturn()',
     "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)'
@@ -675,9 +680,15 @@
     // Parse all tokens (including first and last)
     var context = {'nextTokenIndex': 0};
     while (context.nextTokenIndex < this.result.length) {
+        // All the tokens in which we want to ignore detecting the ','
+        // inside, must be digested here.
+        // We ignore all strings, comments and MethodArgs (a, b, c)
         this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment,
-            kukit.kssp.String, kukit.kssp.String2);
-        var cursor = new kukit.tk.Cursor(context.txt + ' ')
+            kukit.kssp.String, kukit.kssp.String2, kukit.kssp.MethodArgs);
+        // We do not take text accumulated in the digest buffer, as
+        // for MetodArgs, for example, does not produce useful txt.
+        // Instead we take a slice of the original text.
+        var cursor = new kukit.tk.Cursor(context.txt + ' ');
         var parser = new kukit.kssp.KssSelector(cursor, null, true);
         this.selectors.push(parser.kssSelector);
         if (context.nextTokenIndex == this.result.length) break;
@@ -794,9 +805,15 @@
         var args = pseudotoken.value.args;
         // XXX TODO check that there is only 1 arg? Should already be checked.
         var arg = args[0];
-        // Check it in every case.
-        // always check as value provider
-        arg.check(interfaces.valueproviders);
+;;;     // We annotate the error, to give parsing information to it.
+;;;     try {
+            // Check it in every case.
+            // always check as value provider
+            arg.check(interfaces.valueproviders);
+;;;     } catch(e) {
+;;;             kukit.E = 'Error in value provider for event binder id.';
+;;;             this.emitWrappedError(e, kukit.E);
+;;;     }
         if (arg.isMethod) {
             // store it as ppid
             ppid = arg;

Modified: 
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js
==============================================================================
--- 
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js   
    (original)
+++ 
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js   
    Fri Dec 28 12:41:35 2007
@@ -254,8 +254,8 @@
     // Check if the method name really existed.
     if (! f) {
 ;;;     kukit.E = 'Undefined value provider [';
-;;;     kukit.E += this.methodName + ']';
-        throw new Error(kukit.E);
+;;;     kukit.E += this.methodName + '].';
+        throw kukit.err.pluginRegistryError(null, kukit.E);
     }
     // Create the provider checker and evaluator object
     this.pprovider = new f();

Modified: 
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js
==============================================================================
--- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js  
(original)
+++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js  
Fri Dec 28 12:41:35 2007
@@ -135,7 +135,7 @@
 };
 
 kukit.tk._ParserBase.prototype.notInTokens = 
-    function(context, token1, token2, token3, token4) {
+    function(context, token1, token2, token3, token4, token5) {
     var i = context.nextTokenIndex;
     var currentValue = this.result[i];
     return !(
@@ -143,24 +143,25 @@
         (this.resultIsNullOrNotToken(token1, currentValue) &&
         this.resultIsNullOrNotToken(token2, currentValue) &&
         this.resultIsNullOrNotToken(token3, currentValue) &&
-        this.resultIsNullOrNotToken(token4, currentValue))
+        this.resultIsNullOrNotToken(token4, currentValue) &&
+        this.resultIsNullOrNotToken(token5, currentValue))
         );
 };
 
 kukit.tk._ParserBase.prototype.digestTxt =
-    function(context, token1, token2, token3, token4) {
+    function(context, token1, token2, token3, token4, token5) {
     // digests the txt from the tokens, ignores given token
     // plus whitespace removal
-    this.digestExactTxt(context, token1, token2, token3, token4);
+    this.digestExactTxt(context, token1, token2, token3, token4, token5);
     context.txt = this.removeWhitespacesAndTrim(context.txt);
 };
 
 kukit.tk._ParserBase.prototype.digestExactTxt =
-    function(context, token1, token2, token3, token4) {
+    function(context, token1, token2, token3, token4, token5) {
     // digests the txt from the tokens, ignores given token
     // exact value: no whitespace removal
     var result = '';
-    while (this.notInTokens(context, token1, token2, token3, token4)) {
+    while (this.notInTokens(context, token1, token2, token3, token4, token5)) {
         result += this.result[context.nextTokenIndex].txt;
         context.nextTokenIndex ++;
         }

Modified: 
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js
==============================================================================
--- 
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js 
    (original)
+++ 
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js 
    Fri Dec 28 12:41:35 2007
@@ -351,7 +351,21 @@
         this.assertEquals(parser.value.args[0].args[0].txt, 'x');
     };
 
-    this.testEventValueWithValueProviderRejectsAccessValues = function() {
+    this.testEventValueWithValueProvider2 = function() {
+        // methods ok
+        var txt= "click(kssAttr(hello, true ))";
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.EventValue(cursor, null, true);
+    };
+
+    this.testEventValueWithValueProvider3 = function() {
+        // methods ok
+        var txt= "click(kssAttr(hello, true ))";
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.EventValue(cursor, null, true);
+    };
+
+    this.testEventValueWithValueProviderRejectsExcessValues = function() {
         // no more values in the method
         var txt= "click(kssAttr(x), aaa)";
         var cursor = new kukit.tk.Cursor(txt);
@@ -815,7 +829,7 @@
             +"}\n";
         var cursor = new kukit.tk.Cursor(txt);
         this.assertParsingError(kukit.kssp.Document, cursor, null, true,
-            'Error in value provider for parameter [effect].');
+            'Undefined value provider [noSuchProvider].');
     };
 
     this.testActionErrorParameters = function() {
@@ -1500,6 +1514,13 @@
         this.assertEquals(parser.kssSelector.ppid.args[1].txt, 'true');
     };
 
+    this.testValueProvidersInEventIdentification3 = function() {
+        var txt= "a:click(kssAttr(hello, true))";
+        var src = new kukit.tk.Cursor(txt);
+        var src = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.KssSelector(src, null, true);
+    };
+
     this.testValueProvidersInEventIdentificationRejectsMoreParameters = 
function() {
         var txt= "a:drag(kssAttr(hello), xxx)";
         var src = new kukit.tk.Cursor(txt);
@@ -1517,22 +1538,46 @@
         this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
             'KssSpecialSelector [behaviour] must not stand with an event id 
acquired by value provider [kssAttr]');
     };
-    
+     
+    this.testValueProvidersInEventIdentificationWithCommaInString = function() 
{
+        // A value provider can have two attributes.
+        // The parser must not separate the selector at the comma.
+        var txt= ""
+            +"div#update-area:click(',') {\n"
+            +"   action-server: getCurrentTime;\n"
+            +"   getCurrentTime-effect: klah; \n"
+            +"}\n";
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.Document(cursor, null, true);
+        this.assertEquals(parser.finished, true);
+    };
+   
     this.testValueProvidersInEventIdentificationCanHaveTwoAttributes = 
function() {
         // A value provider can have two attributes.
-        // Nothing special - it should just work.
+        // The parser must not separate the selector at the comma.
         var txt= ""
-            +"div#update-area:click(kssAttr(a, true)) {\n"
+            +"div#update-area:click(kssAttr(hello, true)) {\n"
             +"   action-server: getCurrentTime;\n"
-            +"   getCurrentTime-effect: kssAttr; \n"
+            +"   getCurrentTime-effect: blah; \n"
             +"}\n";
         var cursor = new kukit.tk.Cursor(txt);
         var parser = new kukit.kssp.Document(cursor, null, true);
         this.assertEquals(parser.finished, true);
-        ///this.assertParsingError(kukit.kssp.Document, cursor, null, true,
-        //    'Error in value provider for parameter [effect].');
     };
 
+    this.testValueProvidersInEventIdentificationWithUnregistered = function() {
+        // A value provider must be registered.
+        var txt= ""
+            +"div#update-area:click(unDefinedValueProvider(hello, true)) {\n"
+            +"   action-server: getCurrentTime;\n"
+            +"   getCurrentTime-effect: blah; \n"
+            +"}\n";
+        var cursor = new kukit.tk.Cursor(txt);
+        this.assertParsingError(kukit.kssp.Document, cursor, null, true,
+            'Undefined value provider [unDefinedValueProvider].');
+    };
+
+
 };
 
 kukit.KssParserSelectorsTestCase.prototype = new kukit.KssParserTestCaseBase;
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to