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 negate search in intellij structural search

How can i exclude terms from intellij's structure search? (NOT text or regex seach!) for example, using the annotated field template, let's say i want to add @Lazy to all occurrences of @Autowired for fields of type X? That means I want to…
gabriel
  • 147
  • 1
  • 9
0
votes
1 answer

IntelliJ Search Template /Custom Inspection: Analyse sibling annotations

in our project we have a custom annotation @DeprecationReason which should be used to document why a member/method/class is deprecated (and thus annotated with @Deprecated) So to have an IntelliJ warning when @Deprecated is used but…
Manuel
  • 3
  • 2
0
votes
1 answer

Is there a way to add 1 to a string containing numbers in find and replace in intellij?

I have code that looks like this: public void testSomething1() { } public void testSomething2() { } public void testSomething3() { } And I want the result to look like this with find and replace: public void testSomething2() { } public void…
Alex L
  • 3
  • 1
0
votes
1 answer

How to refactor Bootstrap 4 radiobuttons to Bootstrap 5 uinsg Intellij's Structural Replace

I am trying to update some Java Server Pages/Spring Webflow views from Twitter Bootstrap 4 to Bootstrap 5. I have lots of radiobuttons and the requisite HTML boilerplate has changed quite a bit from v4 to v5. This seems like a good use-case for…
Bob Brown
  • 930
  • 2
  • 7
  • 14
0
votes
1 answer

How to avoid assigning child instances to parent class type variables at declaration with Structural Search command in IntelliJ IDEA?

I'm trying to create an inspection based on Structural Search to avoid initializing ExecutorService to Executor Variables. The below is my template:
0
votes
1 answer

IntelliJ TypeScript Structural Search

Is it possible to define a structural search in IntelliJ to warn about the use of the native JavaScript String class instead of the Typescript string type? The typescript documentation recommends that you never use the native JavaScript types (see…
Michael
  • 2,460
  • 3
  • 27
  • 47
0
votes
1 answer

How to find functional interface candidates in IntelliJ

I'm trying to use search structurally to find interfaces that could be annotated with @FunctionalInterface since they only contain a single abstract method but aren't annotated yet. My current structural search template looks like…
jimonthebarn
  • 710
  • 9
  • 24
0
votes
0 answers

How to use structural search in IDEA to find lines without a trailing comment or comment that doesn't match a pattern

The requirement is that all static and not final variables are marked with a corresponding trailing comment, that contains a certain text (e.g. "TEXT") I used the already existing template in IDEA "static fields that are not final", which works fine…
0
votes
0 answers

IntelliJ Structural Search in PhpStorm to find 2 default statements within Switch block

I need to find all switch blocks which has 2 default cases: switch (1) { default: echo "Default 1"; break; default: echo "Default 2"; break; } Trying this: switch () { $s$ default: }
0
votes
1 answer

IntelliJ Structural Search in PhpStorm to find specific function used within foreach block

I need to find all foreach blocks wherever I have used current() function inside of it. Below is sample code block, which should get find. $x=12; foreach ($array as &$val) { $cur=current($array); $x=$x+$cur; echo $cur; }
0
votes
1 answer

IntelliJ IDEA: How to create a new class field during Structural replace

I have many calls to static class method E.g. LegacyLogger.println (ERROR_LEVEL, "Simple string parameter"); I have found all the needed code occurrences by using the template: LegacyLogger.println(ERROR_LEVEL, $params$) How can I possibly import…
ngranin
  • 181
  • 2
  • 14
0
votes
0 answers

Structural Search IntelliJ IDEA

I want to perform a structural search from IntelliJ IDEA. My research is made up of two criteria: Find all classes with custom @CustomAnnotate annotation This annotation is placed exclusively on Repository springs; the result of this research…
0
votes
1 answer

How to find usage of deprecated java classes with Structural Search command in Intellij IDEA?

I'm trying to create inspection based on Structural Search And Replace feature. So, I need to create search template to find all usages of deprecated classes in java code but I can't understand how to do it. I've tried set: Search template:…
0
votes
0 answers

Can I use structural search in HTML files to find nested tags?

I want to find and replace some child tags that are nested inside parent tag. Here is my template: <$tag$ $attribute$=$value$> <$childTag$ $childAttr$=$childValue$ /> <$tag$/> I apply text filtering via regex to $value$ and to…
Dmitry Davydov
  • 987
  • 13
  • 21