Reputation: 15084
I have a number of Eclipse projects that are all using classes from a specific package, let's call it "gr.serafeim". Now, I want to find where (which line numbers of each file) in all my source files are the members of gr.serafeim are used. The problem is that I am usually using imports and not the fully qualified names of classes, so searching for "gr.serafeim" will only return me the import statements :(
I don't want anything fance, just a quick and dirty solution to find out all the lines containing classes of the gr.serafeim package (an eclipse plugin ?). As an added value, I don't want only the declarations but also the method calls of these function.
Here's an example of what I actually wanted:
// File main.java
import gr.serafeim.*;
public static void main(String args[]) {
// Test is a member of gr.serafeim !
Test t = new Test(5);
int i=3;
t.add(i);
}
What I'd like to get as a return from the previous file would be something like this
main.java: 5: Test t = new Test(5);
main.java: 7: t.add(i);
If the previous can't be done, then I could also go with a way to massively name qualify all my classes. So the statement
Test t = new Test(5);
would become
gr.serafeim.Test t = new gr.serafeim.Test(5);
and then I'd just grep for gr.serafiem. This of course won't help in finding the t.add(i) line but would be a good first step and I could go from there checking the code myself ...
This is not the same with this question!
Upvotes: 1
Views: 3229
Reputation: 113
Simply remove the package from your build path and the compiler starts showing error wherever it is used.
Upvotes: 0
Reputation: 96
You can select class, constructor, method or field and press "ctrl + alt+ h". This opens the call hierarchy menu.
Upvotes: 1
Reputation: 298818
Here's a hack:
Mark the package as deprecated using a package-info.java file:
@Deprecated
package com.yourcompany.yourpackage;
Now you should see compiler warnings everywhere you use the package
Upvotes: 1
Reputation: 160170
Right-click -> References -> (whichever you want). For workspace references, Shift-Ctrl-G (by default, anyway).
I think the default results list is a tree, that can be changed to a list. I don't think it shows line numbers, however, at least in the slightly-dated version of Eclipse I'm using. If you're specifically looking for line numbers, I don't think the default tools have an export that includes them.
You might try the IntelliJ Community Edition; its searches do show line numbers, and results are exportable to a text file (fragment below).
Class
server.UDPServer
Found usages (44 usages)
StartThread.java (6 usages)
(12: 19) private final UDPServer myserv;
(14: 17) StartThread(UDPServer server){
(18: 16) myserv.button1.setEnabled(false);
(19: 16) myserv.button2.setEnabled(true);
(30: 32) myserv.area.append("Server is started\n");
(37: 36) myserv.area.append(" Received "
Upvotes: 1