I have a code generator written in Java (Xtext) that outputs Rust code. Now, I would like to debug the generated code (e.g. check for type errors), I would like to use rust-analyzer for this. There is a symlink in my Rust project to the path of the generated source file. When I open the symlink with Emacs/VSCode (with a respective LSP plugin + rust-analyzer), rust-analyzer complains about the generated source file not being in a module and ignores the contents of the file.
I was wondering if there is some way to get rust-analyzer to deal with symlinks differently or perhaps some entirely different approach to debugging automatically generated code (possibly without rust-analyzer)?
Where is the file located? Where is your rust project located? And how are you using the rust file? (using mod generated_file;, #[path = "path/to/generated_file.rs"] mod generated_file; or include!("path/to/generated_file.rs")?)
The file is in the directory where the source file is located (= the file that was used to generate the Rust code). It's a complete module with imports from the crate I want to integrate into (it's pretty much like a plugin). include! won't work because it's not inline code but a whole module... and I think #[path] only works with files that are within the crate but are not automatically included over the crate folder structure.
Files are never automatically included in a crate. You always have to either use include!() or mod foo; and in the later case you can optionally use #[path] to control which file to include for the module.