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
0
votes
1 answer

How to find the usage of method in Java code where the arguments are compound expressions?

Probably a duplicate, but I don't know how to search for it.. I use IntelliJ to find method usages. Now I want to find these usages (method calls) where in the method call itself the argument is an expression. So not a reference to a string or a…
0
votes
1 answer

Structurally Replace Intellij Jsp

I want replace structurally an attribute html with its value. The example is the following. I want replace this instruction with
Mirko
  • 13
  • 3
0
votes
2 answers

IntelliJ structural search find derived classes if base class matches criteria

Suppose I have a base class with a field refCount. I accidentally create a derived class which ALSO declares a field with the same name. (Actually, the name is not important: what matters is the type, which is ReferenceCount; but the names are…
Mark VY
  • 1,489
  • 16
  • 31
0
votes
1 answer

How to find all usages of name() related to specific enum type

I need to find all usages of name() method called on specific enum type. Let's say I've got the enum: enum MyEnum { A, B, C; } I want to receive all places where the method is called on any of MyEnum element. It could be called on specific…
Jakub Ch.
  • 3,577
  • 3
  • 24
  • 43
0
votes
2 answers

How to use IntelliJ's structural replacement for "all matches, except..."?

Lets say I want to replace print(x) with print(wrapper(x)). I can match print($Argument$) and replace it with print(wrapper($Argument$)) However, if I already have a call to print(wrapper(x)), I don't want to replace that with…
kc2001
  • 5,008
  • 4
  • 51
  • 92
0
votes
1 answer

Intellij Structurally replace `thows OneException, TwoException` with only Exception

With IntelliJ's s Structural Search and Replace I want to replace the following snippet: @Test public void myTest() throws ExecutionException, InterruptedException {} with: @Test public void myTest() throws Exception {} The goal is to simplify…
Joe
  • 3,370
  • 4
  • 33
  • 56
0
votes
2 answers

How to check classes have @CompileStatic annotation?

I want to perform an automated static check analysis on my Groovy code to identify which clases doesn't have the @CompileStatic annotation. I'd like to know how that can be done either with IntelliJ or CodeNarc custom rule.
0
votes
1 answer

Intellij Structural search functional interfaces

I've finally changed the java version of my android project to 8. Now, I want to use structural search to find all existing functional interfaces and replace them with lambdas. I've reached till the point where I can find the Anonymous classes : new…
Yash
  • 5,225
  • 4
  • 32
  • 65
0
votes
1 answer

Android Studio Structural Search for all Toast statements in code

How do I use Structural Search feature in Android Studio and search code lines similar to Toast.makeText(someContext, " some text "+someVariable, Toast.LENGTH_LONG).show(); I tried the following but it does not match any toast…
xxx374562
  • 226
  • 1
  • 8
0
votes
1 answer

Custom inspection for double quotes

Our code standard requires that all strings in javascript code would have single quotes instead of double quotes. Unfortunately, IntelliJ Idea doesn't have such inspection by default. I've tried to search and follow the official guideline, but it's…
0
votes
1 answer

Intellij structural search and replace for all forms of if statements

I wrote a search like this: preparedStatement = connect.prepareStatement($sql$); $code1$; $resultSet$ = preparedStatement.executeQuery(); $code2$; if ($resultSet$.next()) { $code3$; } And a replace like this: try (PreparedStatement…
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
0
votes
2 answers

How to easily find/search in IDE(specially in IntelliJ), which methods returns int type and also takes string as parameter in java?

so if I put the keywords.. return type:int, parameter:String (something like this) it show results such as void int Integer.parseInt(String) Hope I could explain what I'm looking for.
Ssubrat Rrudra
  • 870
  • 8
  • 20
0
votes
2 answers

IntelliJ Structural Search in PhpStorm to find methods with specific return types

How can I find the method foo with return type boolean in my example using PhpStorm's Structural Search?
timo kranz
  • 153
  • 1
  • 2
  • 13
0
votes
1 answer

IDEA structural search for classes implementing a specific method and no other

In our codebase, I am looking for anonymous subclasses of a given class which implement one specific method and have no other methods or fields. These can be converted into a lambda expression and remove the need for that anonymous subclass. The…
Christian Semrau
  • 8,913
  • 2
  • 32
  • 39
0
votes
1 answer

Intellij replace getClass() with ClassName.class

Is there a way in an IntellJ Idea project that I can replace all calls to getClass() with the current class name + .class? So for example replace: class ClassName{ public method(){ Logger.logDebug(getClass(), "Some information") } } with…
Maarten
  • 808
  • 1
  • 6
  • 17