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?
I have tried the following according to this thread (Intellij IDEA CE 12 Android XML Code Completion not working): Go to File->Power Save Mode and disable it - it is off. Go to Preferences->Editor->Code Completion and check Autopopup code completion - this has been checked. Go to File->Invalidate Caches and restart.
Invoke basic completionPress Ctrl+Space or choose Code | Code Completion | Basic from the main menu. If necessary, press Ctrl+Space for the second time (or press Ctrl+Alt+Space ).
Create a new Java classIn the Project tool window ( Alt+1 ), right-click the node in which you want to create a new class and select New | Java Class. Alternatively, select the node, press Alt+Insert , and select Java Class.
Press Ctrl+Alt+S to open the IDE settings and select Editor | General | Code Completion. To automatically display the suggestions list, select the Show suggestions as you type checkbox.
Make sure you mark all your Source directories as such in File -> Project Structure -> Modules.
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.
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!
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
ChooseMark Directory As
Then selectSources Root
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.
It helped me to mark the src directory as the "Source Root".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With