

The IDE will use that information to provide additional code completion, will check for string format placeholders, etc. NET base classes have been annotated, as well as popular frameworks such as Caliburn.Micro, NUnit, Nancy’s Razor view engine, xUnit, log4net and so on.įor example, an annotation tells Rider and ReSharper that has a first argument that is a “string format” method. Rider and ReSharper ship with a copy of the XML annotations we have open-sourced on GitHub. All of the. Only one way to tell the engine: annotations.Īnnotations can exist as attributes in our code, as we have seen, or as XML files. Code analysis may warn us that a value can be null, but maybe the underlying code never returns null at all. In our previous post, we saw that the ReSharper engine knew we were working with strings, but only we as the author of that code knew these strings were controllers and actions. We have already seen that we can make this mechanism smarter by telling Rider and ReSharper what we mean. Rider and ReSharper’s code analysis and inspections are very smart on their own and help find code smells, dead code, potential compile time or run time errors, and more.
#Jetbrains annotations how to#
#Jetbrains annotations download#
The IDE will prompt you to download the library with annotations from Maven. In the editor, type an annotation, for example, and press Alt+Enter:įrom the list, select Add 'annotations' to classpath. You can also enable annotations using an intention action.

In the search field, type org.jetbrains:annotations:16.0.2 if you use JDK 1.8 or later.įor JDK 1.5, 1.6 or 1.7, type org.jetbrains:annotations-java5:16.0.2.Īdd in the editor Open the Project Structure dialog Ctrl+Alt+Shift+S and select Libraries. To add the library with annotations to a Gradle project, add the compile 'org.jetbrains:annotations:16.0.2' dependency to the adle file.įor Maven projects, add the org.jetbrains:annotations:16.0.2 dependency to pom.xml.Īdd to other projects

You can add them to the classpath and use in your code. On top of that, IntelliJ IDEA provides a collection of annotations that are available as a separate project. In Java, there is a set of built-in annotations. Java annotations are pieces of metadata that provide information about the code they are used with, and can instruct the IDE how to process this code.
