structural-search

How can I use Intellij Structural Search to find all methods that use two named classes?

旧时模样 提交于 2019-12-08 17:00:36
问题 Say I have two Java classes, TradeType and InstrumentType. I know that somewhere in my codebase there is a method that maps from TradeType to InstrumentType. How can I use Structural Search in Intellij to say "find me all methods that have a single parameter of type TradeType and which return InstrumentType" 回答1: Search template: class $Class$ { InstrumentType $MethodName$(TradeType $Parameter$); } Then click Edit variables... , and set the following for the MethodName variable: Occurrences

Matching chained method calls with structural search

江枫思渺然 提交于 2019-12-08 11:32:57
问题 I try to match this kind of method calls of some fluent API. There can be an arbitrary number of method calls (at least 2 calls, but no upper limit). The whole expression should be matched. Actually, the goal is to find chained method calls in a fluent api which omit doIt() , as in this case the fluent API does nothing. FooClass.some("fluent") .api() .bar(()->"somelambda") .doIt(); I tried something like FooClass.$a$($b$) and use different "occurence counts" like 0,∞ for $a$ , and 0,1 for $b$

IntelliJ structural search and replace problems

别说谁变了你拦得住时间么 提交于 2019-12-06 14:00:13
Is there an easy way to capture types? I can't seem to do basic things like use variable expressions side by side, such as $mapType$$mapEnd$ to do a simple replacement. Is there any reason this might be? That is, if I have a single expression, say .*\s*.*abc , and I break it into two variables, .*\s* and .*abc , the expression does not match any text. What could be going wrong? Example template: $var1$ = $impl$ Example second template: $var1$ = $type$$implEnd$ If $impl$ is a full regular expression, placing $type$ and $implEnd$ together with half of the matching regex causes patterns not to

Structural Search to match method call with generic parameter

做~自己de王妃 提交于 2019-12-06 13:53:05
Let's say that I have a class class Foo : Base and I want to perform a certain method call with signature public void someStuf(Iterable<? extends Base> param) For the search template I just take as starting point the pre-existing one $Instance$.$MethodCall$($Parameter$) Is it possible to match a parameter of any kind Iterable of a specific Base subclass ( Foo in this example)?? List<Foo> fooList = new ArrayList<>(); fooList.add(new Foo("A")); List<Bar> barList = new ArrayList<>(); barList.add(new Bar(1)); someStuff(fooList); // find this! someStuff(barList); // don't find this one someStuff

IntelliJ Structural Search to find classes that implement A but not B

馋奶兔 提交于 2019-12-06 02:20:24
问题 I'm trying to use IntelliJ 10.5's "structural search" feature to find classes that implement an interface, A but do not implement another interface, B . By searching first for classes that implement A , and then limiting the search scope to 'previous search results,' it's easy to reduce this to just searching for classes that do not implement B , which is conceptually pretty simple. Unfortunately, I haven't yet managed to pull it off. If I search for class $clazz$ implements $B$ {} and then

How to convert a C# object initializer to use a constructor using Resharper structural find and replace

回眸只為那壹抹淺笑 提交于 2019-12-04 07:53:56
I want to use a Resharper structural search and replace template to automatically replace examples of this: new Fruit { Name = "Apple", IsTasty = true } With this: new Fruit("Apple", true) (Note, the required constructor already exists) I've tried various combinations like this: new $type$ { Name = $name$, IsTasty = $isTasty$ }; ...using various different Placeholder types, but R# doesn't find any of the examples in my code. Has anyone done this before? So I just did this in resharper (9.0.2 I think) Create pattern: FruityChange new $type$ { Name = $param1$, IsTasty = $param2$ } $type$ is a

IntelliJ Structural Search to find classes that implement A but not B

两盒软妹~` 提交于 2019-12-04 07:31:23
I'm trying to use IntelliJ 10.5's "structural search" feature to find classes that implement an interface, A but do not implement another interface, B . By searching first for classes that implement A , and then limiting the search scope to 'previous search results,' it's easy to reduce this to just searching for classes that do not implement B , which is conceptually pretty simple. Unfortunately, I haven't yet managed to pull it off. If I search for class $clazz$ implements $B$ {} and then tick 'invert condition' in the text constraints for variable B, it seems to find 'all classes that