I have proper dependencies
And lombok plugin was installed, so Android Studio know where generation was applied but i still got an error
Please can anyone give me idea what is happening?
EDIT:
from kotlin 1.7.20 with K2 compiler it is possible.
https://kotlinlang.org/docs/whatsnew1720.html#support-for-kotlin-k2-compiler-plugins
OLD:
Ok, I guess my problem somewhat solved. My project have mixed Kotlin\Java code, I found this closed issue in project lombok: https://github.com/projectlombok/lombok/issues/1169
Corresponding to this lombok cant work in Kotlin\Java code normal way cause reasons... and there is two solutions:
Multi module project where all Java code with lobmok separated from Kotlin code and java module should using only java compiler.
Use special plugin from Kotlin which in part solving issue https://kotlinlang.org/docs/lombok.html
Another dum-dum solution: drop lombok annotation on java class and then using some instruments delombok it.This way no javac will be required.
Related
I am using 1 main class and 1 interface and attached my pseudo code for lambda expressions:
Below is how it looks like:
Below is simple interface:
I am not doing any IO operations so
Why do I get the error "File cannot be resolved to a type"?
does not help me.Tried few more options like clean build project. restarting vs code but not helping. Looking for suggestions to fix this java 8 error. Doing java 8 for first time.
My Source code does not contain any file operations so
importing java.io.file was not helping me.
I did Ctrl+Shift+P(Command Pallete) -> Clean Java server language workspace-> Restart and delete.
This solved the error. Its quite weird that Visual studio code sometimes not build workspace properly. I assumed earlier that it happens only with eclipse old versions but it do happens with new vs code editors as well.
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
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.
It's because IDEA syntax highlighter uses internal Java parser. If IDEA used just javac, then it wouldn't be able to highlight syntax errors as you type. It also gives much better hints about wrong code, so each Java construct, feature or annotation must be implemented by JetBrains team or there's plugin for it like in this case.
Annotation processing option is just for building project which is done via javac, but it's not for syntax highlighting.
Ale IDEs use lombok plugin be it intelij-idea or eclipse.
javac works fine with it - but remember that it works when for example you build you project with mvn clean package.
Then when you have your IDE - it works differntly - the code is not processed like in build task.
The plugin make it know to IDE what is this annotation and what code it generates underhood without need of javac.
This happens in a Java and maven project in Eclipse with a kotlin nature.
In this part of the code:
val faces = figure.getFaces()
for (polygon in faces) {
//...
I get the error below in eclipse, where faces, in the second line above, is underlined in red:
Cannot access class 'Polygon'. Check your module classpath for missing or conflicting dependencies
The project is a mix of Java and Kotlin. The figure object is an instance of a Java class, while the faces are a set of type Polygon which is in a different project that is pure Kotlin (ie Polygon is a Kotlin type, in a separate Kotlin project).
This Kotlin project where Polygon is, is indeed in the classpath as a Maven dependency, and in fact used by the Java class of which figure is an instance.
I think the problem is in Eclipse, because I can build the project with maven successfully. It looks like either a bug in eclipse or a configuration issue.
I know it's strange to have a mix of Java and Kotlin. I simply started this project in Java and then decided to convert it to Kotlin gradually. So far I haven't had many issues but I'm aware that Kotlin tools and support in eclipse are not mature yet.
Not much of a proper solution: I converted my Figure class to Kotlin and the problem went away, but I can do that because I have full control on my project.
Possibly newer versions of the eclipse plugin won't generate this error or, as suggested in the comments, switching to IntelliJ IDEA is another option.
I just discovered google's AutoValue library, which seems great.
I'm trying to compile the example project which I downloaded from here
But the project doesn't compile.
The compiler complains about the AutoValue_ constructor symbol not being recognized.
Can someone explain what I am doing wrong?
I am using auto-value-1.3.jar
Thanks
IntelliJ does not enable annotation processors by default.
You can follow the official guide. You need to go to the Annotation Processors page and click + to create a new profile. Then you have to associate your module with this profile. In the end you only need to enable annotation processing for this profile and everything should work.
The IntelliJ editor might not find the generated class files though and still display the name red. But it should not affect the build.
I am new ( and only person ) on old Java project. Couple guys have developed this before me. Is there any tool ( plugin for Eclipse would be nice ) which can find in project dead classes ( classes that are declared but they don't use anymore anywhere ?
You could use the Emma plugin to determine code coverage and look for the classes with 0% coverage after a full run.
To make sure before you remove classes, use the eclipse function that shows all references to the class in case it is used in exception handling.
Looks like similar question already asked on Stackoverfow check out the following links already asked on SO
How to find unused/dead code in java projects
Find unused classes in a Java Eclipse project
Check out the answers
http://eclipsenuggets.blogspot.com/2007/05/here-is-quick-way-to-eliminate-dead.html
This worked for me (although I tried it several years ago)
IntelliJ has a "Find Usages" that you can apply to classes, methods, strings - anything. Perhaps the Eclipse help can turn up such a thing.
Or maybe you should switch to IntelliJ.
IntelliJ can also generate UML that includes dependencies. Any class or package without a dependency would be a good candidate for removal. You'd get a quick visual that way.