【问题标题】:In IntelliJ, is it possible to find usages of a typed method with a specific type?在 IntelliJ 中,是否可以找到具有特定类型的类型化方法的用法?
【发布时间】:2016-04-14 13:00:37
【问题描述】:

假设我有一个类型化的方法:

public interface Foo {

    public <T> T bar();
}

在 Intellij 中,我可以只搜索特定类型的方法用法吗?说,只有String?

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

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

【问题讨论】:

  • 似乎没有内置功能,所以我为 IntelliJ 团队创建了a ticket。随意投票。

标签: java intellij-idea usability structural-search


【解决方案1】:

冒着让你失望的风险,我不这么认为。我浏览了“查找用法”选项,但没有任何乐趣。我认为也许标准的文本搜索是前进的方向。

【讨论】:

  • 你没有:) 我几乎认为没有选择,只是想确定一下。我想我会为他们开张票。
【解决方案2】:

这是可能的,但需要一些工作。使用Edit &gt; Find &gt; Search Structurally 并输入如下搜索模式:

$a$.<String>bar()

在“结构搜索”对话框中单击Edit Variables,将Foo 放入Expression type (regexp) 文本字段并启用Apply constraint within type hierarchy。单击OK,然后单击Find,将找到所有带有 的调用,即使类型参数是隐式的,例如:

String s = foo.bar();

【讨论】:

    猜你喜欢
    • 2014-02-20
    • 2019-12-15
    • 1970-01-01
    • 1970-01-01
    • 2016-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多