【问题标题】:Structural Search against return type of Annotated method in IntelliJ 13针对 IntelliJ 13 中带注释方法的返回类型的结构搜索
【发布时间】:2014-05-28 09:02:15
【问题描述】:

根据主题,我试图在结构上搜索使用特定注释和特定返回类型注释的所有方法。

为了更清楚,如果我有如下方法:

@MyAnnotation
public String myMethod1(){}

@MyAnnotation
public Integer myMethod2(){}

我想找到一种方法在 IntelliJ 中制定结构搜索以查找,例如,“所有使用 @MyAnnotation 注释且返回类型为 String 的方法”,这样的搜索将只返回 myMethod1()

我正在使用 IntelliJ 13 Ultimate。
谢谢。

【问题讨论】:

    标签: java intellij-idea structural-search


    【解决方案1】:

    使用结构搜索,复制现有模板类的方法。 修改如下:

    class $Class$ { 
      @MyAnnotation
      $ReturnType$ $MethodName$($ParameterType$ $Parameter$);
    }
    

    并编辑 $ReturnType$ 变量以指定文本/正则表达式:
    String (或可选地确定 java\.lang\.String)

    【讨论】:

      【解决方案2】:

      我会将Find in Path 与正则表达式一起使用。
      Text to find: 会是这样的:

      @MyAnnotation\n\spublic.*myMethod1()

      问候

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-26
        • 2021-06-06
        • 2014-04-18
        • 2014-11-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多