Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349020 - [hotbug] [validation] Eclipse complains about jquery minified JS files
Summary: [hotbug] [validation] Eclipse complains about jquery minified JS files
Status: VERIFIED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal with 25 votes (vote)
Target Milestone: 3.5.2   Edit
Assignee: Chris Jaun CLA
QA Contact: Chris Jaun CLA
URL:
Whiteboard:
Keywords:
: 417387 (view as bug list)
Depends on:
Blocks: 399415
  Show dependency tree
 
Reported: 2011-06-10 09:12 EDT by Victor Rubezhny CLA
Modified: 2014-01-03 18:00 EST (History)
28 users (show)

See Also:
thatnitind: review? (thatnitind)
Michael_Rennie: review+


Attachments
Problematic minified JS file (83.28 KB, text/plain)
2011-06-10 09:15 EDT, Victor Rubezhny CLA
no flags Details
Problematic minified JS file (11.23 KB, text/plain)
2011-06-10 09:15 EDT, Victor Rubezhny CLA
no flags Details
Screenshot (147.51 KB, image/jpeg)
2011-06-10 09:16 EDT, Victor Rubezhny CLA
no flags Details
Thread dump (mentions libswt-pi-gtk native) (219.22 KB, text/plain)
2011-06-10 09:17 EDT, Victor Rubezhny CLA
no flags Details
Another thread dump (doesn't look related) (219.49 KB, text/plain)
2011-06-10 09:18 EDT, Victor Rubezhny CLA
no flags Details
Modified grammar file (46.88 KB, application/octet-stream)
2012-09-04 02:11 EDT, Hyukmin Kwon CLA
no flags Details
webtools.jsdt.core master branch patch (53.14 KB, patch)
2013-11-11 21:05 EST, Denis Golovin CLA
no flags Details | Diff
webtools.jsdt.tests master branch patch with test for the fix added (1.58 KB, patch)
2013-11-11 21:06 EST, Denis Golovin CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Rubezhny CLA 2011-06-10 09:12:31 EDT
Build Identifier: I20110428-0848

The JavaScript Editor complains about minified JS files. This happens mostly because of optional semicolon problem, Syntax error on token "Invalid Regular Expression Options" and some other problems (depending on JavaScript Validator preferences)

See the attached examples and screenshot.

Other problems: the editor and the eclipse hang while editing long lines, JVM crashes while activating/deactivating JavaScript Editor and while trying to call a context menu on JS-files in Package Explorer (see attached logs)



Reproducible: Always

Steps to Reproduce:
1. Copy the attached scripts to workspace and open one of these scripts in JavaScript Editor
2. See the Error markers on the JS-code line as well as Error in Problems View
Comment 1 Victor Rubezhny CLA 2011-06-10 09:15:09 EDT
Created attachment 197775 [details]
Problematic minified JS file
Comment 2 Victor Rubezhny CLA 2011-06-10 09:15:40 EDT
Created attachment 197776 [details]
Problematic minified JS file
Comment 3 Victor Rubezhny CLA 2011-06-10 09:16:42 EDT
Created attachment 197777 [details]
Screenshot
Comment 4 Victor Rubezhny CLA 2011-06-10 09:17:39 EDT
Created attachment 197778 [details]
Thread dump (mentions libswt-pi-gtk native)
Comment 5 Victor Rubezhny CLA 2011-06-10 09:18:22 EDT
Created attachment 197779 [details]
Another thread dump (doesn't look related)
Comment 6 Jason Levine CLA 2011-09-07 15:13:17 EDT
I too am seeing these errors; more disturbingly, I cannot figure out any way to turn off the validation process that's generating them. I've enabled project-specific client-side Javascript validation in my project and the excluded the minified jQuery file (in my case, jQuery 1.6.3), but the errors and warnings still show up in the Problems view. I've turned off all Javascript validation entirely (turning it off both for Manual and Build), but the problems don't disappear from the view. I've also disabled the various Javascript- and validation-related builders for my project (a Dynamic Web Project), and the problems persist. It's almost as if they're either being generated by something *other* than the validator, or that there's a cache that's persisting.

Of note, after I disable the client-side Javascript validators and then right-click on my project and choose Validate, the dialog box says that zero errors were found -- yet the three minified jQuery-related errors *still* show in the Problems view.
Comment 7 Pete CLA 2011-09-12 05:43:16 EDT
I dont think it only occurs on Linux, I have the same problem on Win7(In reply to comment
Comment 8 Martin Stockhammer CLA 2011-09-21 03:30:01 EDT
Same problem here (Indigo). And the errors cannot not deactivated by changing the validation settings.
(File is jquery-1.6.4.min.js)
Comment 9 Jason Levine CLA 2011-09-21 06:34:19 EDT
Does anyone know if there's logging or other output that we can provide to help narrow down where this is happening? It's getting pretty frustrating to be unable to clear the red-X warnings on projects that include affected "invalid" files.
Comment 10 Chris Miller CLA 2011-10-06 12:23:37 EDT
Seeing this as well in Indigo SR1 on jquery-1.6.2.min.js.  As previously mentioned by others turning off validation and doing a Project Clean... does not seem to get rid of them.
Comment 11 Nitin Dahyabhai CLA 2011-10-06 13:04:43 EDT
The Client-side JavaScript Validator only validates JavaScript in web pages, as its name implies.  For standalone files the JavaScript Validator *Builder* is the one to turn off, but doing so means having to remove the entries from the Problems view manually.
Comment 12 Jason Levine CLA 2011-10-06 16:52:41 EDT
Thank you, Nitin -- that definitely helps narrow this down. Disabling the "Javascript Validator" entry in the Builders configuration for my project, manually deleting the jquery-1.6.3.min.js-related errors in the Problems view, and then rebuilding the project seems to do the trick -- the errors don't come back. But now I'm in the position where the Javascript Validator is turned off, all because of a problem with its validation of a single file. So I guess I have two questions:

1. Is there any way to configure ignore lists for the Javascript Validator builder for a given project?

2. Does the Client-side Javascript Validator hav any dependencies on the Javascript Validator builder? In other words, if the latter is disabled, does the former still work?
Comment 13 Nitin Dahyabhai CLA 2011-10-07 00:35:06 EDT
(In reply to comment #12)
> 1. Is there any way to configure ignore lists for the Javascript Validator
> builder for a given project?

No.

> 2. Does the Client-side Javascript Validator hav any dependencies on the
> Javascript Validator builder? In other words, if the latter is disabled, does
> the former still work?

Yes, there is no direct relationship between the two as far as usage is concerned.
Comment 14 Jason Levine CLA 2011-10-07 06:45:26 EDT
(In reply to comment #13)
> (In reply to comment #12)
> > 1. Is there any way to configure ignore lists for the Javascript Validator
> > builder for a given project?
> 
> No.

Is there an open feature request for this? It seems like that's what's needed to solve this issue... I'm happy to create one, but figured I'd check first.
Comment 15 Nic CLA 2011-12-08 07:52:51 EST
(In reply to comment #14)
> (In reply to comment #13)
> > (In reply to comment #12)
> > > 1. Is there any way to configure ignore lists for the Javascript Validator
> > > builder for a given project?
> > 
> > No.
> 
> Is there an open feature request for this? It seems like that's what's needed
> to solve this issue... I'm happy to create one, but figured I'd check first.

I have found that I can leave the JavaScript Validator enable and ignore specific files by adding a suitable exclusion pattern e.g. **/jquery*.js to the JavaScript/Include Path/Source/Excluded group (Project->Properties->JavaScript->Include Path->Source). 

I found that I also needed to manually delete the old problem markers.
Comment 16 Lin ZuXiong CLA 2012-01-18 21:57:32 EST
I think the authors of JSDT donot know Javascript Language.

I suggest let us close the javascript validation. 
But eclipse jee 3.7.1 canot close JS validation.I close the Preference of
javascript validation and make the level be Ignore ,but eclipse Problems still 
reports the problems (errors and warnings) of Javascript type .

Guys , you all can import a js file ,like JQuery-1.x.min.js , so that you can
find too many errors.
Comment 17 Lin ZuXiong CLA 2012-01-18 22:02:49 EST
Also in Windows 7
Comment 18 Lin ZuXiong CLA 2012-02-06 00:26:49 EST
(In reply to comment #15)
> (In reply to comment #14)
> > (In reply to comment #13)
> > > (In reply to comment #12)
> > > > 1. Is there any way to configure ignore lists for the Javascript Validator
> > > > builder for a given project?
> > > 
> > > No.
> > 
> > Is there an open feature request for this? It seems like that's what's needed
> > to solve this issue... I'm happy to create one, but figured I'd check first.
> 
> I have found that I can leave the JavaScript Validator enable and ignore
> specific files by adding a suitable exclusion pattern e.g. **/jquery*.js to the
> JavaScript/Include Path/Source/Excluded group
> (Project->Properties->JavaScript->Include Path->Source). 
> 
> I found that I also needed to manually delete the old problem markers.

One way is that :
1.remove javascript -> validator -> errors/warning.
2.remove project -> .project file -> javascript command
3.It is important,too! delete js file and import again.
Comment 19 jules CLA 2012-04-24 05:45:34 EDT
I have been using the workaround suggested by Nic in Comment #15 for some time, but as of Indigo SR2 the user interface described does not appear to be available anywhere.  Is there somewhere else this setting can be configured?
Comment 20 jules CLA 2012-04-24 06:36:23 EDT
Please ignore last comment.  Project properties, not general preferences.
Comment 21 Paul Benedict CLA 2012-05-05 12:33:40 EDT
Any chance this can be investigated for 3.9?
Comment 22 jules CLA 2012-07-10 00:23:00 EDT
Just confirming this problem still exists in Juno Release.
Comment 23 Stephen Dharma CLA 2012-08-08 03:14:11 EDT
Issue still occurred.

Environment:
- Eclipse Indigo SR2 (Build ID 20120216-1857).
- Windows 7 Professional Service Pack 1.
Comment 24 Hyukmin Kwon CLA 2012-09-04 02:11:09 EDT
Created attachment 220670 [details]
Modified grammar file

Current grammar file (js.g) does not follow javascript standard.
According to ECMA-262 5th, only first expression in Expression Statement should not start with 'function' or '{'.
However, current js.g prevents all expression in Expression Statement starting with  'function' or '{'.

In current js.g
767    ListExpressionStmt -> AssignmentExpressionStmt
768    ListExpressionStmt ::= ListExpressionStmt ',' AssignmentExpressionStmt
should be
767    ListExpressionStmt -> AssignmentExpressionStmt
768    ListExpressionStmt ::= ListExpressionStmt ',' AssignmentExpression
(also 1056, 1061, 1090, 1094, 1197 should be fixed)
AssignmentExpression derives all expression whereas AssignmentExpressionStmt does not derive 'function' and '{'.

So, below valid sentences are invalid in current grammar.

x, function y() {}; // this pattern is frequently used in minified js library.
x, {};
 
You can fix your parser with attached grammar file.
(http://www.eclipse.org/jdt/core/howto/generate%20parser/generateParser.html, use jsdtcore.jar instead)


I'm not sure this grammar is safe for other cases. For this issue, it works.
Comment 25 Hyukmin Kwon CLA 2012-09-04 02:21:53 EDT
Comment on attachment 220670 [details]
Modified grammar file

Current grammar file (js.g) does not follow javascript standard.
According to ECMA-262, only first expression in Expression Statement should not start with 'function' or '{'.
However, current js.g prevents some other expressions from starting with 'function' or '{'.

For example, in current js.g:
767    ListExpressionStmt -> AssignmentExpressionStmt
768    ListExpressionStmt ::= ListExpressionStmt ',' AssignmentExpressionStmt
should be
767    ListExpressionStmt -> AssignmentExpressionStmt
768    ListExpressionStmt ::= ListExpressionStmt ',' AssignmentExpression
(also 1056, 1061, 1090, 1094, 1197 should be fixed)
AssignmentExpression derives all expression whereas AssignmentExpressionStmt does not derive 'function' and '{'.

So, below valid program are invalid in current grammar.

x, function y() {}; // this pattern is frequently used in minified js library.
x, {};
 
You can fix your parser with attached grammar file.
(http://www.eclipse.org/jdt/core/howto/generate%20parser/generateParser.html, use jsdtcore.jar instead)
Comment 26 Justin Early CLA 2013-01-29 13:09:39 EST
Per this thread [1] vjet team was asked to look at this bug to see if it also applies to vjet.

This bug appears to also apply to VJET's fork of JSDT AST parser. I receive multiple errors on jquery minified. Bug 399415 for VJET has been created to track this on VJET project.

[1] http://dev.eclipse.org/mhonarc/lists/vjet-dev/msg00022.html
Comment 27 Justin Early CLA 2013-02-19 17:37:25 EST
I have looked at this patch and applied it to VJET JS IDE's js parser.  After applying this fix jquery min 1.9 doesn't have any syntax errors. There are some issues with VJET type checking which will be handled in a different bug. see bug 399415 for more info.
Comment 28 Paul Benedict CLA 2013-02-19 18:20:49 EST
Any chance this making it into 4.3?
Comment 29 Justin Early CLA 2013-02-19 20:02:43 EST
There is currently no plan to get VJET into 4.3. 

VJET JS IDE (in incubation) is currently distributed in the Eclipse marketplace.

http://marketplace.eclipse.org/content/vjet-javascript-ide
Comment 30 Paul Benedict CLA 2013-02-19 22:44:53 EST
I am not a user of VJET. Sorry for the confusion. I mean can someone think about slating this for the vanilla 4.3 installation of Eclipse?
Comment 31 Nitin Dahyabhai CLA 2013-02-19 23:35:47 EST
4.3 would be the Eclipse version; for WTP that would be our 3.5 release.

We'll try.
Comment 32 Denis Golovin CLA 2013-11-10 04:01:16 EST
*** Bug 417387 has been marked as a duplicate of this bug. ***
Comment 33 Denis Golovin CLA 2013-11-10 04:13:04 EST
I verified parser generated out of attached js.g file and it works. All tests form org.eclipse.wst.jsdt.core.tests.compiler in JSDTCompilerTests pass with new parser. No errors for minified JQuery js files.

25 votes should be enough to apply it in 3.5.2 and 3.6, shouldn't it?

Going to add tests for parser to test fixed JavaScript problems.
Comment 34 Chris Jaun CLA 2013-11-11 17:45:39 EST
Is there a patch ready to apply? I only see the grammar file attached to this bug.
Comment 35 Denis Golovin CLA 2013-11-11 21:05:08 EST
Created attachment 237381 [details]
webtools.jsdt.core master branch patch
Comment 36 Denis Golovin CLA 2013-11-11 21:06:30 EST
Created attachment 237382 [details]
webtools.jsdt.tests master branch patch with test for the fix added
Comment 37 Denis Golovin CLA 2013-11-11 21:10:32 EST
(In reply to Chris Jaun from comment #34)
> Is there a patch ready to apply? I only see the grammar file attached to
> this bug.

Patches are attached. I tested various compressed and uncompressed jQuery js files and haven't seen any errors reported.
Comment 38 Michael Rennie CLA 2013-11-12 12:08:43 EST
(In reply to Denis Golovin from comment #37)
> (In reply to Chris Jaun from comment #34)
> > Is there a patch ready to apply? I only see the grammar file attached to
> > this bug.
> 
> Patches are attached. I tested various compressed and uncompressed jQuery js
> files and haven't seen any errors reported.

The core patch misses all the binary changes to the *.rsc files and is also missing the changes to readableNames.properties - once you re-gen the parser it all works fine and all tests pass. Smoke testing using a variety of minified files and the entire Orion code-base does not produce any unexpected errors.
Comment 39 Denis Golovin CLA 2013-11-12 14:10:42 EST
(In reply to Michael Rennie from comment #38)
> (In reply to Denis Golovin from comment #37)
> > (In reply to Chris Jaun from comment #34)
> > > Is there a patch ready to apply? I only see the grammar file attached to
> > > this bug.
> > 
> > Patches are attached. I tested various compressed and uncompressed jQuery js
> > files and haven't seen any errors reported.
> 
> The core patch misses all the binary changes to the *.rsc files and is also
> missing the changes to readableNames.properties - once you re-gen the parser
> it all works fine and all tests pass. Smoke testing using a variety of
> minified files and the entire Orion code-base does not produce any
> unexpected errors.

I didn't include files that weren't changed:
1. parser[21,24].rsc are the same after generation (at least git doesn't show them as changed)
2. Generated readableNames.properties have no copyright comment, but everything else is the same.
Comment 40 Michael Rennie CLA 2013-11-12 14:14:14 EST
(In reply to Denis Golovin from comment #39)

> 
> I didn't include files that weren't changed:
> 1. parser[21,24].rsc are the same after generation (at least git doesn't
> show them as changed)
> 2. Generated readableNames.properties have no copyright comment, but
> everything else is the same.

Weird. Did you forget to run the UpdateParserFiles class after the parser updates? Once you do that step and copy the files over, they are all changed.
Comment 41 Denis Golovin CLA 2013-11-12 14:58:23 EST
Yes, I did all by the jdt doc about generating parser, and run (In reply to Michael Rennie from comment #40)
> (In reply to Denis Golovin from comment #39)
> 
> > 
> > I didn't include files that weren't changed:
> > 1. parser[21,24].rsc are the same after generation (at least git doesn't
> > show them as changed)
> > 2. Generated readableNames.properties have no copyright comment, but
> > everything else is the same.
> 
> Weird. Did you forget to run the UpdateParserFiles class after the parser
> updates? Once you do that step and copy the files over, they are all changed.

Yes, I did all by the jdt doc updating parser and ran UpdateParserFiles. I had problems on Linux, but everything worked fine on windows. Then I moved them over to my linux desktop and made the patches.

Then tested patch under linux and windows.
Comment 42 Victor Rubezhny CLA 2013-11-12 16:52:18 EST
(In reply to Michael Rennie from comment #40)
> (In reply to Denis Golovin from comment #39)
> 
> > 
> > I didn't include files that weren't changed:
> > 1. parser[21,24].rsc are the same after generation (at least git doesn't
> > show them as changed)
> > 2. Generated readableNames.properties have no copyright comment, but
> > everything else is the same.
> 
> Weird. Did you forget to run the UpdateParserFiles class after the parser
> updates? Once you do that step and copy the files over, they are all changed.

I've replicated all the steps of re-generating the parser and achieved the pretty same results:

All the *.rsc were regenerated. Didn't compare their content, but I see all of them in my git-patch as well as in Dennis' patch (look at the source - you'll see all those *.rsc files there in Denis's patch). 

Generated readableNames.properties is the same as before, except the header comment. I've restored the comment in my version and modified the year of last change. So, git diff shows the only 1 comment line (with that year) has changed.

In my case the parser also works as expected.

So, I'm +1 for the Denis' patch to be pushed (If those 'year of change' in comments is not so important).
Comment 43 Denis Golovin CLA 2013-11-14 13:57:22 EST
Please also consider proposed patches for Kepler SR2 release.

Explain why you believe this is a stop-ship defect:
* Parser fails for many compressed js libraries and thus errors reported for correct projects.

Is there a work-around? If so, why do you believe the work-around is insufficient?
* Validation can be disabled but that lead to loosing valuable functionality like content assist.

How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added?
* Tested with JSDT JUnit tests for parser and ast model. All tests are passed with no errors. Test added to verify that function expression now accepted in List Expression Statements. Attached patches are tested against master and 3_5_maintenance branches

Give a brief technical overview. Who has reviewed this fix?
* In previous js.g was:
767    ListExpressionStmt -> AssignmentExpressionStmt
768    ListExpressionStmt ::= ListExpressionStmt ',' AssignmentExpressionStmt
in new js.g is:
767    ListExpressionStmt -> AssignmentExpressionStmt
768    ListExpressionStmt ::= ListExpressionStmt ',' AssignmentExpression
(also fixed in some other lines where List Expression Statements can be used)
AssignmentExpression derives all expression whereas AssignmentExpressionStmt does not derive 'function' and '{'.

What is the risk associated with this fix?
* Low. All JUnit Tests are good after applying the patches in master and 3_5_maintenance branches. Parser doesn't report errors for latest jQuery compressed js files (tested manually).
Comment 44 Chris Jaun CLA 2013-11-18 10:43:35 EST
Denis, I'm getting ready to push this. Can you add the Certificate of Orgin sign off statement to the comments of this bugzilla? Described near the bottom of this page: http://wiki.eclipse.org/Development_Resources/Contributing_via_Git
Comment 45 Denis Golovin CLA 2013-11-18 12:33:50 EST
(In reply to Chris Jaun from comment #44)
> Denis, I'm getting ready to push this. Can you add the Certificate of Orgin
> sign off statement to the comments of this bugzilla? Described near the
> bottom of this page:
> http://wiki.eclipse.org/Development_Resources/Contributing_via_Git

This contribution complies with http://www.eclipse.org/legal/CoO.php
Comment 46 Chris Jaun CLA 2013-11-18 13:17:10 EST
Pushed to 3.5.2 and 3.6.
Comment 48 Alexander Willner CLA 2014-01-02 08:28:19 EST
(In reply to Chris Jaun from comment #46)
> Pushed to 3.5.2 and 3.6.

Nice - but what about pushing it to Eclipse 4 as well? I'm using version 4.3.2 (Build id: M20140101-1810) and the issue still occurs.
Comment 49 Mickael Istria CLA 2014-01-02 08:40:15 EST
@Alexander: versions listed here are JSDT versions. JSDT 3.5.2 will be part of Kepler SR2 (due February) and JSDT 3.6 will be part of Eclipse 4.4 Luna (June).
You may already be able to use the WTP Integration Build from http://download.eclipse.org/webtools/downloads/drops/R3.6.0/I-3.6.0-20131217131919/repository/ to give a try to this change before it gets part of a release.
Comment 50 Denis Golovin CLA 2014-01-03 14:08:25 EST
Verified on Luna M4, no more errors in minified jQuery files.
@Victor, could you confirm that and mark the issue as verified?
Comment 51 Victor Rubezhny CLA 2014-01-03 17:26:05 EST
(In reply to Denis Golovin from comment #50)
> Verified on Luna M4, no more errors in minified jQuery files.
> @Victor, could you confirm that and mark the issue as verified?

Yes, this issue is gone, but some UI issues are still occuring (See Bug #424131 and Bug #424193). 

Those two UI issues still making the Editor to complain on JSDT errors/warnings. Bug #424131 is fixed in WTP R352 integration build 01022014, while other has a work around (a user might type a char or just close and open the editor again due to see those errors/warnings gone)
Comment 52 Victor Rubezhny CLA 2014-01-03 18:00:00 EST
Verified for WTP 3.5.2 and WTP 3.6