如何提高 Eclipse 代码完成度?
Eclipse 找不到用于代码完成的正确变量,如下所示。
int i = 0;
f(xyz); // f takes an int but eclipse won't fill it with i.
Eclipse does not find the correct variable for code completion as shown below.
int i = 0;
f(xyz); // f takes an int but eclipse won't fill it with i.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在“窗口”下> “偏好设置”> “Java”> “编辑器”> “内容辅助”,确保设置“填充方法参数并显示猜测参数”并选择“插入最佳猜测参数”。
编辑:
我在 Eclipse 中尝试了此操作(版本:Helios Service Release 1 - 构建 ID:20100917-0705):
在输入
f
后,我按空格并选择f(xyz)
,Eclipse 确实提供了f(i)
,其中i
突出显示,并且在i
的下拉菜单中code>(突出显示)、xyz
和0
。i
是默认值。我找不到任何关于 Eclipse 如何选择“最佳猜测参数”的信息(我不知道在 Eclipse 源代码中查找)。我猜测 Eclipse 会根据类型、名称和可见性进行“猜测”,并且 Eclipse 认为存在比本地变量更好的匹配。也许如果局部变量的类型和名称更接近,它会是更好的匹配?
Under "Window" > "Preferences" > "Java" > "Editor" > "Content Assist", make sure "Fill method arguments and show guess arguments" is set and "Insert best guessed arguments" is selected.
Edit:
I tried this in my Eclipse (Version: Helios Service Release 1 - Build id: 20100917-0705):
Right after I typed the
f
, I hit space and selectedf(xyz)
, Eclipse did supplyf(i)
withi
highlighted and in a pop-down menu ofi
(highlighted),xyz
, and0
.i
was the default.I couldn't find any info on how Eclipse selects the "best guessed parameters" (I have no idea where to look in the Eclipse source). I would guess that Eclipse "guesses" based on type, name, and visibility, and that Eclipse thinks there's a better match than your local variable. Perhaps if the local variable were closer in type and name, it would be a better match?