PNS PNS - 15 days ago 12
Java Question

IntelliJ Code Completion not working for new Java classes

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

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.

For example, after declaring

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


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.

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

Any ideas?

Answer

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!