0

What is the best way to / How can I get Eclipse to give content assist/completion in a large javascript application.

We are developing a large application with HTML/javascript in the front end. We want to awoid cluttering up the javascript environment with lots of functions, and thus want to build a namespace for our application, lets call it app.

in order to extend our namespace we want to be able to call app.namespace("package").function = function(){...}

namespace("package") resolves the package if it exits, or creates it if it does not.

The problem at hand is that this aproach helps us keep the environment clean, but makes content assist harder (or impossible?)

Any ideas on how to get this approach to work with code completion and content assist in eclipse? Are there any other IDEs around that would make this possible?

Henrik
  • 21
  • 4

1 Answers1

0

I found several solutions for this question, none of them fullfilling exactly what I was after but each with their own strongpoints. I looked at Aptana plugin, Visual Web Developer 2010 Express and WebStorm.

Eclipse

For Eclipse, I ended up with the Aptana. This plugin has somewhat stronger code completion support than the standard eclips JavaScript perspective. To make our solution work, we had to create "interfaces" publishing what is available alongside our actual code. We put these interfaces in a file structure mapping to our actual code, and just leave it out when building the application.

To get the Aptana plugin to work propperly, you need to do some changes to your setup. Under "Properties" you need to set the "Project Nature" to "Web". Secondly, you need to edit the "Preferences/General/Editors/File Associations" make sure to set the "JavaScript Source Editor" as default NOT the standard "JavaScript Editor". Once you reopen your javascript source files, you should be ready to go :)

Visual Web Developer 2010 Express

Actually this is pretty good for js development. The down side is offcource that installing this will install a lot of rubbish you dont need on your machine, and it takes forever and 5 (five!) reboots to install. But once you are ready to go, it is actually pseudo running your code as you type. In effect all your dynamically generated objects are available to you with intellisense giving you type specific help (Strings, Numbers, Objects, etc.) To get this fantastic (I don't think I have ever used this word alongside a Microsoft product before) behaviour in cross file references you will need to apply some magic at the top of your file.

/// <reference path="path to another js source file you want intellisense for">

WebStorm

I did not look as deep into this solution as the other two, because we would need a commercial licence for this product (free licence for non comercial use available). It looks like you get many of the features available for visual web developer in this IDE as well. In fact I think this IDE gives you the most hits under Code Completion and Code Assist of the three. I actually think you get too many hits under code completion, at least i got hits that were out of scope, thus making it harder to actually use properly. It's hopefully possible to tweak this behaviour so you get more accurate support from the IDE, but I did not have the time to investigate further.

Our conclusion

For our part, we will probably go for the Aptana plugin for eclipse or Visual studio. Eclipse is our default IDE, and our organisation has Visual Studio in our line of approved development tools, but I would have checked out WebStorm further if we hadn't had any prefered choices in advance that are already using.

Henrik
  • 21
  • 4