Refactoring annotations?

I have an annotation parameter that I'd like to move to a different annotation. None of the refactorings seem to work (for example Move errors with 'There are no variables that have a reference type').

For example,
@A(paramA1 = valA1, paramA2 = valA2)
becomes
@A(paramA2=valA2)
@B(paramB1=valA1) - note the use of @A's param val

So, I tried Search/Replace Structurally.
Using the default template
class $Class$ {
@$Annotation$( )
$FieldType$ $FieldName$ = $FieldInitial$;
}

I can find all annotations and refine the search by defining the $Annotation$ variable. I can refine the search further by changing $Annotation$ to $Annotation$($ParamName$) and defining the annotation and param I'm interested in.

However, I cannot seem to use $ParamName$=$ParamVal$ to get the $ParamVal$ I want to extract.

Any suggestions on how to accomplish this?

0
1 comment

If it does not work with pattern like following (assuming you search for
fields) then it is a bug in SSR

@$Annotation$( $paramA1$ = $valA1$, $paramA2$ = $valA2$)
$FieldType$ $FieldName$ = $FieldInitial$;

interface $Class$ {}

Andy Kriger wrote:

I have an annotation parameter that I'd like to move to a different annotation. None of the refactorings seem to work (for example Move errors with 'There are no variables that have a reference type').

For example,
@A(paramA1 = valA1, paramA2 = valA2)
becomes
@A(paramA2=valA2)
@B(paramB1=valA1) - note the use of @A's param val

So, I tried Search/Replace Structurally.
Using the default template
class $Class$ {
@$Annotation$( )
$FieldType$ $FieldName$ = $FieldInitial$;
}

I can find all annotations and refine the search by defining the $Annotation$ variable. I can refine the search further by changing $Annotation$ to $Annotation$($ParamName$) and defining the annotation and param I'm interested in.

However, I cannot seem to use $ParamName$=$ParamVal$ to get the $ParamVal$ I want to extract.

Any suggestions on how to accomplish this?



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Please sign in to leave a comment.