问题
I've found how to search for all fields and variables of a type that implements a given interface, in my case AutoCloseable.
My current way to do this is first creating a filter for classes that implement AutoCloseable. This filter is derived from the pre-defined filter "implementors of interface (within hierarchy)" by adding a filter on the Interface.
class $Class$ implements $Interface$ {} where $Interface$ is filtered with text=AutoCloseable.
After saving that filter as "AutoCloseableFilter", I use another filter that uses it:
$FieldType$ where $FieldType$ is filtered with reference=AutoCloseableFilter.
That works, but I'd like to be able to skip the step of saving a specific instance of that pre-defined filter, instead setting its filter when using it as a reference.
In other words, I'd like to create a filter where $FieldType is filtered by reference=implementors of interface (within hierarchy) and then filtering $Interface$ to a specific interface in one go.
Is that possible in structural search?
回答1:
For your use case it appears to be enough to specify a text filter on $FieldType$ instead of a reference filter. Use text AutoCloseable and check the Within type hierarchy checkbox.
来源:https://stackoverflow.com/questions/53759638/when-using-a-reference-in-a-structural-search-how-do-i-filter-its-fields