Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

java - IntelliJ Structural Search to find all classes without given declarations

Consider we have a class

public class MyTest() {
    @Inject private Class1 class1;
    @Inject private Class2 class2;

}

and a class

public class MyTest2() {
    @Inject private Class1 class1;
    @Inject private Class2 class2;
    @Inject private Class3 class3;

}

I want to find all classes that inject class1 and class2 and DO NOT inject class3. I've tried to use Structural search from IntelliJ but got stuck. Is it doable with structural search?

question from:https://stackoverflow.com/questions/65844900/intellij-structural-search-to-find-all-classes-without-given-declarations

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Maybe by using search template:

class $a$ {
  @Inject private Class1 $_1$;
  @Inject private Class1 $_2$;
  $3$;
}

and search text filters for $_1$ $_2$ and $_3$: respectively

text=class1
text=class2
text=!@Inject private Class1 class3;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...