Eclipse JavaScript Editor: content assist for js f

2019-01-04 09:04发布

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.

11条回答
\"骚年 ilove
2楼-- · 2019-01-04 09:31

As a complement to the other answers I strongly recommend installing the Eclipse JSHint plugin. You can configure it via project preferences and it works like a charm. It shows additional warnings in the JavaScript editor.

I would also recommend writing jsDoc above your functions as this will help Eclipse (@memberOf, you can use Ctrl+o to navigate).

You may also move to TypeScript as Eclipse support is now mature (2015), TypeScript is typed and an IDE can reap the benefits (autocompletion works like a charm with Palantir).

查看更多
SAY GOODBYE
3楼-- · 2019-01-04 09:35

For Aptana Studio 3: (plugin for Eclipse tested)

Find a library you are interested in...Save it to your disk, and then drag it into your project. It does not matter where in the project it sits, so you can create a new folder for files like this if you like.

!! The project must be some type of web project: Web, PHP, Python, Ruby, Rails.

http://wiki.appcelerator.org/display/tis/Using+JavaScript+Libraries

查看更多
闹够了就滚
4楼-- · 2019-01-04 09:37

I just figured out how 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)

查看更多
甜甜的少女心
5楼-- · 2019-01-04 09:38
  1. Right click on your project and select Properties.
  2. Expand Javascript -> Include Path.
  3. In the Libraries tab, click "Add Javascript Library".
  4. Select "User Library" -> "Configure User Libraries".
  5. Add all the .js files you need, click OK and wait for the project build to complete.
  6. You should have code completion from all library files you added when editing your own .js files.

Adding .js Libraries to your project

查看更多
男人必须洒脱
6楼-- · 2019-01-04 09:41

Enabling Javascript validation for Aptana Studio 3.2:

  1. Window -> Preferences -> Validation
  2. Select Javascript and enable jslint
  3. Project -> Properties -> Project Natures
  4. Select Web (and anything else you'd like)
  5. Window -> Show View -> Problems
  6. Save your file, problems should fill up with warnings
查看更多
劫难
7楼-- · 2019-01-04 09:46

I tried and failed at many suggestions. About to give up I came across this:

  1. Search for JSDT jQuery from the Eclipse market place and install. I found JSDT jQuery 1.5.0.
  2. Right click on your project and configure build path (I know I wish it were workspace level too).
  3. Go to JavaScript > Include Path and click Add JavaScript Library...
  4. Choose jQuery. This is v1.8 support. I looked but couldn't find anything newer.
  5. Restart Eclipse and viola.

Finally, right?!

查看更多
登录 后发表回答