IntelliJ Structural Search查找实现A而不是B的类 [英] IntelliJ Structural Search to find classes that implement A but not B

查看:115
本文介绍了IntelliJ Structural Search查找实现A而不是B的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用IntelliJ 10.5的结构搜索功能来查找实现接口的类 A ,但不实现另一个接口 B

I'm trying to use IntelliJ 10.5's "structural search" feature to find classes that implement an interface, A but do not implement another interface, B.

首先搜索实现 A 的类,然后将搜索范围限制为以前的搜索结果,可以很容易地将其减少到只是搜索没有实现 B 的类,这在概念上非常简单。不幸的是,我还没有成功。

By searching first for classes that implement A, and then limiting the search scope to 'previous search results,' it's easy to reduce this to just searching for classes that do not implement B, which is conceptually pretty simple. Unfortunately, I haven't yet managed to pull it off.

如果我搜索

class $clazz$ implements $B$ {}

然后勾选'反转条件'在变量B的文本约束中,它似乎找到'所有实现除 B 之外的东西的类',即使它们也实现 B 。我也尝试在'完全匹配'变量上勾选'反转条件',它的效果不是很明显,但绝对不是我想要的。

and then tick 'invert condition' in the text constraints for variable B, it seems to find 'all classes that implement something other than B' even if they also implement B. I've also tried ticking 'invert condition' on the 'complete match' variable, and its effect is not immediately obvious, but definitely not what I'm looking for.

Inicidentaly,其他人在IntelliJ论坛上询问了类似的问题,但没有得到爱。帮助我,stackoverflow!

Inicidentaly, someone else asked a similar question on the IntelliJ forums, but got no love. Help me out, stackoverflow!

推荐答案

要查找实现InterfaceA但未实现InterfaceB的类,我执行了以下操作:

To find classes that implement InterfaceA, but don't implement InterfaceB, I did the following:


  1. 搜索>结构搜索

  2. 点击复制现有模板

  3. 选择界面的实施者(在层级内),然后点击确定

  4. 点击修改变量

  5. 变量列表中选择界面

  6. 输入< 文字/正则表达式中的strong> InterfaceA ,然后点击确定

  7. 点击查找

  8. 搜索>从结构上搜索

  9. 点击修改变量

  10. 选择 变量列表中的界面

  11. 文字/正则表达式中输入 InterfaceB ,< STRO 最小计数 0 最大计数 0 ,然后点击确定

  12. 范围下拉列表中选择以前的搜索结果

  13. 点击查找

  1. Search > Search Structurally
  2. Click Copy existing template
  3. Select implementors of an interface (within hierarcy) and click OK
  4. Click Edit Variables
  5. Select Interface in the Variables list
  6. Enter InterfaceA in Text / regular expression and click OK
  7. Click Find
  8. Search > Search Structurally
  9. Click Edit Variables
  10. Select Interface in the Variables list
  11. Enter InterfaceB in Text / regular expression, 0 in Minimum Count and 0 in Maximum Count and click OK
  12. Select Previous Search Results in the Scope dropdown
  13. Click Find

注意我在步骤8尝试使用编辑查询按钮时出现问题。我没有研究/重试,但回到菜单并选择搜索>搜索结构肯定有效。

Note I had problems when I tried to use the Edit Query button at step 8. I didn't research/retry, but going back to the menu and selecting Search > Search Structurally definitely worked.

这篇关于IntelliJ Structural Search查找实现A而不是B的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆