IntelliJ cannot find any declarations

走远了吗. 提交于 2019-11-29 19:41:14

I had this same problem, and @AniaG's solution in the comments worked for me.

  • Right-click src folder
  • Mark Directory as > Sources Root

I faced the same issue and spent almost 15-16 tiring hours to clean, rebuild, invalidate-cache, upgrade Idea from 16.3 to 17.2, all in vain. We have a Maven managed project and the build used to be successful but just couldn't navigate between declaration/implementations as Idea couldn't see the files.

After endlessly trying to fix this, it finally dawned to me that it's the IDEA settings causing all the headache. This is what I did (Windows system):

  1. Exit IDE
  2. Recursively delete all .iml files from project directory del /s /q "C:\Dev\trunk\*.iml"
  3. Find and delete all .idea folders
  4. Delete contents of the caches, index, and LocalHistory folders under .IntelliJIdea2017.2\system
    1. Open Idea and import project ....

VOILAAAAAAAAAAAA...!! I hope this helps a poor soul in pain

Pavithra

I had the same issue with idea and I was trying to open a maven project but the pom files where not identified. So right clicking on the pom file and choosing "add as maven project" did all the magic for me :)

sujeet

Your source folders where your Symbols are (Classes) are need to be configured as "Content Root".

  • Open Project Structure: #;
  • Click Modules
  • You can configure your Content Root (Sources, Tests, Resources etc) for each module that you want to Navigate to.

Once done you should be able to navigate to your symbols.

I was having similar issues in my IntelliJ mvn project. Pom.xml was not recognized as. What worked for me was right click on the POM.xml and then add as a maven project.

Figo Wang

I found this cannot find declaration to go to problem once in my Maven project. The reason for this was just that one of the sub-projects in my project did not import as maven project correctly.

If you see red circle on the icon of Java files, and got warning like "cannot find declaration to go to". Then you can do something below:

  1. Right click root folder of your project/module.
  2. Mark Directory As -> Excluded.

It works for me. in Windows 7, Intellij 2016.1.1

Had the same problem. But only on my own methods.
Just fixed it by invalidating cache: (File-> Invalidate Caches/Restart)

Anand

Ensure that the directory which contains your compiled classes and libraries is marked as sources Root.

Came across the same issue and in my case (Java project), I had to include all the dependent jars in the project's libraries section.

File -> Project Structure -> Libraries

I had to add my project dependent jars in the above section (for example; project/web/lib/). After doing so, all resolved fine. I hope this will help someone.

In my case, I just updated my IntelliJ to Ultimate 2018.2 and all of my projects suddenly cannot find the implementations and the 'src' folders - it turned out IntelliJ removed the type of project (e.g. Maven).

What I did is:

Right click on the root project > Add Framework support... > Look for Maven (in my case) > Wait to re-index again > Then it worked again.


UPDATE 2:

I have always been encountering this when I update IntelliJ (2019.1.1 Ultimate Edition). Just click the refresh button of Maven Tab and it should re-index your current project as Maven Project:

mykey

IDEA may ignore some of your maven dependency files. The "External Libraries" node in your project structure might be empty or incomplete.

Go to:

  1. IntelliJ --> Preferences
  2. Search for Maven [on the left tab] -> Ignored Files
  3. See if there is any path on the right side that is checked(ignored) and uncheck that.

In my case I was using a gradle project with subprojects. The reason IntelliJ couldn't find declarations was that the subprojects were not built.

After investigating why subprojects were not built, I found out that using "auto-import" was breaking the subprojects.

After importing the project from build.gradle without auto-import, it worked for me.

For what its worth, in Pycharm it is: Right click on the root folder->Mark Directory as-> Sources Root

Same Problem for Python Project!!!

I tried to make a clean new intellij project and updated everything. Tried different virtualenvs but nothing worked out.

UNTIL I uninstalled the Python Plugin + Restart IntelliJ + Intall Python Plugin + Restart IntelliJ again. I'm not sure if this is a "real" solution, but it solved my issue.

Maybe you can try something familar for Java "Plugin"/JDK?

In my case, none of the above helped. Only upgrade of Intellij from 2017.3 to 2018.2 helped.

Do not try 2018.1 as it had a bug wherein the Find files popup would not come up.

Most of the times there has been a problem with building the cache of the IDE, or something related.

Most probably, File -> Invalidate Caches / Restart, will resolve this problem, just let the IDE finalize it's caching.

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