IntelliJ 代码完成不适用于新的 Java 类 [英] IntelliJ Code Completion not working for new Java classes

查看:30
本文介绍了IntelliJ 代码完成不适用于新的 Java 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IntelliJ IDEA 13 开始在我的本地设置中表现出非常奇怪的行为.

IntelliJ IDEA 13 has started exhibiting a very weird behavior in my local setup.

也就是说,在添加到现有项目中的任何新 Java 类中,Code Completion 不起作用.因此,在新类中声明任何类型的对象变量,然后键入该变量的名称,后跟点 (.) 后,不会出现对应对象的任何方法的建议.

Namely, in any new Java class added to an existing project, Code Completion does not work. So, after declaring an object variable of any type in the new class and then typing the name of that variable, followed by the dot (.), no suggestions come up for any of the methods of the corresponding object.

例如声明后

File f = new File("/home");

键入 f. 不会显示 File 类中所有方法的列表,以从中选择一个.事实上,在输入点 (.) 时,不会出现任何建议,并且在 IDE 窗口的左下角(在状态栏中)会显示消息预期标识符.预期标识符".被陈列.有时,会从不相关的组件或库中提出一长串完全不相关的方法.

typing f. does not bring up a list of all the methods in the File class, to select one from. As a matter of fact, when typing the dot (.), no suggestions appear and at the bottom left (in the status bar) of the IDE window, the message "Identifier expected. Identifier expected." is displayed. Sometimes, a long list of totally irrelevant methods from irrelevant components or libraries are proposed.

奇怪的是,如果上述声明发生在任何现有类中,代码完成会按预期工作.

Strangely, Code Completion works as expected if the above declaration happens in any of the existing classes.

在机器重启、IDE 重启、项目重新导入、关闭/重新打开或重建的多种组合后,此行为仍然存在.

This behavior persists after many combinations of machine restart, IDE restart, project re-importing, closing/reopening, or rebuilding.

有什么想法吗?

推荐答案

对于关注者,一件事帮助了我(自动完成只显示演员表场地实例等)是因为我打开了一个没有正确链接到它的子模块的 Maven 模块(它有一个注释掉的子模块部分),所以 IntelliJ 只是将 Maven java 文件显示为基本上带有一个小j"的文本"文件在项目窗格中的图标中.修复根 maven pom.xml 文件以将子目录包含为模块,瞧,它们再次被视为真正的 java 文件,哇!

For followers, one thing that helped me (auto complete only showed cast field instanceof etc.) was that I had opened a maven module that didn't link correctly to its children (it had a commented out submodules section), so IntelliJ just showed the maven java files as basically "text" files with a tiny "j" in their icon in the project pane. Fixing up the root maven pom.xml file to include the children dirs as modules and voila, they are treated as real java files again, woot!

这篇关于IntelliJ 代码完成不适用于新的 Java 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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