1

I'm using IntelliJ 15 and I'm trying to find usages of methods and objects in a .java file packed in a .jar file downloaded through Maven. I now that they're used: I can find them through the simple search (ctrl+f) command, but when I try with the Find Usages command the post-title message is returned.

I've read this post, but it doesn't work.

This an example of a method in a file InstanceManager.class (belonging to .jar file imported with Maven):

private void notifyNewInstance(Instance instance) {
    List var2 = this.instanceListeners;
    synchronized(this.instanceListeners) {
        Iterator var3 = this.instanceListeners.iterator();

        while(var3.hasNext()) {
            InstanceListener listener = (InstanceListener)var3.next();

            try {
                listener.newInstanceAvailable(instance);
            } catch (Throwable var7) {
                LOG.error("Notification of new instance availability failed.", var7);
            }
        }

    }
}

And in the same file is called with this.notifyNewInstance(host); but if I use Find usages on notifyNewInstance I'll receive the error.

UPDATE: I've tried to Download the source code, but I get the message:

Cannot download sources Sources not found for: org.apache.flink:flink-runtime_2.10:1.1-20160316.114232-35

Can you help me with that?

Community
  • 1
  • 1
justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
  • 1
    What type of usage is there? Could it be that there are multiple classes with the same name on your classpath (but with different package names)? Have you tried ticking all the boxes when doing advanced usage search (ctrl+shift+alt+F7)? – Tobb Mar 18 '16 at 10:28
  • I don't understand what you mean by "type of usage", but for example in find of usage of a method, I would like to see a list of where the method is called, and this doesn't happen (even if I KNOW that it does even in the same file). – justHelloWorld Mar 18 '16 at 10:30
  • 1
    Is the `.jar` you downloaded a dependency? If so, it's not a usage in your Project Files because it's read as a dependency by IntelliJ. Can you also provide code and/or examples of what you're doing as it is unclear. – Harmelodic Mar 18 '16 at 11:23
  • Updated with example – justHelloWorld Mar 18 '16 at 13:01
  • That method is decompiled from a class file... It isn't part of the class file. You have to download the sources of the Maven library if you want to search the methods – OneCricketeer Mar 18 '16 at 13:05
  • You're right. I **UPDATED** the question – justHelloWorld Mar 18 '16 at 13:09
  • Possibly useful note: IntelliJ considers the version for "find usages", so if you have two different libraries (A and B) loaded in your project, and A depends on B-2.10, if you release B-2.10 and then start working on B-2.11 in the same project while A still depends on B-2.10, then IntelliJ will start reporting that every method in B-2.11 is unused. – Gordon Mar 18 '16 at 14:52

1 Answers1

0

You need to get the source code.

Assuming you're attempting to do this on Apache Flink:

Source Code found here

If you only want a particular folder from the source code, you can use the method found here.

Community
  • 1
  • 1
Harmelodic
  • 5,682
  • 1
  • 28
  • 31