Structural search for transient fields


I've been trying to create a structural search that finds all transient instance fields with a certain annotation. So first i did the search for fields with the annotation which works fine. The problem is, i cannot find a way to also include a restriction on the transient modifier. In the example template i found something that looks promising (search for package local fields):

class $Class$ {
@Modifier("packageLocal") $FieldType$ $FieldName$ = $Init$;

I've not been able to find any docu on the valid values for @Modifier("x"). I've tried transient and TRANSIENT but they are not valid.

Any clues on this would be much appreciated or just some advice on whether what i'm trying is even possible.



Correct template syntax for selecting instance transient fields with particular annotation is provided below:

class $Class$ {
  @$Annotation$( )
  transient @Modifier("Instance") $FieldType$ $FieldName$ = $FieldInitial$;

I.e. you can get built-in 'annotated fields' template, add 'transient @Modifier("Instance")' qualification to it and define target annotation constraint.ssr-annotated-fields.png
The problem is that 'transient' qualification is procesed incorrectly at the moment. I created dedicated ticket for that - IDEA-54656. Feel free to track it's processing.

About '@Modifier' role during structural search processing - it's supposed to be used only when it's not possible to naturally define the criteria. Basically, it's assumed to be used only for 'packageLocal' and 'Instance' qualifications, all other criteria like 'transient', 'volatile', 'synchronized' etc should be used as is directly at template body. I created dedicated ticket about providing documentation about @Modifier usage - IDEA-54654.


Hey thanks a lot for that.

I found another solution  by discovering some totally undocumented feature in one of the example  templates (static fields that are not final) which had the following in  the script section:


So  after modifying that i got it working (after spending ages trying to  work out why non-matching files were coming up in the search results  with the line /**).


Hi Oliver,

You made very good work, thanks.

I absolutely agree that there is a lack of documentation for structural search script constraints. Created corresponding ticket for that - IDEA-54748. Feel free to watch/vote it up.

You said that there was a problem with incorrect search processing for the files that contain '/**' - can you provide more information about that? I.e. we need to fix the bug if it's there.



Please sign in to leave a comment.