Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324416 - JSDT cannot correctly parse jQuery 1.4.2 files
Summary: JSDT cannot correctly parse jQuery 1.4.2 files
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major with 8 votes (vote)
Target Milestone: 3.2.3   Edit
Assignee: Chris Jaun CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
: 277165 289805 289806 298577 325519 326894 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-03 09:59 EDT by Scott Kellicker CLA
Modified: 2010-11-17 16:26 EST (History)
11 users (show)

See Also:
thatnitind: review+


Attachments
jQuery .js file to add as a library (160.01 KB, text/plain)
2010-09-03 10:00 EDT, Scott Kellicker CLA
no flags Details
proposed patch to treat undefined as a regular identifier and not a keyword (does not update syntax coloring) (889 bytes, patch)
2010-09-09 13:40 EDT, Nitin Dahyabhai CLA
no flags Details | Diff
Updated patch (4.41 KB, patch)
2010-10-29 11:02 EDT, Chris Jaun CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Kellicker CLA 2010-09-03 09:59:05 EDT
Build Identifier: Helios

There are screenshots here: http://kellicker.wordpress.com/2010/09/03/using-jsdt-4-adding-third-party-library.

I have successfully added mooTools as a user library and seen content assist.  However, JSDT seems to be confused when I add jQuery.


Reproducible: Always

Steps to Reproduce:
1. add uncompressed jQuery 1.4.2 as javascript user library.  Add it to project
2. Create test.js.
3. Type jQ<ctrl-space>.
Should see content assist for jQuery variable.  Do not.
4. If I open the jQuery library in Explorer, the AST/DOM is clearly confused as the first 8 or so entries are "_load".  See referenced screenshots.
Comment 1 Scott Kellicker CLA 2010-09-03 10:00:06 EDT
Created attachment 178148 [details]
jQuery .js file to add as a library
Comment 2 Jacek Pospychala CLA 2010-09-03 11:42:50 EDT
Scott, 
do you know what exactly breaks JSDT's parser in jQuery 1.4? In 1.3 I remember it was the use of "undefined" as a variable (bug 298577). After removing 1 line, all jQuery file was parsed correctly.

I'm wondering what this time :-)
Comment 3 Scott Kellicker CLA 2010-09-03 11:55:46 EDT
(In reply to comment #2)
> Scott, 
> do you know what exactly breaks JSDT's parser in jQuery 1.4? In 1.3 I remember
> it was the use of "undefined" as a variable (bug 298577). After removing 1
> line, all jQuery file was parsed correctly.
> 
> I'm wondering what this time :-)

No idea.  I haven't taken the time to dig into it.  I did take a glance at the log and didn't see anything obvious.


The fact that _load is being considered a variable, makes me think that its tripping on constructs like this:

var jsc = now(),
	rscript = /<script(.|\s)*?\/script>/gi,
	rselectTextarea = /select|textarea/i,
	rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
	jsre = /=\?(&|$)/,
	rquery = /\?/,
	rts = /(\?|&)_=.*?(&|$)/,
	rurl = /^(\w+:)?\/\/([^\/?#]+)/,
	r20 = /%20/g,

	// Keep a copy of the old load method
	_load = jQuery.fn.load;
Comment 4 Nitin Dahyabhai CLA 2010-09-09 13:40:35 EDT
Created attachment 178538 [details]
proposed patch to treat undefined as a regular identifier and not a keyword (does not update syntax coloring)
Comment 5 Scott Kellicker CLA 2010-09-09 18:53:55 EDT
I tried the proposed patch with latest source.  There was no change in the behavior.

I think the problem must be elsewhere.
Comment 6 Nitin Dahyabhai CLA 2010-09-09 21:54:13 EDT
Strange.  Without the patch the Outline view simply shows a flat list of functions and variables.  With it, a jQuery type is created, although it's missing every function that's added by jQuery.extend().
Comment 7 Chris Jaun CLA 2010-09-16 15:57:52 EDT
*** Bug 277165 has been marked as a duplicate of this bug. ***
Comment 8 Chris Jaun CLA 2010-09-16 15:59:04 EDT
*** Bug 325519 has been marked as a duplicate of this bug. ***
Comment 9 Nitin Dahyabhai CLA 2010-09-27 17:06:11 EDT
*** Bug 298577 has been marked as a duplicate of this bug. ***
Comment 10 Jacek Pospychala CLA 2010-10-04 04:13:22 EDT
*** Bug 326894 has been marked as a duplicate of this bug. ***
Comment 11 Chris Jaun CLA 2010-10-29 11:02:43 EDT
Created attachment 182052 [details]
Updated patch
Comment 12 Chris Jaun CLA 2010-10-29 11:15:56 EDT
*** Bug 289806 has been marked as a duplicate of this bug. ***
Comment 13 Chris Jaun CLA 2010-10-29 15:18:28 EDT
*** Bug 289805 has been marked as a duplicate of this bug. ***
Comment 14 Bouiaw CLA 2010-11-02 18:07:31 EDT
Could you provide a binary patch for WTP 3.2.2 in order to make testing easier ?
Since this is a blocking issue for a lot of users, it could help a lot of people.
Comment 15 Nitin Dahyabhai CLA 2010-11-15 21:47:57 EST
(In reply to comment #11)
> Created an attachment (id=182052) [details]
> Updated patch

Unrelated change in org.eclipse.wst.jsdt.internal.compiler.batch.CompilationUnit?
Comment 16 Chris Jaun CLA 2010-11-17 10:27:32 EST
(In reply to comment #15)
> (In reply to comment #11)
> > Created an attachment (id=182052) [details] [details]
> > Updated patch
> 
> Unrelated change in
> org.eclipse.wst.jsdt.internal.compiler.batch.CompilationUnit?


No, that is needed so that the junits pass.
Comment 17 Chris Jaun CLA 2010-11-17 16:26:39 EST
Checked into 3.2.3 and HEAD.