문제

I can easily find all mentions of some annotation in my project using SSR (structural search and replace). For example I have following spring based code:

class DashboardController {

  @RequestMapping("/dashboard")
  public void doDashboard() {
    [...]
  }
}

If I search by pattern org.springframework.web.bind.annotation.RequestMapping than I will find my code. But what if I want to find methods annotated with parametrized annotation, so find only method with annotations @RequestMapping for "/dashboard" url?

I can simply search by @RequestMapping("/dashboard") string, but annotation can be written in several ways:

@RequestMapping("/dashboard")
@RequestMapping(value = "/dashboard", method = {RequestMethod.POST})
@RequestMapping(headers = "content-type=application/*", value = "/dashboard")

etc.

도움이 되었습니까?

해결책

Use Structural Search and Replace in IntelliJ IDEA 14. Copy the existing template annotated methods and add "/dashboard" as an argument to the annotation like so:

class $Class$ {
  @$Annotation$("/dashboard")
  $MethodType$ $MethodName$($ParameterType$ $ParameterName$);
}

You might also want to edit the $Annotation$ variable and give it the text/regexp "RequestMapping" This should find all possible formats of the annotation (on methods only).

다른 팁

Why don't you search this :

@RequestMapping\(((.*?)value\s*=\s*)?"/dashboard"(.*?)\)

Why not just do a text search for @RequestMapping("/dashboard"), its unlikely to give that many false positives.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top