4

Android Studio helps the user writing good code in several ways. One of them is the Code Inspection which tells the user about some missing stuff or unused code. For example, when I have an Activity with a Fragment in it, i use FragmentTransactions to change the Fragment. To finish such a transaction, I have to call commit(). If I don't do this, Android Studio gives me this warning:

Android Studio Code Inspection warning

If you use a Toast and forget to call show() on it, there is a similar warning.

So my question is: Can I implement a custom inspection like this?

As Android Studio is based on the IntelliJ IDEA, this is probably a feature of IntelliJ.

Community
  • 1
  • 1
l7r7
  • 1,134
  • 1
  • 7
  • 23
  • See my question on this topic http://stackoverflow.com/questions/40133113/writing-custom-lint-warning-to-check-for-custom-annotation – Adam Oct 21 '16 at 08:13

1 Answers1

1

According to a video on the Android Developers Channel it is the Structural Replace Feature of IntelliJ. The video moves forward quite fast so you can read this article about the video content.

In Android Studio/IntelliJ you can find the Structural Replace dialog via Edit | Find | Replace Structurally, create your pattern and click Save Template.

For more details, see also the IntelliJ help page for this feature.

l7r7
  • 1,134
  • 1
  • 7
  • 23