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.
Questions tagged [structural-search]
152 questions
0
votes
0 answers
Jetbrains Structural Search - Matching Constants
I'm using Android Studio and I'm trying to create an inspection for myself to match all instances of a View.INVISIBLE - View is a class and INVISIBLE is a constant. If I have View.INVISIBLE in my structural search query it doesn't find instances of…

Marius Miliunas
- 61
- 3
- 9
0
votes
2 answers
Search with regex - is there a way to find classes that do not have a certain annotation in any of its methods?
I want to look in a certain directory and find in all of its sub directories all of the classes that derive from X and do not have annotation Y.
If this isn't possible, I can manage with all classes that do not contain annotation Y.
Is that possible…

Bick
- 17,833
- 52
- 146
- 251
0
votes
2 answers
Matching chained method calls with structural search
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…

user140547
- 7,750
- 3
- 28
- 80
0
votes
1 answer
How to find method annotated with a specific annotation without a specific argument set?
Example :
I want to have all the instance of :
@Test
$MethodType$ $MethodName$($ParameterType$ $ParameterName$);
but not
@Test( group="wazoo")
$MethodType$ $MethodName$($ParameterType$ $ParameterName$);

Teocali
- 2,725
- 2
- 23
- 39
0
votes
1 answer
IntelliJ Structural Search : Try Catch in Tests
I recently switched from Eclipse to IntelliJ Idea, and I'm very pleased with this change.
But, I don't get how to write my own structural search template.
I'd like to identify all test methods containing try ... catch ... finally blocks in order to…

jurocknsail
- 15
- 5
0
votes
1 answer
How to exclude code block in Intellij IDEA Structural Replace
I'm creating own inspections based on Structural Replace.
For example I want to make inspection of transforming code like:
if (!$Map$.containsKey($key$)){
$Map$.put($key$, $value$);
}
and
if ($Map$.get($key$) == null){
$Map$.put($key$,…

agavlyukovskiy
- 231
- 3
- 11
0
votes
1 answer
structural search Intellij IDEA : Howto find occurrences of all classes extending another class
is there a way to search for all occurences of subclasses of a particular class ?
Say I have a class AbstractItem and I have got a lot of implementations of this AbstractItem class. Now I want to know where all subclasses are used.
Can I search for…

Detlef Brendle
- 131
- 1
- 8
0
votes
1 answer
Intellij regular expression search in XML atributes
I'm using Intellij and I want to search for XML attributes.
For example this XML line:
I want to search my project for any other instances of this line:


Eden G
- 60
- 8
0
votes
1 answer
Find structurally catch blocks in IntelliJ IDEA
I need to find all catch blocks with one-letter catch parameters in Java code, for example:
catch (IOException e)
I've tried the following pattern and it doesn't work:
catch ($Type$ $name$)
$name$ text/regexp set to `.`

Michal Kordas
- 10,475
- 7
- 58
- 103
0
votes
1 answer
IntelliJ structural search generics
Maybe I do not understand IntelliJs structural search not.
I want to find all occurences which match the following example pattern:
Map mapper = new HashMap<>()
My not working approach was
Map<$a$,$b$> $c$ = new HashMap<>()
Does…

EhmKah a.k.a. Michael Krauße
- 2,837
- 5
- 34
- 53
0
votes
1 answer
How to find top level not annotated classes in IntelliJ IDEA
Motivation: Every class/interface/annotation/enum has to be annotated by @SomeAnnotation. However we want this annotation to be only at the top level classes and not at the inner ones.
The goal is to create a structural inspection which warns…

imparente
- 151
- 5
0
votes
1 answer
IDEA Structural Search - matching code at end of method
I'm trying to find methods like this:
@Test
public void testStuff()
{
doStuff();
doOtherStuff();
mockery.assertIsSatisfied();
}
The goal is to remove the mockery.assertIsSatisfied(). I can't just remove all calls to it because…

Hakanai
- 12,010
- 10
- 62
- 132
0
votes
1 answer
Regex to find a method with specific return and behviour inside of it
I want something similar to this, but within the scope of a method.
Given a project, I want to find all the files with a method which return an specific Object and use another specific method.
Currently I only have this:…

Patrick Bard
- 1,804
- 18
- 40
0
votes
1 answer
Structural find/replace in Resharper format identifier
When using R# structural find/replace, is it then possible to alter/modify the output of a token?
e.g. if I capture an identifier, can I then reformat this using regex in the output?
I'd like to transform this:
[Fact]
public void…

Roger Johansson
- 22,764
- 18
- 97
- 193
0
votes
1 answer
Intellj Idea refactoring replace one interface with another
I found 2 similar interfaces. I'd like to replace all usages one interface with another in 1 click (refactoring). Refactoring is more safe due it aware of context change rather than plain regexp replace.
But I cannot find fit refactoring in IntelliJ…

Daniil Iaitskov
- 5,525
- 8
- 39
- 49