IntelliJ Code Completion not working for new Java classes

送分小仙女□ 提交于 2019-11-28 10:48:42

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!

Make sure you mark all your Source directories as such in File -> Project Structure -> Modules.

Makoto

Ensure that you are not in Power Save Mode while running IntelliJ (File [menu] -> Power Save Mode checked or not). If Power Save Mode is enabled, IntelliJ will not run background tasks, including code completion.

I am using IntelliJ Ultimate 2017.1, and I encountered similar issue. Maven project, was trying to using selenium APIs, but the intellisense didn't pop up relative methods for me.

Here is the way I solved my issue:

Right click on your project src folder
Choose Mark Directory As Then select Sources Root

There could be 2 reasons for your problem

  1. Either the the source folder is not properly configured in the your build java build path. If the source folder is not properly configured the autocomplete wont get the required class definitions and autocomplete would fail for your project.
  2. Restoring the default options in 'Windows > Preferences > Java > Editor > Content Assist > Advanced'

Right click on project -> Add framework support -> Select Maven -> Click OK

The only thing that worked for me was killing IntelliJ (on Ubuntu) and starting it again.

Cut the folder .idea and the files *.iml in the root folder and paste somewhere else out of project. when you re-open the project , auto import will work again magically.

I had this same problem and it was caused by me not having a folder marked as sources root.

Right click on your src directory and Mark Directory As > Sources Root.

I was facing this issue while coding for eclipse-che client extension. Eclipse che modules are all of maven type. My client extension project was an independent module which can be compiled independent of the parent project. When I imported the same structure to Intellij my client-side extension project was not giving suggestions. After I include the client-extension project to the parent module (adding it to pom.xml) the suggestions started showing up.

Remove your package from the Settings>Editor>General>Auto Import>Java>Exclude from Import and Completion

I had run into this problem. None of the solutions from this post worked, but I was able to fix it because I accidentally put my project's package in the "Exclude from Import and Completion" settings.

Sander

I had a groovy project where somehow the jdk was not set as a dependency, so jdk classes would not autocomplete.

Fix:

  1. project structure
  2. modules
  3. (your module)
  4. tab Dependencies.
  5. In the field Module SDK, add a jdk.

This is not IntelliJ 13 but a more recent 2017.1.1 Community version. Adding this answer here so that others benefit from a cause that has its roots in the Gradle Configurations.

Now, in my case too the auto complete, Generate Override methods and other features were not working. What I figured out is that in my project settings, I had multiple configurations for the gradle modules. The moment I cleaned up the rest of the modules and retained the only one (apart from test) I needed for that project, all behaviors were back to normal.

Also in such cases of Gradle projects, remember to mark all your sourceSet root folders ad the Source folders.

Edit: If you do not want to create multiple configurations per sourceSet and you are importing a gradle module, on the import screen, you should also disable the Create a module for per sourceSet flag. Without this, I was having to remove the multiple modules after importing the module.

I had similar problem, nothing in this topic helped.

So finally I made it work, I clear cache of IntelliJ and restart.

File > Invalidate Caches / Restart.. > Invalidate Cache and Restart (button)

It was happening for me in a module that was not added in the parent project pom (they did it on purpose), that was the reason, I right clicked the pom.xml of the module that has the issue and clicked the

now the autocomplete came and in addition to that I can see the module as a separate project in the maven tab on the top right.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!