Difference in parsing generated sources

Difference in parsing generated sources

This is a light bug/interesting anomaly report.

While I was working on my own pet project I started reworking my GraphQL endpoint to do error management following the Error as Data approach. First I tried the way where my java classes representing the GraphQL entities are written by hand. This approach was just uncomfortable as I had to deal with the FasterXML/Jackson annotations. It just felt dirty.

The second approach I tried is using Kobylynskyi's GraphQL Java Codegen but since I did not know the correct configuration to add the necessary I run into the same error and struggle.

Anyway, I did what has to be done in cases like this. Create a small super focused example to find a solution. So, I did it. This is the part which is relevant to NeoVim.

When I generated the graphql entities IntelliJ parsed correctly the namespaces of the generated entities. As you can see in the screenshots below there are no errors at the imports.

While in NeoVim, using this config showed the following errors:

  • in the generated classes that the package name is incorrect

  • in the controller class that the imports generated entities representing the GraphQL model are invalid

Did not matter how many times I typed :LspRestart, or restarted LunarVim or recompiled the project using mvn clean compile the error message persisted.

But, as I moved the project to another location in order to be able to link to this article in a manageable way something has changed. When I started LunarVim to make screenshots about the error messages they disappeared. According to NeoVim's status line JDTLS did many things and it seems it cleaned up cache so it could see the current state.

The lesson here is that I need to figure out how can I fully restart the LSP. The result is that I always have IntelliJ open to be able to quick help with it if NeoVim/LSP gets into a strange state. The goal here is to consistently show the same state in NeoVim what IntelliJ shows.