Search code examples
eclipsescalascala-ide

scala code completion in eclipse


[EDIT]: I am an idiot. I was using 'Eclipse IDE for Java Developers' and should have been using 'Eclipse Classic'. The Scala plugin works much better under Classic.

*[EDIT]: 11/1/2011 - the Beta 12 release that came out on 10/31 seems to be significantly better *

**[EDIT]: 11/4/2011 - the Beta 12 release became unstable to the point that our team switched to IntelliJ. I hope to try the Eclipse plugin in the future and have a different experience.

I have a blended java/scala project in eclipse, and I'm finding that the code-completion doesn't always work. It seems to have the most issues with 'objects', and classes that are defined in a different project. I understand that this is just a 'feature' of the scala plugin, but are there any things I should be doing to try to minimize the impact of these features?

Eclipse Indigo
Scala Plugin: 2.0.0-beta11 

After playing with it for one more day, I find that most of the issues arise when accessing static members of java classes from scala.


Solution

  • There are currently (Scala plugin version: 2.0.0.beta11-2_09-201110031011-3a97f5e, Eclipse version: 3.6.2.v201102101200) a number of problems with the code completion in the plugin. BTW, this is not the latest version of the plugin, and I know that a number of these issues are being actively worked on.

    Firstly, please ensure that in the Scala->Setup Diagnostics the two options for completion are checked:

    1. Use Scala-compatible JDT content assist proposals
    2. Enable JDT content auto-assist activation

    There are two general areas of problems:

    1. The autocompletion of classes sometimes does not add the import correctly.

      val foo = new Th<ctrl-space>

    2. The methods on a class do not appear when you're doing ctrl-space.

    The workaround for these problems is to add the import for the class that you're trying to use manually. This avoids the vast majority of the problems. It's a pain I know, but it works.

    I haven't looked at this code recently, but as I remember the problems are mostly due to:

    1. speed of the scala compiler (it's just not as fast as the java compiler)
    2. the class search facility (which is being worked on, I think most of the problems have been ironed out now)
    3. The complexity of the proposals required, i.e. you have to wait for the scala compiler to finish it's work so that it can know all of the methods from all of the traits etc.
    4. The maturity of the solution.

    Also, please note that some of the methods that you're expecting may not appear at all. If the object is subject to an implicit conversion,, then you'll not get the methods that you're expecting.

    If you do come across problems, then please first look at the Known Issues, and the at the list of open issues. If the issue exists, please add your use case to it, including version numbers and any other relevant information. If your issue doesn't exist, please create it.

    For extra brownie points, you could clone the scala ide on github and submit a pull request with your fix.