How to create complex Structural Search Inspection with condition

Answered

Hello,

I need to detect absence of some annotation on Class or Method with condition:

if (noClassAnnotation) {

    if (noMethodAnnotation) {

         error();

    }

}

I made two Search Inspections to make this checks separately. How can I combine it with this condition or maybe there are some mechanism to run inspections one by one? 

 

0
5 comments

Hi, its possible to create a custom inspection profile and run it through Analyze | Inspect Code https://www.jetbrains.com/help/idea/code-inspection.html

0
Avatar
Permanently deleted user

I think you didn't understand my question. I already have custom inspections according guide from your link.

@$Annotation$( )
class $Class$ {}
@Test @$Annotation$
public void $Method$();

 How can I combine them in the chain like

if (checkFirstInspection) {
if (checkSecondInspection) {
}
}
0
Avatar
Permanently deleted user

Hello?

0

I don't quite understand how you want to combine the two. If you want to find unannotated methods in unannotated classes, it should be possible to just combine the patterns into one:

@$Annotation$
class $Class$ {
  @Test @$Annotation$
  public void $Method$();
}

With Annotation min/max set to 0 and Method set as This variable is target of the search. I hope that helps.

1
Avatar
Permanently deleted user

It's not solving my cases completely but it helped. Thank you!

0

Please sign in to leave a comment.