简体   繁体   English

使用正则表达式进行搜索-是否可以找到在其任何方法中都没有特定注释的类?

[英]Search with regex - is there a way to find classes that do not have a certain annotation in any of its methods?

I want to look in a certain directory and find in all of its sub directories all of the classes that derive from X and do not have annotation Y. 我想查看某个目录,并在其所有子目录中找到所有从X派生且没有注释Y的类。

If this isn't possible, I can manage with all classes that do not contain annotation Y. 如果这不可能,那么我可以管理所有不包含注释Y的类。

Is that possible with the regex search? 正则表达式搜索有可能吗?

I think it's not possible. 我认为这是不可能的。 But it's possible to find classes that do not have given annotation (works only if class have only one annotation): 但是有可能找到没有给定注释的类(仅在类仅具有一个注释的情况下有效):

Regex: @(?!Annotation.*) 正则表达式: @(?!Annotation.*)

在此处输入图片说明

This is possible using Structural Search. 使用结构搜索可以做到这一点。 Use a pattern like this: 使用这样的模式:

@$Y$
class $A$ extends $X$ {}

Edit Variables: 编辑变量:
X - text/regexp: X , Apply constraint within type hierarchy checked to find indirect subclasses Y - text/regexp: Y , min/max occurrences: 0 X-文本/正则表达式: XApply constraint within type hierarchy以查找间接子类Y-文本/正则表达式: Y ,最小/最大出现次数: 0

To search a specific directory only, you will have to create a custom scope. 仅搜索特定目录,您将必须创建一个自定义范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用IDEA的结构搜索来查找错过某些注释的字段? - How do I use IDEA's Structural Search to find fields that miss certain annotation? 如何找到一组特定的类并将其重命名? - How do I find a set of certain classes and rename them? 如何在IntelliJ中搜索以给定注释注释的类? - How to search for classes annotated with a given annotation in IntelliJ? 如何检查类是否有@CompileStatic 注释? - How to check classes have @CompileStatic annotation? 如何使用Intellij结构搜索来查找使用两个命名类的所有方法? - How can I use Intellij Structural Search to find all methods that use two named classes? 如果我未能为公共字段和方法提供JavaDoc描述/注释,如何让IntelliJ给我一个警告? - How do I get IntelliJ to give me a warning if I have failed to provide JavaDoc description/annotation for public fields and methods? 通过IDEA结构化查找多次使用注释查找类 - Find classes using an annotation multiple times via IDEA structured find IntelliJ 结构搜索以查找实现 A 但未实现 B 的类 - IntelliJ Structural Search to find classes that implement A but not B Intellij结构搜索:查找字段和对应的getter(迁移注解) - Intellij structural search: find field and corresponding getter (to migrate an annotation) 有没有办法在类的所有方法上设置断点? - Is there any way to set breakpoints on all methods of a class?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM