I have some legacy code and I want to mark all of them and all of their methods @Deprecated
so that as we go and touch them we can remove these annotations so we can keep track of what has been modernized and what still is bad.
I am trying to use the Structural Search/Replace
and can't seem to get the correct template going.
Search Template
class $Class$ {
$ReturnType$ $MethodName$($ParameterType$ $Parameter$) { $Stmt$; }
}
Replace Template
@Deprecated
class $Class$ {
@Deprecated
$ReturnType$ $MethodName$($ParameterType$ $Parameter$) { $Stmt$; }
}
But this removes everything else that is in the class.
@Deprecated
class OldAndCrusty {
@Deprecated
( );
}
This strips off all the visibility modifiers and final modifiers of all the classes it matches.
Unfortunately I can't test this as I don't have the proper IntelliJ version. But as I found here, you can use a variable for the class content.
Search template:
Replacement template:
The minimum and maximum occurrence counts for the
MyClassContent
variable should be set to0
andInteger.MAX_VALUE
respectively. This should leave you with the classes annotated.Now, I suppose you can do the same with a method template too. What I don't know is if you can apply the method template to all methods in the source. That way you should be able do a 2-step search and replace: First for classes, next for methods.