Eclipse: Using “Open Declaration” … in a Scala pro

2019-08-01 10:04发布

问题:

I've been trying to convert from Java to Scala for a few months, and found that the greatest roadblock is that Eclipse plugin for Scala is hardly better then using Vim.

I normally have "Build Automatically" on, so apart from Open and Save, the commands I use most of the time are:

Open Declaration (F3)
References > Workspace (Ctrl-Shift-G)
Open Type Hierarchy (F4)
Open Type (Ctrl-Shift-T)
Content Assist (Ctrl-Space)

and looking at the Outline.

None of this works with the Scala IDE for the libraries. Some stuff works for my own code, like outline. But the rest just returns the following error:

The resource is not on the build path of a Java project.

Is there any way to get any of those things to work in Eclipse? Without them, basically the only thing I get is syntax highlight and compile-on-save, and I can get syntax highlight from vim without needing 1.5 GB of ram...

With implicits, and static function import, finding out from where something comes is really difficult without F3. I ended up using Google to find what class/trait defines what.

[EDIT] I just pulled Eclipse Classic 3.6.2, and update-1.0.0-milestones-2.8.1.final, which wasn't available the last time I checked. They have fixed the Outline, and "Open Type", that's it. The rest still doesn't work.

回答1:

Which version of the Eclipse plugin are you using? If the version is from a while ago, then you're right, it's a bit buggy.

However, there is a new version, currently in beta (as of 23.04.2011) available from Scala IDE Eclipse download site. This is a lot better.

Also, please make sure that the 'Use JDT content assists' checkboxes are checked in Scala->Setup diagnostics window.

Please try the new version, and see if it fixes your problems. If not, raise a bug, and the team will fix it.