日食不插入“金刚石”运算符在java 8项目中 [英] eclipse not inserting "diamond" operator in a java 8 project
问题描述
Map< String ,字符串> map = new HashMap<>();
甚至抱怨老式代码(类型参数的冗余规范)当我设置这个在错误/警告选项卡上。问题是,我无法解决如何使自动完成默认使用这种语法 - 我很确定我看到它早点工作,但现在每当我ctrl-space插入一个构造函数,它坚持添加参数,我不喜欢。
任何人都可以提示要检查什么设置,使内容协助插入<>而不是< String,String>?或者也许这与我使用Java 8而不是Java 7的事实有关,或者是我在maven?
我在几分钟前就遇到了这个问题,并通过输出一个SO问题解决了这个问题。
Eclipse的自动完成显然优先考虑了旧式通用语法之前曾经提到过高级内容辅助设置。尝试重新设置 Java>编辑>内容辅助>高级
默认值;这是为我修复,并返回自动完成,默认插入钻石语法。
I have a maven project configured to use Java 8 and all works fine, eclipse compiles code like:
Map<String,String> map = new HashMap<>();
It even complains about old-style code ("redundant specification of type arguments") when I set this on the Error/Warnings tab. The problem is, I can't work out how to make it use this syntax by default on autocompletion - I'm pretty sure I saw it working earlier but now whenever I ctrl-space to insert a constructor, it insists on adding the parameters, which I don't like.
Can anybody hint what setting to check to make content assist insert <> instead of < String,String >? Or perhaps it's related to the fact I'm using Java 8 not Java 7, or that I'm on maven?
I had this issue just a few minutes ago and solved it half way through typing out an SO question.
Eclipse's auto-complete apparently prioritized the old-style generic syntax after I had fiddled with the advanced content assist settings a while ago. Try resetting Java > Editor > Content Assist > Advanced
to defaults; this was what fixed it for me and returned auto-complete to inserting the diamond syntax by default.
这篇关于日食不插入“金刚石”运算符在java 8项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!