Trying to do a structural find and replace

Answered

I want to rename my @RequestMapping annotations to @GetMapping, @PutMapping ... annotations.

I tried adding the following in the search

@RequestMapping( $key$ = $value$)

Added a filter on the key. text=method

Now I want to extract the from the value (RequestMethod.GET) , the word after . (period). and then in the replacement add

@[Word]Mapping( [everything except the key,value that was extracted in the search])

Is this possible in IntelliJ using structural replace without having to write a custom plugin?

0
6 comments
Official comment

This is currently not supported by Structural Search and Replace, because of a bug. Follow the issue to get a notification when it is fixed.

 

Bas

Hi. Could you please provide example of original string and a string after the replace?

0
Avatar
Permanently deleted user

Here is an example of before and after:

 

Before:

@RequestMapping(
value = "/channels/{channel_name}",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public Channel updateChannel(
@PathVariable("channel_name") String channelName,
@Valid @RequestBody Channel channel) {
return channelService.updateChannel(channelName, channel);
}

@RequestMapping(
value = "/channels/{channel_name}",
method = RequestMethod.DELETE,
produces = MediaType.APPLICATION_JSON_VALUE)
public Channel deleteChannel(
@PathVariable("channel_name") String channelName) {
return channelService.deleteChannel(channelName);
}

 

After:

@PostMapping(value = "/channels/{channel_name}",
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public Channel updateChannel(
@PathVariable("channel_name") String channelName,
@Valid @RequestBody Channel channel) {
return channelService.updateChannel(channelName, channel);
}

@DeleteMapping(
value = "/channels/{channel_name}",
produces = MediaType.APPLICATION_JSON_VALUE)
public Channel deleteChannel(
@PathVariable("channel_name") String channelName) {
return channelService.deleteChannel(channelName);
}

 

0

Hi.

This is currently not supported by Structural Search and Replace, because of a bug. Follow the issue to get a notification when it is fixed.

 

Bas

0

Is this still not supported? If so, making intellij plugin is the only valid way for now?

0

Please sign in to leave a comment.