Filter Eclipse's “Open Call Hierarchy” to just

2019-04-21 23:45发布

问题:

One of my favorite features of Eclipse is the ability to open a caller/callee hierarchy of a method.

By default, the view shows calls to/from classes that are outside of my codebase... which I don't usually care about.

There is an option to filter out specific package names I don't want, but I need to do the opposite... to filter out all packages except the one I want. What is the appropriate regex to use here to "match all strings except those that start with com.mycompany.?"

回答1:

It appears that "Filter Calls" uses glob syntax for filter patterns, not regular expressions. You can't specify something that should not match with glob patterns. Sorry.



回答2:

I had the same problem lately and exploring the options of the Call Hierarchy led me to the Search In option. It is activated by clicking on the triangle

The filtering options are pretty simple and effective:



回答3:

It is not exactly what you are looking for, but it is an alternate solution. Take a look at nWire for Java. It is a code exploration plugin. Among many other things, it will present the call hierarchy. However, it will only show calls which originate from your own code, so it should fit your needs.



回答4:

Another approach is to open the 'Type Hierarchy' view's View menu, select 'Select Working Set' and select an existing or new working set that only includes the project you're currently interested in (create one just for this purpose if necessary, e.g. called 'TypeHierarchyFilterWorkingSet').

I just did this using Eclipse Indigo, by the way, not sure whether the other versions have something similar.



回答5:

After "Open Call Hierarchy" right click on the root of the results and select under "References" or "Declarations" the project you interest in:



回答6:

One solution (though somewhat brute force) is to remove the other code from Eclipse's reach. Either put them into separate workspaces, or, if you sometimes do need them in one workspace, close the other projects when you don't want to see them.



回答7:

You could try to add a parameter to the method, than all calls will be shown as error on rebuild.



回答8:

you could filter out org., net., java.* and so on. This (in my case) reduces the list enormously