[英]Why do many Collection classes in Java extend the abstract class and implement the interface as well?
[英]In Intellij IDEA, find classes that implement an interface but do not extend another class
在Intellij IDEA中使用結構化搜索,如果我想查找實現接口但不擴展另一個類的所有類,應該如何使用搜索模板? 模板分別是:
class $Class$ implements $Interface$ {}
和
class $Class$ extends $Parent$ {}
分別設置最小和最大1,1和0,0。
我嘗試了與此問題類似的嘗試,但未成功:
您可以結合使用兩個模板:
class $Class$ extends $Parent$ implements $Interface$ {}
使用以下變量設置
$Parent$
:
Text / regexp Excluded
並啟用“ Apply constrains in type hierarchy
,最小/最大0,0
$Interface$
:
Included
text / regexp,並啟用Apply constrains in type hierarchy
,最小/最大1,1
當我在以下測試代碼上使用這些設置進行搜索時,將找到B
和E
。
class Excluded {}
interface Included {}
class A extends Excluded implements Included {}
class B implements Included {}
class C extends Excluded {}
class D extends A {}
class E extends B {}
class F {}
當然,您需要使用自己的類和接口名稱,而不是“包含”和“排除”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.