9

I have a larger maven multi-module project where multiple languages are involved. Now with Eclipse JDT and JSDT installed the code coloring works fine but code completion in JavaScript does not work very well which makes it hard to be productive. Eclipse does not seem to find JavaScript classes in my project so i am also not able to jump around JavaScript methods very easily. Mapping JavaScript classes seems also not possible since this is a Java project and i see no way to mix up project natures.

Is there a way to improve this behavior? Or are there any other JavaScript Plugins which are able to do so and work simultaneously with JDT?

3
  • 1
    JavaScript "smart" code completion is a fairly hard problem because the language is so dynamic. It's pretty hard for the editor environment to know what type of object a symbol might refer to because there are no type declarations. Commented Feb 11, 2011 at 14:35
  • 2
    why is IntelliJ able to do it then? ;) Commented Feb 11, 2011 at 14:40
  • Is my understading that IntellJ can even do it, in a mixed scenario ( eg. jsp / javascript ) They have a different ( better ) architecture. Commented Feb 11, 2011 at 16:35

2 Answers 2

8

You can definitely mix Java and JavaScript development in Eclipse. The Dynamic Web Project creates such a configuration by default.

To add JavaScript support to any Java project, do the following...

  1. Project Properties -> Project Facets
  2. Click on "Convert to faceted form" link
  3. Check JavaScript and hit ok to close the dialog.
  4. Make sure that you are in a perspective that has "Project Explorer" view as opposed to "Package Explorer", which is standard in Java perspective or open that view yourself. Unlike the Java-specific Package Explorer, the Project Explorer view accommodates different technology extensions, such as JavaScript.

Enjoy. Facets are somewhat like natures, but unlike natures the can be user-manipulated without hacking metadata files. New Eclipse tooling, like JSDT has been moving to providing facets to make enablement easier.

Sign up to request clarification or add additional context in comments.

4 Comments

Maybe I'm missing something, but which such a config, editing JS is much slower and there are no completions at all, as opposed to what you'd get with a JS project.
Code completions work but agree they are not fast. However, this works; has my vote for the correct answer... +1
With 2019-12 it stops warning but fails to do anything.
RIP Facets in 2020.
0

Does it work for you if you open up your .project file and add a new <nature> into the <natures> element? I've done that to apply the java nature to non-java projects which had other natures.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.