xmolecules / jmolecules-integrations

Technology integration for jMolecules
Apache License 2.0
79 stars 21 forks source link

Handle case of existing package-info.java file correctly and pick up … #233

Closed tobiasstamann closed 5 months ago

tobiasstamann commented 5 months ago

…even not annotated TypeElements via Packages.

This still won’t guarantee that all TypeElement will be used. But ensures that only one annotation must be present per package.

tobiasstamann commented 5 months ago

Hi, if a package-info. java file is present in package the current implementation wouldn't work since getRootElements would provide the PackageElement instead of the TypeElement. The fix moves validation to processingDone flagged wave and collects all Package names it can get first to then collect and validates all types.

tobiasstamann commented 5 months ago

The code won't currently validate nested classes. I am going to add that as well.

odrotbohm commented 5 months ago

Any reason you tweaked the package name of the example classes? They reside in the example package and thus should have this declared as package, too? Is there any chance you avoid the reformatting? If that gets too much of a hassle, never mind. I can easily fix that myself during the merge.

tobiasstamann commented 5 months ago

Hi, can you please wait with merge until i have added support for nested classes?

I have moved the example classes to another package, because some IDEs are compiling java files that are located in resource folders. Cute offers a way to circumvent that. You can name test file *.java.ct to prohibit this, but this has the tradeoff that for example autocompletion in IDEs wont work anymore. So best way is to have kind of /testcases/testcaseX/ structure. The compiler doesn't need that the folder structure matches the package structure. The only precondition is that the class names must match the file names.

With my implementation the processor would scan for example package names , then it would pick up the compiled classes from example folder. That's why there could be a hassle.

tobiasstamann commented 5 months ago

Do you provide have some kind default formatting/style config i can use?

tobiasstamann commented 5 months ago

Validation of nested classes is now supported as well.

odrotbohm commented 5 months ago

I've folded your changes into GH-230. I had to move the valid probes for the test cases into a separate packages as otherwise, the test cases checking those valid files now included the invalid ones producing errors and thus broke the tests.

Thanks for the contribution. Highly appreciated! 🙇