Eclipse 没有给我变量名建议
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12925781/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse not giving me variable name suggestions
提问by Arturas M
well I've seen in Tips & Tricks of Eclipse that it's possible to get a variable name generated by eclipse by clicking Ctrl + Space. However I'm getting empty suggestions. Fors instance I'm typing this and click ctrl + space:
好吧,我在 Eclipse 的提示和技巧中看到,可以通过单击 Ctrl + Space 来获取 Eclipse 生成的变量名称。但是我得到了空洞的建议。例如,我正在输入此内容并单击 ctrl + space:
private Color
私人颜色
And I am supposed to get some name suggestions on it? All I'm getting is an empty list of suggestions. So what's turned off? Any idea?
我应该得到一些关于它的名字建议吗?我得到的只是一个空的建议列表。那么关掉了什么?任何的想法?
Thanks in advance.
提前致谢。
This is what I want to achieve:
这就是我想要实现的目标:
回答by Yogendra Singh
I believe you are trying to get variable name e.g. color
after private Color
where Color
is you class i.e. private Color color
. I see that working in my eclipse.
我相信您正在尝试获取变量名称,例如color
在您在private Color
哪里Color
上课 ie 之后private Color color
。我看到这在我的日食中起作用。
To verify your settings, go to below settings and verify as they look good to you.
要验证您的设置,请转到以下设置并验证它们是否适合您。
Windows -> Preferences -> Java -> Editor ->Content Assist
and
和
Windows -> Preferences -> Java -> Editor ->Content Assist -> Advanced
回答by Rana Ranvijay Singh
Goto Window -> preferences -> java -> Editor -> content Assist ->Advances -> Select all the check boxes. DONE :)
转到窗口 -> 首选项 -> java -> 编辑器 -> 内容辅助 -> 高级 -> 选中所有复选框。完毕 :)
回答by Michael Fulton
This is the default behavior after entering a Java type and a space, and then pressing CTRL+Spaceto activate auto-complete. For example, if you enter:
这是输入 Java 类型和空格,然后按CTRL+Space激活自动完成后的默认行为。例如,如果您输入:
private Color
then activate auto-complete it will suggest some variable names for you.
然后激活自动完成它会为您建议一些变量名称。
An easier way than having to press CTRL+Spaceall the time is to change the characters which automatically activate auto-complete. I find it very useful to have all characters which could possible be variable names to activate auto-complete. Try having ._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
as Auto activation triggers for Java
found in Preferences -> Java -> Editor -> Content Assist:
比一直按CTRL+更简单的方法Space是更改自动激活自动完成功能的字符。我发现让所有可能是变量名的字符激活自动完成非常有用。尝试具有._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
如Auto activation triggers for Java
在首发现- >爪哇- >编辑- >内容辅助:
This way you can achieve how Visual Studio handles auto-complete.
通过这种方式,您可以实现 Visual Studio 处理自动完成的方式。
回答by Karoly Horvath
private
? It looks like you're creating something new.. eclipse cannot suggest in this case.
private
? 看起来您正在创建新的东西.. 在这种情况下 eclipse 不能建议。
Autocomplete is for existing variables/functions/classes/etc.
自动完成适用于现有的变量/函数/类/等。
回答by Clark
In Eclipse, it can get a variable name that you alreadymade.
在 Eclipse 中,它可以获得您已经创建的变量名称。
For example,
例如,
int awesomeVariable;
awesomeVariable = 50;
int superVariable;
superVariable =
If I press Ctrl + Space after that =, it would generate some things that it could fill in. For example, it might suggest awesomeVariable. Basically, it doesn't generate a name for you, it just auto-completes with things you have already created.
如果我在这之后按 Ctrl + Space =,它会生成一些它可以填充的东西。例如,它可能会提示 awesomeVariable。基本上,它不会为您生成名称,它只是自动完成您已经创建的内容。
回答by Elio
I tried them one after the other and found out that the correct one is:
我一个接一个地尝试,发现正确的是:
Windows -> Preferences -> Java -> Editor ->Content Assist -> Advanced
: check Word Proposals
Windows -> Preferences -> Java -> Editor ->Content Assist -> Advanced
: 查看 Word Proposals
回答by Liu guanghua
Ctrl + Space is maybe shortcuts of IM, so it is covered, I suggest you change the shortcuts of this function, for example: Alt + /,
Ctrl + Space 可能是IM的快捷键,所以被覆盖了,建议你改一下这个功能的快捷键,例如:Alt + /,
if you don't know how to change shortcuts, please see the following steps:
如果您不知道如何更改快捷方式,请参阅以下步骤:
- click Ctrl + Alt + L twice,
- find "Content Assist",
- change Binding value to you like shortcuts(cannot same the other shortcuts),
- click Apply button.
- 单击 Ctrl + Alt + L 两次,
- 找到“内容辅助”,
- 将绑定值更改为您喜欢的快捷方式(不能与其他快捷方式相同),
- 单击应用按钮。
回答by Arturas M
Thanks for everyones time and help. :)
感谢大家的时间和帮助。:)
I finally found it and the answer to this was that in my case the "java.awt.Color" wasn't imported and eclipse doesn't work on this one if it's not imported.
我终于找到了它,对此的答案是,在我的情况下,未导入“java.awt.Color”,如果未导入,则 eclipse 将无法在此上运行。
So it does suggest the name for you if your file had imported the class already, but if it hadn't it won't work.
因此,如果您的文件已经导入了该类,它确实会为您建议名称,但如果没有,它将无法工作。
I guess it makes the whole function pretty useless, but unfortunately that's how eclipse works. :/
我想这会使整个函数变得毫无用处,但不幸的是 eclipse 就是这样工作的。:/
回答by sushanth
it just suggesting you can also declare the variable by that name..it just helping you because it was a tool write..nothing to worry about that..you can give your own name as you like kk..
它只是建议你也可以用那个名字来声明变量..它只是帮助你,因为它是一个工具编写..没什么好担心的..你可以像kk一样给你自己的名字..
import Color Class to your class: import java.awt.Color;
将颜色类导入您的类: import java.awt.Color;