dylibso / chicory

Native JVM WebAssembly runtime
Apache License 2.0
483 stars 36 forks source link

Generated class files are breaking IntelliJ #576

Open andreaTP opened 2 weeks ago

andreaTP commented 2 weeks ago

Steps to reproduce:

git clone https://github.com/dylibso/chicory.git
cd chicory
mvn -Dquickly

Screenshot from 2024-10-13 11-37-32

You can notice that Wat2Wasm is not recognized by the IDE.

The current workaround to generate a source file Wat2WasmMachineFactory to wrap the generated code masks the issue to the users, but still, it should be great to have a working setup. Everything works as expected with plain Maven commands.

I attempted to ask for help at the IntelliJ boot at Devoxx, but haven't received a contact back so far. The issue is completely reproducible, but I have no clue where to start to debug/narrow it down.

Attempting to summon @bashor for guidance on how to progress with this :pray:

andreaTP commented 2 weeks ago

Cross-linking: https://youtrack.jetbrains.com/issue/IDEA-360628/Generated-class-files-are-breaking-IntelliJ

bashor commented 2 weeks ago

@andreaTP do I understand correctly that Wat2Wasm should be resolved to class inside wabt/src/main/java/com/dylibso/chicory/wabt/Wat2Wasm.java?

If so:

andreaTP commented 2 weeks ago

Thanks a lot for having a look @bashor !

Wat2Wasm is a pure class file generated with ASM, it doesn't have a corresponding .java file associated. The generated source file Wat2WasmMachineFactory.java is a wrapper to avoid that the IDE breaks in user land, but is correctly using Wat2Wasm as it has a constructor that takes Instance as a parameter. The problem is that IntelliJ, apparently, doesn't recognize Wat2Wasm at all.

bashor commented 2 weeks ago

I guess IJ doesn't resolve classes in the output dir of the same module. You can try to put generated files into a separate module and depend on it. Or generate class files into a separate folder and add it to dependencies.

andreaTP commented 2 weeks ago

Thanks for getting back and the suggestion @bashor , it was my very first attempt, but, unfortunately it doesn't work, you can reproduce on this branch Screenshot from 2024-10-14 16-04-58

That said, even if we get this setup to work, I hope we can narrow down the root cause. This is the developer experience we are giving to the users, and asking to create straightaway 2 sub-modules to achieve the functionality seems not optimal.

bashor commented 2 weeks ago

Well, adding the directory to dependencies manually via Project Structure seems to work. Unfortunately, I can't help more here 🤷‍♂️.

andreaTP commented 2 weeks ago

Thanks a lot for the effort and your help on this @bashor . One last question, if you don't mind: is it reasonable to expect updates on the YouTrack issue? Any better alternative to get the ball rolling?

Thanks!

bashor commented 2 weeks ago

One last question, if you don't mind: is it reasonable to expect updates on the YouTrack issue?

IDK, it's a different team, and I am not aware of their process. I've set a more specific Subsystem there; let's wait for some time 🤷‍♂️.