Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why IntelliJ needs Lombok plugin?

As far as I understand, Lombok uses Java's Annotation Processors to generate additional methods.

With Maven 3.5 it works perfectly without adding any additional configuration, just add dependecy to Lombok and put some annotations like @Getter, @Setter.

However, if I open this project in IntelliJ IDEA 2018.2, all usages of generated getters/setters are highlighted as errors. I have Annotation Processing turned on, I tried to built project in IntelliJ or build in Maven and then use in IntelliJ, but it still requires Lombok Plugin to avoid false errors.

Is it some kind of bug? Error in workflow? Or maybe Lombok is using not only Annotation Processors, but some other stuff I didn't know and that's why IntelliJ + javac cannot figure out how to deal with it? It would be strange as javac itself compiles those files without errors

I know there are many questions "I have errors while using Lombok" and answers like "use the plugin". I'm not asking if I should use plugin, but why I should use it, why IntelliJ cannot handle it without plugin while javac does

like image 742
T. Gawęda Avatar asked Aug 30 '18 09:08

T. Gawęda


People also ask

What is Lombok plugin used for?

Project Lombok is a java library tool that is used to minimize/remove the boilerplate code and save the precious time of developers during development by just using some annotations. In addition to it, it also increases the readability of the source code and saves space.

What is Lombok in IntelliJ?

Lombok is a library that facilitates many tedious tasks and reduces Java source code verbosity. Of course, we usually want to be able to use the library in an IDE, which requires additional setup. In this tutorial, we'll talk about configuring Lombok in two of the most popular Java IDEs — IntelliJ IDEA and Eclipse.

Does IntelliJ support Lombok?

This is an outline on IntelliJ Lombok Plugin. Generally, IntelliJ supports different types of plugins, Lombok is one of the plugins which IntelliJ supports.


1 Answers

IntelliJ's code analysis engine does not use javac or run annotation processors. Instead, IntelliJ uses its own Java parser and reference resolution logic, and builds its own code model. The Lombok plugin extends the code model to provide information about declarations generated by the Lombok annotation processor.

like image 143
yole Avatar answered Sep 22 '22 16:09

yole