[英]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'.
我正在使用“面向Java开发人员的Eclipse IDE”,并且应该一直在使用“ Eclipse Classic”。 The Scala plugin works much better under Classic.
Scala插件在Classic下工作得更好。
* [EDIT]: 11/1/2011 - the Beta 12 release that came out on 10/31 seems to be significantly better * * [编辑]:2011年11月1日-10/31发行的Beta 12版本似乎要好得多*
**[EDIT]: 11/4/2011 - the Beta 12 release became unstable to the point that our team switched to IntelliJ. ** [编辑]:2011年1月4日-Beta 12版本变得不稳定,以至于我们的团队改用了IntelliJ。 I hope to try the Eclipse plugin in the future and have a different experience.
我希望以后再尝试使用Eclipse插件,并获得不同的体验。
I have a blended java/scala project in eclipse, and I'm finding that the code-completion doesn't always work. 我在eclipse中有一个Java / scala混合项目,但我发现代码补全并不总是有效。 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?
我了解这只是scala插件的“功能”,但是我应该做些什么来尽量减少这些功能的影响?
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. 在玩了一天之后,我发现从scala访问java类的静态成员时,大多数问题都会出现。
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 . 您可以尝试http://groups.google.com/group/scala-ide-user组,前提是您可以提供其他详细信息,并且希望不要使用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. 我只能说这个简短的测试用例在Helios SR2和Eclipse Scala插件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.
我不确定对Java多项目的支持有多深,有可能存在已知的局限性。
I tested with the following structure. 我用以下结构进行了测试。
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)
}
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. 目前,插件中的代码完成存在许多问题(Scala插件版本:2.0.0.0.beta11-2_09-201110031011-3a97f5e,Eclipse版本:3.6.2.v201102101200)。 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: 首先,请确保在Scala-> Setup Diagnostics中选中了两个完成选项:
There are two general areas of problems: 一般有两个方面的问题:
The autocompletion of classes sometimes does not add the import correctly. 类的自动完成有时不能正确添加导入。
val foo = new Th<ctrl-space> val foo =新的Th <ctrl-space>
The methods on a class do not appear when you're doing ctrl-space. 在执行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: 我最近没有看过这段代码,但据我所知,问题主要是由于:
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. 对于额外的布朗尼点,您可以在github上克隆scala ide并使用修复程序提交请求请求。
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. 这是一篇老文章,我的环境略有不同,但是我对Eclipse Luna + Scala IDE插件(4.2.0)遇到了相同的问题,并且找到了一个想要做出贡献的解决方案。
In my case, no autocompletion on Ctrl+Space and actually no compilation errors were shown either. 就我而言,在Ctrl + Space上没有自动补全,实际上也没有显示任何编译错误。
My workaround was 我的解决方法是
Then it started working. 然后它开始工作。
(Scala Library container [2.11.7] was missing from my project) (我的项目中缺少Scala库容器[2.11.7])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.