Question

Imagine I want to search for all the methods with any number of parameters that accepts as one of them Collection but are called by passing a List. Example:

  • void test1(Collection x)
  • void test2(A a,Collection x)
  • void test3(Collection x, B b)
  • void test4(List x, B b)

and I have:

  • test1(myList) # Matches
  • test1(aCollection) # NO match
  • test2(xxx, myList) # matches
  • test3(myList, xxx) # matches
  • test4(myList, xxx) # Does not match as I am looking for calls to methods that receive collection and we pass a List.

Is there a way of using Structural search for that?

Was it helpful?

Solution

If you want to find the calls to the methods, not the methods itself, you can use the following search template:

$call$($a$, $argument$, $b$)

With the following variable constraints:

a, b

  • Minimum count: 0
  • Maximum count: unlimited

argument

  • Text/RegExp for java expression type: List
  • Text/RegExp for formal argument type of the method: Collection
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top