Reputation: 185
I am working on a project in intellij using java and spring. I want to change in multiple files my api's in a similar way like this:
instead of:
public void someApi(HttpServletRequest request, HttpServletResponse response) throws Exception {
someThrift thriftRequest = getThrift(...);
someOtherThrift thriftResponse = …
setThriftResponse(...);
}
use this:
@ThriftResponse
public someThrift getReports(@ThriftRequestBody someThrift thriftRequest) throws Exception {
someOtherThrift thriftResponse = …
return thriftResponse;
}
is there a way to achieve this using some sort of a macro? this kind of code spans on multiple files that all have the same suffix in their name as well
thank you
Upvotes: 3
Views: 381
Reputation: 62783
As said in the comments, you can use Structural search and replace. It allows you to search and replace fragment of codes using a template defined with variables constraint by count numbers, regular expressions, and even Groovy scripts.
The easiest way to create a template is to browse the list of existing ones, find one similar to what you want to achieve and modify it.
Upvotes: 1