1
Vote

JayLint $data.ASTParser undefined

description

Using Jaydata 1.3.4 with KendoUI and requireJS the $data.Expressions.CodeParser class parseExpression method often falls through to line 5678 which is:

var AST = $data.ASTParser.parseCode(code);

However, I get the error "Cannot call method 'parseCode' of undefined".

Indeed $data.ASTParser is undefined.

require-config.js looks like this:

{
    paths: {

        // Libs
        jquery: 'lib/kendo/js/jquery.min',
        kendo: 'lib/kendo/js/kendo.custom',

        jdata: "lib/jaydata/jaydata", 
        jdatakendo: "lib/jaydata/jaydatamodules/kendo",
        jdatasqlite: "lib/jaydata/jaydataproviders/SqLiteProvider",

        // Paths
        jdataproviders: 'lib/jaydata/jaydataproviders',
        jdatamodules: 'lib/jaydata/jaydatamodules'
    },
    shim: {
        kendo: {
            deps: ['jquery'],
            exports: 'kendo'
        },
        jdata: {
            deps: ['jquery'],
            exports: '$data'
        },
        jdatakendo: {
            deps: ['jdata', 'kendo'],
            exports: 'jdatakendo'
        },
        jdatasqlite: {
            deps: ['jdata'],
            exports: 'jdatasqlite'
        }
    }
};

comments

adriankb wrote Dec 3, 2013 at 7:05 AM

The same issue was raised here previously.

http://jaydata.org/forum/viewtopic.php?f=3&t=238

adriankb wrote Dec 3, 2013 at 7:18 AM

Infact

$data.Acorn
$data.Esprima

are also undefined.

the quick work-around is to explicitly load jaydata.js - i.e. dont use requirejs.

However, everything is so close to working with requirejs it would be ideal to solve this niggle.

Thanks.

SteRichardson wrote Jan 9, 2014 at 12:17 PM

It seems that requirejs returns the parser in question when jaydata is fetched. The parser used is $data.Acorn rather than $data.ASTParser.

A workaround for the example above is be to set the parser manually, e.g.
define(['jdata'], function(jdata) {
   $data.Acorn = jdata;
});

adriankb wrote Feb 21, 2014 at 4:19 AM

Thank you.