Configuring Check/Assert Methods in IDEA 13 beta
Hi there
I use IDEA Cardea IU-133.124.
I would like to configure assert methods but I cannot find the specific button as it is described in this page: http://www.jetbrains.com/idea/webhelp/configuring-check-assert-methods.html
Is it missing in this version or has it been moved to another place?
Thanks
Stefan
Please sign in to leave a comment.
This feature is deprecated in IDEA 13, please use contracts instead: http://blog.jetbrains.com/idea/2013/10/better-control-flow-analysis-with-contract-annotations-and-intellij-idea-13/
Hi Peter
Is the "infer nullity" feature also deprecated? As I understand helps the configuration of check and assert methods to infere nullity. Now it is harder for IDEA to infer @NotNull and @Nullable.
What do you think?
Cheers
Stefan
Just for cross linking:
http://youtrack.jetbrains.com/issue/IDEA-35808
"Infer Nullity" should work as expected. Do you experience any issues with it?
It works fine but without ability to configure the assert methods I guess it's harder to infere @NotNull. Or am I wrong?
Infer Nullity doesn't currently use that information. And you have the ability to configure assert methods using contracts.
You mean in a method where I use SomeAsserter.assertNotNull(aParameter) I can add a contract like (I don't know the syntax) @Contract(aParameter -> fail)?
Or do you have an example how I extend the following?
The simplest way would be to annotate aParameter as @NotNull and remove SomeAsserter. It might also get you runtime assertions generated by IDEA.
You can annotate SomeAsserter.assertNotNull method by @Contract("null->fail"), this will make IDEA's highlighting know that in "more code" part aParameter is not-null. If you have access to SomeAsserter source code, you can do this annotation directly there. If it's in a library, go to the declaration of assertNotNull and choose "Add Contract" intention from Alt+Enter menu and enter null->fail there.
Hi Peter
Ok, now I understand your approach. Instead of configuring check/assert methods I annotate them directly with contracts. I'll try that out.
Thanks alot for the help
Stefan