开发者

Eclipse PDT doesn't seem to be parsing compact javascript code correctly

I uploaded a project into Eclipse PDT and in its first build it identified a number of errors in compact js scripts. Most of the errors relate to missing semicolons, asking to include a }, etc.

This is code that is running fine in the web server without any js errors being logged on the page.

I am guessing I need to configure Eclipse to use a different parser to process these compact js scripts. However I am in an area I am not familiar with and would like to hear advise from more experienced folks.

Some things I found out during my research of the problem:

1 - compact js scripts do not follow the same syntax requirements as regular js scripts. For example, there are very few semicolons in the compact js script. I guess the PHP parser on the server understands it is a compact js script and executes the code even without the semicolons. Am I right?

Here is an example:

The code:

var Mapifies;

if (!Mapifies) Mapifies = function(){};

Mapifies.MapObjects = {};

Mapifies.MapObjects.Set = function ( element, options ) {
    var mapName = jQuery(eleme开发者_运维知识库nt).attr('id');
    var thisMap = new GMap2(element);
    Mapifies.MapObjects[mapName] = thisMap;
    Mapifies.MapObjects[mapName].Options = options;
    return Mapifies.MapObjects[mapName];
};

and here is the compact version that is causing me problems:

var Mapifies;Mapifies||(Mapifies=function(){}),Mapifies.MapObjects={},Mapifies.MapObjects.Set=function(a,b){var c=jQuery(a).attr("id"),d=new GMap2(a);Mapifies.MapObjects[c]=d,Mapifies.MapObjects[c].Options=b;return Mapifies.MapObjects[c]}

As you can see, it seems that compact js does not require all the semicolons we typically see in a regular js script.

2 - I could convert from compact js to regular js, but that would be a major undertaking I am trying to avoid.

3 - I really don't want to simply turn off the js validation if I can avoid it. I want to leverage it in case I do commit errors.

Thank you for the help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜