简体   繁体   中英

In IntelliJ, is it possible to find usages of a typed method with a specific type?

Say I have a typed method:

public interface Foo {

    public <T> T bar();
}

In Intellij, can I search for the method usages only with a specific type? Say, only with String ?

foo.<String>bar(); // will be listed in the search result

foo.<Integer>bar(); // won't

At the risk of disappointing you, I don't believe so. I've looked through the 'Find Usages' option, but with no joy. I think perhaps a standard text search is the way forwards for this.

This is possible, but it requires a little bit of work. Use Edit > Find > Search Structurally and type a search pattern like the following:

$a$.<String>bar()

Click Edit Variables in the Structural Search dialog, put Foo in the Expression type (regexp) text field and enable Apply constraint within type hierarchy . Click OK and then Find and all calls with <String> will be found, even where the type parameter is implicit, for example:

String s = foo.bar();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM