Eclipse 自动完成:Java 1.7 泛型钻石 [英] Eclipse Auto Complete: Java 1.7 Generics Diamond

查看:28
本文介绍了Eclipse 自动完成:Java 1.7 泛型钻石的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级到 Luna(来自 Kepler),我注意到一些小(但很烦人)的问题:
自动完成无法为变量初始化中已经指定的泛型生成菱形<>".例如,当我输入:

I just upgraded to Luna (from Kepler) and I noticed some little (yet annoying) problem:
The auto completion lacks the possibility to generate diamonds "<>" for already specified generics in variable initialisation. For Example, when I type:

Set<String> mySet = new HashSet 

我希望它会自动完成

Set<String> mySet = new HashSet<>();

而不是

Set<String> mySet = new HashSet<String>();

我使用的是 JDK 1.7,并且合规性级别也设置为 1.7.

I am using JDK 1.7 and the compliance level is set to 1.7 also.

同样很奇怪的是,当我在自动完成过程中多次点击 STRG+Space 直到它再次到达 java-autocompletion 然后点击 Enter 时,它会提供预期的钻石.

Its also very strange that when I hit STRG+Space multiple times during auto-completing till it reaches java-autocompletion again and then hit Enter it delivers the expected diamonds.

这在我看来很像一个错误.
此错误是否已知",是否有解决此问题的方法?找不到与此主题相关的任何内容.

This looks very much like a bug to me.
Is this bug "known" and is there any workaround for this issue? Could not find anything related to this topic.

推荐答案

您很可能安装了 Code Recommenders 插件.不幸的是,这个插件受到 bug #435597 的影响,它破坏了这个功能.

You have most likely installed the Code Recommenders plug-in. Unfortunately this plug-in is affected by bug #435597 which breaks this functionality.

只有当您在‘默认’内容辅助列表"(Eclipse Preferences > Java > Editor> 内容辅助 > 高级).例如,我可以通过禁用以下建议类型来恢复正确的行为:

This bug appears to occur only if you have certain proposal kinds enabled in the "'default' content assist list" (Eclipse Preferences > Java > Editor > Content Assist > Advanced). For example I could get back the correct behavior by disabling the following proposal kinds:

  • 基本提案
  • JPA 提案
  • 模板提案

(如果您使用代码模板,最后一个可能是最烦人的……)

(the last one is likely the most annoying if you are using code templates…)

当您使用 ctrl+space 进行循环时,您实际上达到了Java 提案"(而不是Intelligent Java Proposals (Code Recommenders)"),不受此错误影响.

When you are cycling with ctrl+space, you are actually reaching the "Java Proposals" (instead of the "Intelligent Java Proposals (Code Recommenders)"), which is not affected by this bug.

此错误计划在 2.2.0 版发布2015 年 6 月.目前您能做的最好的事情是:

This bug is scheduled for release 2.2.0 in June 2015. The best you can do for the moment is:

  • 使用建议来检查哪些建议为您触发了错误(在执行此操作之前,请先截取当前设置的屏幕截图);
  • 投票错误 #435597bug #435660 以修复它们;
  • 提出补丁以修复这些错误:-)
  • Play with the proposals to check which ones trigger the bug for you (maybe take a screenshot of your current setup before doing that);
  • Vote for bug #435597 and bug #435660 to get them fixed;
  • Propose patches for fixing those bugs :-)

这篇关于Eclipse 自动完成:Java 1.7 泛型钻石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆