1

I have a custom class, which is useless when it's only instantiated, without having its method called. This should never happen, so if it is in the code, I would like a warning in Android Studio that says something like "You instantiated that class, but didn't call it's method. Did you forget to call this method?", so pretty much the same as when you forget .commit() or .show() on some other stuff.

Now I've found some similar questions online, but the answers for those only are "Use Intellij inspections". I got that far, but i don't know how to check if something is missing.

TL;DR: How can I create an inspection that creates a warning when my code does not contain something, similar to the warning when not calling .commit() or .show()?

Example:

ExampleClass example = new ExampleClass;
// Should give me a warning.

ExampleClass example = new ExampleClass;
example.Method($var1$, $var2$);
// Should no longer give me a warning
Timmiej93
  • 1,328
  • 1
  • 16
  • 35
  • 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

0 Answers0