Questions tagged [structural-search]

A tool to search and replace language constructs in source code, indifferent to formatting and comments. Structural Search & Replace is developed by JetBrains and available in IntelliJ IDEA, PhpStorm, WebStorm and Resharper.

152 questions
1
vote
1 answer

Concatinate string literals using IntelliJ IDEA Structural Replace

I am trying to search static concatenation of strings and combine them into single string using Structural Search Replace. For instance I want to search replace "String1"+"String2"+"String3" and replace with "String1String2String3" .But it should…
Prashant Bhate
  • 10,907
  • 7
  • 47
  • 82
1
vote
2 answers

Structural Search against return type of Annotated method in IntelliJ 13

As per the subject, I am trying to structurally search against all methods annotated with a specific annotation and with a specific return type. To be clearer, if I have methods like the followings: @MyAnnotation public String…
mdm
  • 3,928
  • 3
  • 27
  • 43
1
vote
1 answer

Intellij - how to keep structured search/replace from discarding annotations?

I created a structured search and replace, using this search string: protected $FieldType$ $FieldName$; and this replace string: private $FieldType$ $FieldName$; to replace, for example, this: @Autowired protected JdbcTemplate…
Don Branson
  • 13,631
  • 10
  • 59
  • 101
1
vote
1 answer

Resharper search pattern to detect methods that return a value that is not used

I would like a resharper pattern to detect unhandled IDisposables if possible. If I have a method IDisposable Subscribe(...){....} and call it without assigning and using that IDisposable I would like to be told about it. I have tried the…
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
1
vote
2 answers

ReSharper Search pattern for .First([With condition]) ignoring .First()

As the title reads, is there a way using the ReSharper search pattern to find all instances of .First() that contains a condition, ignoring .First()? The motivation for this search is in response to question Why is LINQ .Where(predicate).First()…
paligap
  • 942
  • 1
  • 12
  • 28
1
vote
1 answer

Is there a way to make a resharper rule to discourage ref & out parameters?

It's my opinion that ref & out parameters hurt code readability. In most instances they can be replaced using generics & nullable types. I'd like to have resharper warn when someone tries to define a function that has a ref or out parameter.…
dan
  • 9,712
  • 6
  • 49
  • 62
1
vote
1 answer

Intellij filtering Find Usages/Call hierarchy

I need to do important refactoring in a framework. I have a method called about 300 times from various locations in the code (i.e. Find Usages give me about 300 results). I would like to filter those results so that it only return usages that are…
ben75
  • 29,217
  • 10
  • 88
  • 134
0
votes
2 answers

Intellij structural search for method invocation where class containing method is marked with specific annotation

Intellij structural search script to to find all method invocations where method source class is marked with @Internal annotation. As for example bellow - script should return a.a(); package com.interestingpackage.internal import…
doleris
  • 25
  • 4
0
votes
1 answer

Structural search - find any final local variables?

I'm trying to work with IntelliJ's structural search to find any local variables declared final. I'm using the following: class $Class$ { $ReturnType$ $Method$ ($ParameterType$ $Parameter$) { $S$; [0,inf] final $Type$ $Name$ =…
rb612
  • 5,280
  • 3
  • 30
  • 68
0
votes
0 answers

ReSharper structural search: Method declaration

I'd like to write a Rider/ReSharper custom inspection based on method signatures, but I'm not sure if structural search and replace works well against parameter list declarations. I'd like to look for a parameter of type A in a method signature, and…
Tim Robinson
  • 53,480
  • 10
  • 121
  • 138
0
votes
0 answers

How to find all occurences of an AIC initializer with N statement pairs inside?

I am struggling to write a search template that would match all pairs of expressions in a block like new Expectations() {{ someInstance.someMethod(BRAND_ID, SPORTSBOOK); result = Mono.just(providerConfiguration); …
62mkv
  • 1,444
  • 1
  • 16
  • 28
0
votes
0 answers

Intellij SSR: how to extract structured information from initializer expressions

Is there a way to extract into some structured format (JSON, XML, whatever) partial information from a number of constructor calls expressions? Say we have code like: public enum Model { TOYOTA, FORD } public enum Dealership { …
62mkv
  • 1,444
  • 1
  • 16
  • 28
0
votes
1 answer

how to find and replace annotations based on parameters?

I have a big java project using TestNG Test annotation. I want to add parameter timeOut=100L to all tests, that are not part of a group (defined via Test Annotation parameters). We use groups for functional/integration/etc. I want to impact only…
gabriel
  • 147
  • 1
  • 9
0
votes
1 answer

Issues with Resharper Search with Pattern/Structural Replacement functionality

I am trying to use Resharper's Search with Pattern/Structural Replacement functionality to find (cs)html fragments like the following, with the end goal of replacing said code with an editor template:
@Html.LabelFor(model…
JP.
  • 5,536
  • 7
  • 58
  • 100
0
votes
1 answer

Why does IntelliJ Structural Search find some of `(int) ($expr$ + 0.5f)`, but not all?

I'm trying to use Structural Search to replace a rounding anti-pattern with the correct pattern. I'm searching for: (int) ($expr$ + 0.5f) in order to replace it with: Math.round($expr$) Strangely, that search pattern finds most of the instances of…
Pepijn Schmitz
  • 2,143
  • 1
  • 17
  • 18