Question

[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.

Was it helpful?

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.

OTHER TIPS

You may want to try the http://groups.google.com/group/scala-ide-user group, provided you can provide additional details and hopefully not use the word suck.

All I can say is this short test case works fine for me on Helios SR2 and Eclipse Scala plugin 2.0.0.beta11. I'm not sure how deep the support is for multi-projects with Java and it's possible there are known limitations.

I tested with the following structure.

  1. test1 scala project, test2 scala project and a test3 java project.
  2. I added test1 and test3 as dependent projects to test2 and also added them to the build path
  3. in test2 I can autocomplete classes from test1 and test3; and on an object from test1 (if you're still following me)

Here is what was autocompleted (see comments)

package test2

import test1.{A1, O1} // A1 and O1 choices offered from A or O

class A2 {

  val a1 = new A1
  a1.ma1("foo") // ma1 was autocompleted from m

  val a3 = new test3.A3 // test3 choice offered from test
  a3.ma3("wqqw").toLowerCase() // ma3 completed from m
  // toLowerCase was completed from toL (3 choices offered)

  val o1 = O1.mo1  // mo1 was autocompleted from m
  val ox = O1 // O1 was completed from O (as second choice)
}

This is a old post and my environment is slight different but I had the same problem with Eclipse Luna + Scala IDE plugin(4.2.0), and found a solution so wanted to contribute.

In my case, no autocompletion on Ctrl+Space and actually no compilation errors were shown either.

My workaround was

  1. Right click on a Scala project
  2. Scala -> Add Scala Library to Build Path

Then it started working.

enter image description here

(Scala Library container [2.11.7] was missing from my project)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top