如何改进eclipse代码完成?

时间:2010-12-22 02:45:43

标签: eclipse code-generation content-assist

Eclipse没有为代码完成找到正确的变量,如下所示。

int i = 0;
f(xyz);    // f takes an int but eclipse won't fill it with i.

1 个答案:

答案 0 :(得分:1)

在“窗口”下> “偏好”> “Java”> “编辑”> “内容辅助”,确保设置“填充方法参数和显示猜测参数”并选择“插入最佳猜测参数”。


编辑:

我在Eclipse中尝试了这个(版本:Helios Service Release 1 - Build id:20100917-0705):

public class BestGuessedParameter {
    static int xyz = 1;
    static void f(final int xyz) {
    }
    public static void main(final String[] args) {
        final int i = 0;
        f/*cursor here*/
    }
}

在我输入f之后,我点击了空格并选择了f(xyz),Eclipse确实提供了f(i),其中i突出显示,并在i的弹出菜单中显示1}}(突出显示),xyz0i是默认设置。

我找不到关于Eclipse如何选择“最佳猜测参数”的任何信息(我不知道在Eclipse源代码中查找)。我猜想Eclipse会根据类型,名称和可见性“猜测”,并且Eclipse认为匹配比本地变量更好。也许如果局部变量在类型和名称上更接近,那么它会更好匹配吗?

相关问题