Intellij idea annotations library to enforce call to super
Answered
In Android Studio, it will force you to call super for certain methods. As far as I know, this is not available in IntelliJ IDEA. It would be nice to have this addition in the Jetbrains Annotations library ('org.jetbrains:annotations' in maven).
If such thing is already available, please tell me!
Please sign in to leave a comment.
Have you tried using javax.annotation.OverridingMethodsMustInvokeSuper and ensuring "Method does not call super method" inspection is enabled? You can also configure other annotations there.
Could you please provide a reference to this feature or a code snippet to check how it works?
It works through a plugin provided by Google (by default present in Android Studio) I believe.
Here is a link to how to specify it: https://developer.android.com/reference/android/support/annotation/CallSuper.html
Then when overriding such an annotated method, Android Studio will show an error that says you should call super too.
@Peter Gromov,
Thank you, this works, but it is quite hard to get a set of these annotations. I took them from https://code.google.com/archive/p/jsr-305/