【问题标题】:Intellij Structural Search for param type and actual typeIntellij 结构搜索参数类型和实际类型
【发布时间】:2014-04-18 16:14:50
【问题描述】:

想象一下,我想搜索具有任意数量参数的所有方法,这些参数接受为 Collection 之一,但通过传递 List 来调用。示例:

  • void test1(集合 x)
  • void test2(A a,Collection x)
  • void test3(Collection x, B b)
  • void test4(List x, B b)

我有:

  • test1(myList) # 匹配项
  • test1(aCollection) # 不匹配
  • test2(xxx, myList) # 个匹配项
  • test3(myList, xxx) # 个匹配项
  • test4(myList, xxx) # 不匹配,因为我正在寻找对接收集合的方法的调用,并且我们传递了一个 List。

有没有办法使用结构搜索?

【问题讨论】:

    标签: intellij-idea structural-search


    【解决方案1】:

    如果您想查找对方法的调用,而不是方法本身,可以使用以下搜索模板:

    $call$($a$, $argument$, $b$)
    

    具有以下变量约束:

    a, b

    • 最小计数:0
    • 最大数量:无限制

    参数

    • Java 表达式类型的文本/RegExp:列表
    • 方法的形式参数类型的文本/正则表达式:集合

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-13
      • 1970-01-01
      相关资源
      最近更新 更多