CTRL clicking goes to decompiled class instead of java class
This always happens to me and I can never figure it out . I'll have a source loaded and I'll CTRL click on a symbol to go to it's definition but instead of finding the .java file (which is present in the project) it decompiles the .class file and then shows me that. All I can think is somehow the .class files got listed as sources in the project configuration and those appear before the .java files of the same name. The thing is, the project in question is the community source and the sources are about a couple million files in modules autmagically loaded when you set up the project by pointing it at the community source. I actually don't think there are .class files in any of them. What this tells me is that the file of the source is not on my sourcepath, but that's not true, at least that missing class whose decompilation is showing up in in the projects view and appears as a source file in the project.
Totally baffled.
Please sign in to leave a comment.
Where are these .class files located to which you are navigated to (path is shown in the frame header)?
Make sure that <Module source> entry is the first one in the table at Dependencies tab of each module (Project Structure dialog).
For me module source on top was not enough. Invalidate caches & restart didn't work. However, the maven toolbox thingy had errors, and a maven reimport fixed it.
Hello,
I am experiencing the same issue and bumped into this thread with apparently no solution yet.
Alexander Doroshko I tried your suggestion but no luck with it. CTRL+click still goes to decompiled classes.
Flavio What kind of project do you have? Does it use Maven?
Hi Arina Efremova, yes I do. It's a multi-module maven project.
Just one more information: the parent project is at the same level as its children modules.
Flavio
Does it help if you enable the following option in File | Settings | Build, Execution, Deployment | Build Tools | Maven | Importing?
Hello,
unfortunately not. Do you suggest to start from scratch one more time importing the maven projects? Any recommendation?
Thanks!
Is it a Spring project that you have?
Yes, please try that after enabling the option.
It is OSGi framework.
I started also from scratch again but no luck with it.
I have a directory containing n-subdirs:
Project Dir
--- moduleA
--- moduleB
--- [...]
--- module-n
--- container
--- pom.xml (with sub-modules declarations for moduleA, moduleB etc.)
What version of the IDE do you have? Can you check if the problem is the same for you in the latest version 2022.2.1 installed side by side?
Do you have Kotlin sources in your project?
Does the action 'Navigate | Class' opens the source file as expected?
Do you have the same problem in a simple new Java+Maven project (before creating it, make sure to enable the option to automatically download sources in File | New Projects Setup | Settings for New Projects > Build, Execution, Deployment | Build Tools | Maven | Importing).
Hi,
I'm using IntelliJ IDEA 2022.2.1 (Community Edition) Build #IC-222.3739.54, built on August 16, 2022.
I have no Kotlin sources in my projects.
Actually the action 'Navigate | Class' opens the source file as expected. I usually do it via CTRL+N and it always opens the source file I need. The problem occurs just when I CTRL+Click on some class which is contained in another module.
Regarding the last point: I have a simple maven project with few external dependencies. If I go into the class using one of these dependencies, I can CTRL+Click and see the source file (not the decompiled one). So this means that the sources have been correctly downloaded.
On my OSGi project instead, it always go to the decompiled class that is coming from a jar installed into my local .m2 repo and IntelliJ doesn't seems to know that the sources are right here, in the project I am working at (namely, the same "workspace").
Thanks!
What brand/version of JDK is used in your OSGi project?
Is it the same for Maven importer in File | Settings | Build, Execution, Deployment | Build Tools | Maven | Importing)?
Does it help if you change them to something else and reload the project from the Maven tool window?
This is the JDK used for my project:
Unfortunately this didn't help.
It's for sure due to my mistake. Could you kindly provide step by step guide on how to start again from scratch? I know there are lots of guides on Internet and I have already followed.
>The problem occurs just when I CTRL+Click on some class which is contained in another module.
>On my OSGi project instead, it always go to the decompiled class that is coming from a jar installed into my local .m2 repo and IntelliJ doesn't seems to know that the sources are right here, in the project I am working at (namely, the same "workspace").
When you navigate to a class from one module, - the IDE for navigation uses the dependencies which are set up for the module. So if the module has a dependency on a local .m2 library jar file - IDE will navigate to this jar file rather than a module.
For the IDE to navigate to a module instead of the jar - it must be set up as a multi-module maven project - where the dependencies in pom.xml file are set up to other Maven modules which have the same Maven coordinates (groupId, artifactId, version) as the coordinates of the module declaration. See for example this guide for an example of such a project structure.
Thanks for your reply Andrey,
considering that I'm not creating a new project but I am trying to import an existing one (it's a bit "complicate" to change the structure now) I totally agree with you but apart the fact that the parent module is in the same directory of the children modules, it is like the guide you mentioned.
Consider that I want to leave Eclipse and finally migrate to IntelliJ despite these problems I am facing, but it's not a good start :D
I think the best solution here would be what Eclipse calls "enable workspace resolution". I don't want to exclude any peculiarity of my projects but Eclipse doesn't have this problem.