kotlinintellij-ideastatic-analysisintellij-inspections

How to create a custom IntelliJ IDE inspection based on regex?


Is it possible to create a custom IntelliJ IDEA inspections that detects code matching a certain regex? If so: how?

For example I want to spot places in the code where the key for a lookup in a Map is created inside the square brackets:

val x = myMap[SomeKey(a, b)]
              ^^^^^^^^^^^^^

I don't ask for "structural search and replace", because that is not available for Kotlin today.


Solution

  • Structural Search is available for Kotlin since IntelliJ IDEA 2020.3.

    However if you are using a language not supported by Structural Search, IntelliJ IDEA 2023.1 now also has custom RegExp Search & Replace inspections.