osundblad / intellij-annotations-instrumenter-maven-plugin

IntelliJ IDEA annotations instrumenter maven plugin
Other
38 stars 11 forks source link

Stop double check on Kotlin files #55

Open maf123sp opened 3 years ago

maf123sp commented 3 years ago

Hello, I have set up the plugin to add the null-checks in my modules. The modules are generated based on mixed java and kotlin files. The pitty side effect is, that even my original kotlin files are processed by Your plugin and have now a double-check for null.


if (param == null) { throw new IllegalArgumentException("NotNull annotated argument 0 of must not be null"); } Intrinsics.checkNotNullParameter(param, (String)"param");

Is there any chance to avoid the "double-check" and to skip all files originally based on Kotlin?

Thanks a lot,

Matthias

osundblad commented 3 years ago

Sorry for late reply, I don't have time to work much on this plugin 😞 .

One way would be to only annotate the Java classes with @ImplicitNotNull ie not setup full implicit in Maven.

But this is something that I think is missing maybe should be added. But since the plugin work on class files I know of no way to determine the actuall source file to determine if it is Java, Groovy, or Kotlin etc. (which was actually a good thing until Kotlin made NotNull default, as it should be! (ie the reason for this plugin)).

I was planing for an implicit package level annotation but never had time to do it, but that might not help in your case (unless java and Kotlin is in different packages. (this can be done with https://github.com/osundblad/intellij-annotations-instrumenter-maven-plugin#exclusion but is messy)

The other way is matching class filenames with source filenames, but I don't want to do since I is so error prone with anonymous/synthetic classes.