views:

2776

answers:

2

I'm trying Eclipse (with JavaEE and Web Development plugins) as a JavaEE/GoogleAppEngine IDE. In HTML editor if I put a <script ... src="..." /> in <head> I automatically get content assist for javascript in the referenced file. I was wondering if it was possible to obtain content assist for other javascript files (e.g. jQuery or homebrew js library) inside javascript editor.

+2  A: 

imo, Aptana is the best eclipse plugin for js editing. It includes support for many of the major libraries like jQuery, yui, dojo, etc.

Spket, however is also good. Though mostly if you do firefox extension development (getting a little out of date though)

The built in js editor is terrible. it claims there are errors all over the place even when there clearly are not.

Jonathan Fingland
Thanks for the hint: I just installed Aptana js editor plugin and it looks really nice. But, how do I get content assist for my js files (not libraries)?
Utaal
if it didn't make the association automatically, go to the window menu -> preferences. In the general section of preferences, go to editors->file associations. Then select the *.js file type and set aptana editor as the default
Jonathan Fingland
also, for jquery code assist, you need to go to preferences -> Aptana -> Editors -> JavaScript -> Code Assist and check the box next to jQuery
Jonathan Fingland
+2  A: 

I just figured out hot to obtain js content assist in eclipse javascript editor (without Aptana plugins):

if the project type doesn't natively contain JavaScript Support: open Web (or JavaScript) perspective, right-click on the project and select Web Development Support > Add JavaScript Support (this won't hurt if javascript support is already present)

then right-click JavaScript Support within the project and select Properties, in the JavaScript section go to JavaScript library and then select Source tab: here you can add folders and files to be scanned by content assist for the current project


In Aptana Studio (as an eclipse plugin but I suppose the standalone version is almost the same): open any js or html file, show References window (or open Aptana perspective in eclipse) and drag-drop js files you want to add to javascript scope (it is possible to build and activate different scope profiles with different javascript files and resources: just click add profile in the window toolbar)

Utaal
unfortunately, this way gives you significant quantities of erroneous errors as the built-in javascript parser is somewhat sub-optimal
Jonathan Fingland
@Jonathan: "Somewhat?" I just installed the latest Eclipse and it fails on basic things like understanding regex literals with quotes in them, or the `undefined` keyword when used as a function parameter. Yikes.
T.J. Crowder