Intellij idea annotations library to enforce call to super

已回答

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!

1
正式评论

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?

0

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.

0

@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/

0

请先登录再写评论。