IntelliJ IDEA没有Java 10'var'的代码完成? [英] IntelliJ IDEA no code completion for Java 10 'var'?

查看:1863
本文介绍了IntelliJ IDEA没有Java 10'var'的代码完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我安装了IntelliJ IDEA的新版本(2018.1),它增加了对Java 10的支持。



但是当我尝试使用 var (对于局部变量类型推断),我发现代码完成列表中没有 var 。 (见下面的截图)



如果我继续输入,它将应用 VarHandle 作为该列表中的第一个建议。然后我必须撤消该完成以恢复 var



我检查了项目设置,我使用的是JDK 10,语言级别也设置为10.代码如 var number = 1; 汇编得很好。我在IDE设置中找不到任何相关内容。



我做错了什么?我只想在不中断的情况下使用 var 声明。



解决方案

正如@Vic指出的那样,


Recently I installed the new version (2018.1) of IntelliJ IDEA, which added support for Java 10.

But when I trying to use the var (for local variable type inference), I found there was no var in the code completion list. (See the screenshot below)

If I continue typing, it will apply VarHandle as the first suggestion in that list. Then I have to undo that completion to restore var.

I have checked project settings, I use JDK 10 and the language level is also set to 10. Code like var number = 1; compiles well. And I couldn't find anything about this in IDE settings.

What am I doing wrong? I just want to use var declaration without interruption.

解决方案

As @Vic pointed out, this appears to be a bug. Until it gets fixed, you can create a custom live template as a workaround.

Create a live template triggered by the var abbreviation, then enter var as the template text. Make it available in the Java statement context.

这篇关于IntelliJ IDEA没有Java 10'var'的代码完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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